In the NFS service application, we will encounter mounting usage and configuration. Many of my friends are not familiar with this content. Therefore, we will introduce the content in detail here, hoping to help you understand this knowledge. Note: In some books, brackets can be directly added after the path name and their permissions can be defined. According to the actual test, no error is prompted in this case, however, the system prompts that the permission is insufficient during mounting, Which is depressing. network services defined on UNIX operating systems have two levels of permission settings. One is the file system level permission settings, and the other is the network service custom permission settings.
NFS is short for Network File System, that is, Network File System. it is used to share files between UNIX systems. It can be easily mounted to a directory, which is just as convenient as local files.
I 've encountered a lot of problems when I recently helped my colleagues configure the NFS service. record that the system is Red Hat Linux 9.
◆ Start the NFS service
Service nfs start
In the same way, restart and close means replace start with restart and stop.
◆ Configure the/etc/exports file
This configuration file determines which files are allowed to be exported through the network. The format is "path permission". An example is as follows:
/Tmp/test * (rw, async)
This means that the/tmp/test directory is shared. All Users have the right to access and can read and write data and transmit data asynchronously. all users are defined by *. You can also use IP addresses, IP addresses/num, and machine names.
Note: In some books, brackets can be directly added after the path name and their permissions can be defined. According to the actual test, no error is prompted in this case, however, the system prompts that the permission is insufficient during mounting, Which is depressing. therefore, for the sake of security, do not add brackets behind the path to define permissions.
◆ Export now
Run the following command:
Exportfs-rv
This will immediately process the file/etc/exports and export its content to the NFS server. this is also a good way to check the Configuration File Syntax. some outdated definitions will be prompted in this operation.
◆ View the exported NFS folder on a computer
Showmount-e IP
In this way, you can see the list exported by the other party.
◆ Mount and use
For the directory exported in the example above, and I want to mount it to the/mnt/temp folder, run the following command:
Mount-t nfs IP:/tmp/test/mnt/temp
Generally, the execution is successful. If the execution fails, it is generally a permission problem.
◆ Permission issues
Network services defined on UNIX operating systems have two levels of permission settings. One is the file system level permission settings, and the other is the network service custom permission settings. the NFS shared resource we Just configured has ensured that its Network Service permission settings are correct. Below we define its file system permissions:
Chown nfsnobody: nfsnobody/tmp/test
In this way, the ownership of the folder/tmp/test and all groups are changed to nfsnobody. This user is the default user of the NFS service and can ensure convenient permission settings.
◆ Uninstall
It is a little simple for everyone, but for beginners, let's just talk about it. simply execute the umount operation on the mounted directory, as shown below:
Umount/mnt/temp
This completes the uninstallation of Mounted Directories.