This article describes how to configure the nfs service in centos (enable the nfs service in centos). For more information, see CentOS.
Server Configuration
1. install nfs-utils and rpcbind
Copy codeThe code is as follows:
Yum install nfs-utils rpcbind
2. set the startup service
Copy codeThe code is as follows:
Chkconfig nfs on
Chkconfig rpcbind on
3. start Related services
Copy codeThe code is as follows:
Service rpcbind start
Service nfs start
4. create a shared directory
Copy codeThe code is as follows:
Mkdir-p/export/primary
Mkdir-p/export/secondary
5. edit the/etc/exports file and add the following content:
Copy codeThe code is as follows:
Vi/etc/exports
/Export * (rw, async, no_root_squash, no_subtree_check)
6. refresh the configuration to take effect immediately
Copy codeThe code is as follows:
Exportfs-
Client Configuration
1. install nfs-utils and rpcbind
Copy codeThe code is as follows:
Yum install nfs-utils rpcbind
2. set the startup service
Copy codeThe code is as follows:
Chkconfig nfs on
Chkconfig rpcbind on
3. start the service
Copy codeThe code is as follows:
Servicerpcbind start
Servicenfs start
4. create a mount point
Copy codeThe code is as follows:
Mkdir-p/mnt/primary
Mkdir-p/mnt/secondary
5. Mount Directory
Copy codeThe code is as follows:
Mount-t nfs server_ip:/export/primary/mnt/primary
Mount-t nfs server_ip:/export/secondary/mnt/secondary
6. view the mounted Directory
Copy codeThe code is as follows:
Df-h
7. unmount the mounted Directory
Copy codeThe code is as follows:
Umount/mnt/primary
Umount/mnt/secondary
8. edit/etc/fstab and mount it automatically upon startup.
Copy codeThe code is as follows:
Vi/etc/fstab
Server_ip:/export/primary/mnt/primary nfs rw, tcp, intr 0 1
Server_ip:/export/secondary/mnt/secondary nfs rw, tcp, intr 0 1