Install NFS in centos 7, centosnfs
NFS service Introduction: NFS is the abbreviation of Network File System, that is, Network File System. The client mounts the data directory shared by the NFS server to the local directory. --- The main function is to share files.
Why do you want to install the NFS service: when the server access traffic is too high, multiple service areas need to be distributed, and these servers can use the NFS service for sharing. (NFS is the most basic shared service)
Application Scenario: NFS application scenario, which is often used for high-availability file sharing. multiple servers share the same data, with poor scalability and imperfect high-availability solutions, instead, distributed file systems such as MFS, TFS, and HDFS can be used.
Install the NFS service: to install the NFS service, you must rely on RPC. Therefore, to run NFS, you must install RPC.
1. server side (that is, the computer to be shared)
Assume that the server address is 192.168.1.140.
Download: yum command: yum install nfs * portmap-y // yum command installed on both NFS and RPC
Disable firewall: systemctl stop firewalld
Disable selinux: vi/etc/sysconfig/selinux
Change the status of SELINUXTYPE to: display. Save and exit.
Configuration: nfs configuration file:/etc/exports
Vi/etc/exports
Add:/share * (rw, sync)
/Share is the folder to be shared, and the shared files are stored in the/share folder. * indicates the user connected to ps: 192.168.1.121 and the parameters in parentheses (Parameter Details)
Create a shared folder: mkdir/share
Authorize the folder: chmod 766/share
Set NFS to enable auto-start: systemctl enable nfs
Enable NFS: systemctl start nfs
Set RPC to boot: systemctl enable rpcbind
Enable the RPC service: systemctl start rpcbind
--- You can view the status through systemctl status nfs, etc.
Use the chown command to mount the folder/share: chown nfsnobody. nfsnobody/share
Enter "exportfs" to view the local shared file system. If yes, the system is successful.
2. Client (the computer that views the shared folder)
1. Install NFS and RPC and set them to start and start on startup
2. Disable the firewall and disable selinux.
3. mount the shared nfs system: mount 192.168.1.140:/share/media
4. check whether it is successful: mount | grep media
5. Write the shared directory to the system mount file: vi/etc/fstab
Append: 192.168.1.140:/share/media nfs4 defaults 0 0
Iii. Test
1. Add a test file test1 to the server's shared directory (/share ).
2. view the file in the client, delete test1, and add test2
3. Check whether test2 exists on the server and test1 is deleted successfully.