Install and Configure NFS in CentOS 6.4

Source: Internet
Author: User

Install and Configure NFS in CentOS 6.4
0. environment Description: nfs server system: CentOS 6.4 x86_64nfs Server IP: 192.168.4.211nfs Client System: CentOS 6.4 x86_64nfs Client IP: 192.168.4.212 1. install NFS server (192.168.4.211) Step-1: Install nfs-utils and rpcbind. Run the following command:

Yum install-y nfs-utils rpcbind

The above command will install the rpcbind service and nfs service.
Step 2: specify a fixed port for NFS and run the following command:
Vi/etc/sysconfig/nfs

Search for and set the following port configurations:
RQUOTAD_PORT = 30001
LOCKD_TCPPORT = 30002
LOCKD_UDPPORT = 30002
MOUNTD_PORT = 30003
STATD_PORT = 30004
Step 3: Open the above port in the firewall and run the following command:
Iptables-I input-p tcp -- dport 111-j ACCEPTiptables-I input-p udp -- dport 111-j ACCEPTiptables-I input-p tcp -- dport 2049-j ACCEPTiptables-I INPUT -p udp -- dport 2049-j ACCEPTiptables-I INPUT-p tcp -- dport 30001: 30004-j ACCEPTiptables-I INPUT-p udp -- dport 30001: 30004-j ACCEPTservice iptables saveservice iptables restart
Step-4: Set SELinux to the license status and run the following command:
Vi/etc/selinux/config

Replace
SELINUX = enforcing
Replace
SELINUX = permissive

After saving the preceding file, run the following command:
Setenforce 0
Step 5: create a shared directory and run the following command:
Mkdir-p/data/nfs_share

The above command will create a shared directory/data/nfs_share.
Step-6: configure the exports file and run the following command:
Vi/etc/exports

Add a line at the end of the above file, as shown below:
/Data/nfs_share 192.168.4.212 (rw, sync, no_root_squash)
/Data/nfs_share * (ro)

This line indicates that only the client 192.168.4.212 can mount the shared directory with the read/write permission. Other clients can only mount the shared directory with the read-only permission.
Step-7: Start NFS-related services and run the following command:
Chkconfig nfs on
Chkconfig rpcbind on
Service nfs start
Service rpcbind start
Step-8: Check whether the NFS port is enabled. Run the following command:
Service iptables status
Rpcinfo-p localhost
2. Install the NFS client (192.168.4.212). The NFS client does not need to start the NFS service, but needs to install nfs-utils. Run the following command:
Yum install-y nfs-utils
3. Manually mount the NFS shared directory Step-1: Determine the mount point and run the following command:
Showmount-e 192.168.4.211

-E Option displays the exported list of NFS servers.
Step 2: Create a mount directory and run the following command:
Mkdir-p/root/remote_dir

/Root/remote_dir is the mount point directory of the shared directory.
Step-3: mount the shared directory and run the following command:
Mount-t nfs 192.168.4.211:/data/nfs_share/root/remote_dir

The-t option specifies that the file system type is nfs.
Step 4: After the shared directory is used up, uninstall the shared directory and run the following command:
Umount/root/remote_dir
4. Add a shared directory Mount entry to the fstab file to enable automatic mounting upon startup. However, the connection to the NFS server will remain active. Run the following command:
Mkdir-p/root/remote_dir
Vi/etc/fstab

Add a mount entry to the shared directory at the end of the above file, as shown below:
192.168.4.211:/data/nfs_share/root/remote_dir nfs defaults 0 0

The value 0 indicates that the file system in the shared directory does not need to use the dump command for dump, the value 0 indicates that the file system in the shared directory does not need to use The fsck command for checking.
In addition, you can also use the automatic mounting tool (autofs) to automatically mount the network shared directory as needed. When the shared file is no longer in use and is not active for a certain period of time, the auto-mounting device unmounts the shared file. 5. On-demand automatic mounting (Special ing) when the autofs service is running, a special directory named/net exists in the system, but the directory will be blank. The NFS client automatically mounts the shared directory as needed through special ing as follows: Step-1: Modify the time-out period of the inactive state, and run the following command:
Vi/etc/sysconfig/autofs

Replace
TIMEOUT = 300
Replace
TIMEOUT = 600
That is, the time-out period of the inactive state is changed from 5 minutes to 10 minutes.

After the configuration is complete, restart the autofs service:
Service autofs restart
Step 2: Access the shared network directory and run the following command:
Cd/net/192.168.4.211/data/nfs_share

When running the preceding command, autofs automatically mounts the network shared directory on the NFS server.
Step-3: unmount the mounted shared network directory. The details are as follows:
Autofs unmounts the shared directory after all files and directories under/net/192.168.4.211/data/nfs_share are out of use and expire (10 minutes.
6. automatically mount (indirect ing) as needed Step-1: Modify the time-out period of the inactive state and run the following command:
Vi/etc/sysconfig/autofs

Replace
TIMEOUT = 300
Replace
TIMEOUT = 600
That is, the time-out period of the inactive state is changed from 5 minutes to 10 minutes.
Step 2: Create the parent directory of the shared directory mount point and run the following command:
Mkdir-p/root/demo
Step-3: configure the parent directory of the shared directory mount point and run the following command:
Vi/etc/auto. master

The content of the preceding file is as follows:
/Root/demo/etc/auto. demo

Here,/root/demo is the parent directory of the mount point, which is always visible in the system and monitored by the autofs service to determine whether to "need" Mount/create a subdirectory mount point. /Etc/auto. demo is a single configuration file that contains a list of sub-directory mount points managed by the autofs service in this parent directory.
Step 4: configure the shared directory mount point directory and run the following command:
Vi/etc/auto. demo

The content of the preceding file is as follows:
Remote_dir-rw 192.168.4.211:/data/nfs_share

Among them, remote_dir is a subdirectory mount point, which is usually invisible. it is visible only when the autofs service creates this directory and mounts the shared directory and directly names/accesses it. -Rw is the mount option used when the Mount network is shared. 192.168.4.211:/data/nfs_share is the NFS server and shared directory to be mounted.
Step 5: restart the autofs service and run the following command:
Service autofs restart
Step 6: Access the shared network directory and run the following command:
Cd/root/demo/remote_dir

After running the preceding command, autofs automatically creates a mount point directory and mounts the shared directory.
Step-7: unmount the network shared directory. The details are as follows:
Autofs unmounts the shared directory after all files and directories under/root/demo/remote_dir are out of use and expire (10 minutes.

-------------------------------------- Split line --------------------------------------

Install NFS server in Ubuntu 12.04

Install and configure the NFS server to share the Ubuntu 12.04 and ARM files.

Build an nfs server in Ubuntu

File Server NFS configuration details

Build an NFS Network File System server in Ubuntu

Heartbeat_ldirector + LB + NFS for HA, LB, and file sharing

How to Configure NFS server in CentOS 5.5

Install and use NFS in Ubuntu 12.10

-------------------------------------- Split line --------------------------------------

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.