NFS file sharing
Experimental environment: two Centos7 Centos7 server IP address: 192.168.10.1 Centos7 client IP address: 192.168.10.2
Server configuration:
install service
yum install rpcbind -y #install rpcbind service yum install nfs-utils.x86_64 -y #install nfs service
Modify the configuration file
mkdir /data/share #Create a shared file vim /etc/exports #Modify the configuration file /data/share 192.168.10.*(rw,sync,root_squash) The configuration file /data/share is a shared folder 192.168.10.*Yes Shared network break rw is to read and write sync is to write data to memory and hard disk at the same time to ensure no data loss. root_squash is when the NFS client accesses as the root administrator, the format of the root administrator configuration file mapped to the NFS server is: [File sharing path]+[Sharing network disconnection]+[Sharing permission]
Restart the service: the order of restarting the service is rpcbind first and then nfs service
systemctl restart rpcbind.service #restart rpcbind service systemctl restart nfs-server.service nfs.service #restart nfs service
Client configuration:
yum install showmount -y #Install test command mkdir /gzs #Create mount point file chmod 777 /gzs #Give all permissions vim /etc/fstab #Write boot self-starting file 192.168.10.1:/data/share /gzs nfs defaults 0 0 The format of the self-starting mount file after booting is: [server IP address][shared folder]+[mount folder] [file system format] [default mount]
Domain name mount
The server needs to do DNS resolution
client
showmount -e nfs.hb.com
mkdir /gzs chmod 777 /gzs vim /etc/fstab nfs.hb.com:/data/share /gzs nfs defaults 0 0 mount -a
If mount.nfs: access denied by server while mounting 192.168.10.1:/share appears on the client side, it is because the firewall is enabled, resulting in the nfs port being greater than 1000. Go to the server to modify the configuration file and remount
vim /etc/exports /share 192.168.10.0/24(insecure,rw,sync,root_squash)
restart service
systemctl restart rpcbind.service #restart rpcbind service systemctl restart nfs-server.service nfs.service #restart nfs service
server mount
yum install nfs* -y vim /etc/exports /kdy *(insecure,rw,async,no_root_squash) systemctl restart nfs rpcbind