NFS--------Network File system
NFS Plots
650) this.width=650; "Src=" https://gss0.bdstatic.com/94o3dSag_xI4khGkpoWK1HF6hhy/baike/c0%3Dbaike80%2C5%2C5%2C80 %2c26/sign=132195ebdec451dae2fb04b9d7943903/0df3d7ca7bcb0a46faeb868c6863f6246a60afbd.jpg "alt=" 0DF3D7CA7BCB0A46FAEB868C6863F6246A60AFBD "/>
Role: Data sharing between Linux servers
Software:
Nfs-utils
Rpcbind
[Email protected] ~]# rpm-q Rpcbind
Rpcbind-0.2.0-32.el7.x86_64
[Email protected] ~]# rpm-q nfs-utils
Nfs-utils-1.3.0-0.21.el7.x86_64
[Email protected] ~]#
Catalog Export File---/etc/exports
File format:
Directory name client address (permissions)
Client Address:
IP address 192.168.1.1
Network Segment 192.168.1.0/24
*
Permissions:
Ro Read Only
RW Read/write
Sync Synchronization
Async Async
All_squash Client All users upload files that belong to Nfsnobody
Root_squash The owner of the file uploaded by the root user of the client will be mapped to Nfsnobody
No_root_squash Client root user is still the root of the uploaded file
Anonuid=<number>
Anongid=<number>
Example:
Share local directory/webdata via NFS, allow 192.168.122.121 to mount as read-only
[Email protected] ~]# Mkdir/webdata
[Email protected] ~]# touch/webdata/{1..10}.html
[Email protected] ~]# Cat/etc/exports
/webdata192.168.122.121 (RO)
[Email protected] ~]#
[Email protected] ~]# systemctl restart Rpcbind
[Email protected] ~]# systemctl restart Nfs-server
[Email protected] ~]# Systemctl enable Nfs-server
[Email protected] ~]# showmount-e localhost
Export list for localhost:
/webdata 192.168.122.121
[Email protected] ~]#
Client:
[email protected] ~]# Mount 192.168.122.105:/webdata/www/
[Email protected] ~]# ls/www/
10.html 1.html 2.html 3.html 4.html 5.html 6.html 7.html 8.html 9.html
Auto Mount:
# Vim/etc/fstab
192.168.122.105:/webdata/www NFS Defaults 0 0
Example 2:
Shared local directory/mysqldata via NFS, allowing 192.168.122.121 to mount in read-write mode
[Email protected] ~]# Mkdir/mysqldata
[Email protected] ~]# Touch/mysqldata/{1..10}.sql
[Email protected] ~]# chmod o+w/mysqldata/
[Email protected] ~]# Vim/etc/exports
...
/mysqldata192.168.122.121 (rw)
[Email protected] ~]# Exportfs-rav
Exporting 192.168.122.121:/mysqldata
Exporting 192.168.122.121:/webdata
[Email protected] ~]#
Client:
[Email protected] ~]# Vim/etc/fstab
192.168.122.105:/mysqldata/database NFS Defaults 0 0
[Email protected] ~]# mount-a
[Email protected] ~]# df-h
File system capacity has been used with available% mount points
/dev/mapper/centos-root 7.3G 4.4G 3.0G 60%/
Devtmpfs 230M 0 230M 0%/dev
Tmpfs 245M 0 245M 0%/dev/shm
Tmpfs 245M 4.7M 240M 2%/run
Tmpfs 245M 0 245M 0%/sys/fs/cgroup
/dev/mapper/centos-home 2.0G 33M 2.0G 2%/Home
/DEV/VDA1 512M 141M 372M 28%/boot
Tmpfs 49M 0 49M 0%/run/user/0
192.168.122.105:/webdata 7.3G 3.6G 3.8G 49%/www
192.168.122.105:/mysqldata 7.3G 3.6G 3.8G 49%/database
This article is from the "lyw666" blog, make sure to keep this source http://lyw666.blog.51cto.com/12823216/1957472
NFS for the Linux file service