Centos7 Installation configuration NFS services and mounting tutorial of recommended

  • 2020-06-19 12:28:12
  • OfStack

Now there are 3 servers, s1(master), s2(slave) and s3 (slave), which need to realize real-time synchronization of files. We can install Nfs server and client to achieve this!

1. Packages required to install NFS server:


yum install -y nfs-utils

2. Edit exports file and add slave


vim /etc/exports
/home/nfs/ 192.168.248.0/24(rw,sync,fsid=0)

Hosts with 192.168.248.0/241 network Numbers can mount the /home/nfs/ directory on the NFS server to their own file system
rw stands for read-write; sync means synchronous write, and fsid=0 means wrap /data into a root directory

3. Start nfs service

Start up rpcbind and nfs first :(the rpcbind service must be started first)


systemctl enable rpcbind.service
systemctl enable nfs-server.service

Then start rpcbind and nfs services respectively:


systemctl start rpcbind.service
systemctl start nfs-server.service

Confirm that the NFS server started successfully:


rpcinfo -p

Check that the NFS server mounts the directory /home/nfs/ we want to share:


exportfs -r

# Make the configuration work


exportfs


You can view already ok


/home/nfs 192.168.248.0/24

4. Install the NFS client on the slave

First, install nfs, ditto, and then start the rpcbind service

First do startup for rpcbind:


systemctl enable rpcbind.service

Then start the rpcbind service:


systemctl start rpcbind.service

Note: The client does not need to start the nfs service

Check for directory sharing on the NFS server: ES85en-ES86en nfs server


vim /etc/exports
/home/nfs/ 192.168.248.0/24(rw,sync,fsid=0)
0

Mount the server directory /home/nfs to a client directory using mount on the slave:


vim /etc/exports
/home/nfs/ 192.168.248.0/24(rw,sync,fsid=0)
1

df-h checks to see if the mount succeeded.


Related articles: