In many systems, NFS is required. So how do I add an NFS platform to some non-production and development systems? Here we will explain how to create a CentOS NFS server. Hope to help you. How to build an NFS platform in CentOS:
1. First in the VM to download a CentOS as the NFS server nfs-server.example.com), and then clone a as NFS client nfs-client.example.com), MINI installation.
The NFS server allocates the IP address 192.168.1.100 and the NFS client assigns the IP address 192.168.1.200.
Nfs-server.example.com configuration is as follows:
[Root @ nfs-server ~] # Cat/etc/sysconfig/network
NETWORKING = yes
HOSTNAME = nfs-server.example.com [root @ nfs-server ~] # Cat/etc/hosts
# Do not remove the following line, or various programs
# That require network functionality will fail.
127.0.0.1 localhost. localdomain localhost
192.168.1.200 nfs-client.example.com nfs-client
Nfs-client.example.com configuration is as follows:
[Root @ nfs-client ~] # Cat/etc/sysconfig/network
NETWORKING = yes
HOSTNAME = nfs-client.example.com [root @ nfs-client ~] # Cat/etc/hosts
# Do not remove the following line, or various programs
# That require network functionality will fail.
127.0.0.1 localhost. localdomain localhost
192.168.1.100 nfs-server.example.com nfs-server2, configuring NFS server nfs-server.example.com)
The NFS service is installed by default, so you only need to enable the server.
[Root @ nfs-server ~] # Chkconfig nfs on for example, to share/data/directory:
[Root @ nfs-server ~] # Mkdir/data
[Root @ nfs-server ~] # Vi/etc/exports
/Data/192.168.1.200 (rw, no_root_squash, no_all_squash, sync) Now you can start the NFS service.
[Root @ nfs-server ~] # Service nfs start3, configure the NFS client nfs-client.example.com)
Test the NFS server.
[Root @ nfs-client ~] # Showmount-e nfs-server
Export list for share:
/Data 192.168.1.200 if the above information is not displayed, it indicates that the NFS server has not been correctly configured. Generally, the IP settings are incorrect.
MOUNT shared directory/data:
[Root @ nfs-client ~] # Mkdir/data
[Root @ nfs-client ~] # Mount-t nfs 192.168.1.100:/data then test whether the shared directory/data can be read and written:
[Root @ nfs-client ~] # Echo "hello world">/data/test. Then, run the NFS server to check whether the/data/test file exists :)?
If you want to automatically mount the shared directory when the NFS client is turned on, you only need to modify/etc/fstab and add the following sentence:
192.168.1.100:/data nfs rw 0 04. troubleshooting reference
When the permission set by/etc/exports does not comply with the client source, the following error message is displayed:
Mount: hostname:/dir failed, reason given by server: Permission denied
However, it must be noted that if the IP address and hostname are set in/etc/hosts of the nfs server
Nfs first converts the source IP address to the hostname, and then compares it with the settings in/etc/exports.
If the/etc/exports setting uses an IP address instead of a hostname? Method matching error
? In this case, although the source IP address has been correctly set in/etc/exports, the Permission denied still occurs.
The solution is to use hostname in/etc/exports to avoid IP addresses or set correct IP segments.
Source: http://www.sofee.cn/blog/2006/09/29/46/