NFS File Sharing Service
1 protocols
Use 2 RHEL6.4 virtual machines, one as an NFS shared server (192.168.100.1), and another as an NFS client for testing (192.168.100.2)
2. Implement
2.1. Configure the NFS shared server.
1) Install the package and create a shared directory.
[Email protected] ~]# rpm-q rpcbind nfs-utils
Rpcbind-0.2.0-11.el6.x86_64
Nfs-utils-1.2.3-36.el6.x86_64
[Email protected] ~]# mkdir/nfstest
[[email protected] ~]# echo "Test file" >/nfstest/nfs.txt//Create test file
[[email protected] ~]# ls-ld/nfstest//View Test directory Permissions
Drwxr-xr-x. 2 root root 4096 Apr 07:18/nfstest
2) Modify the NFS Master Profile/etc/exports to add/nfstest sharing settings.
[Email protected] ~]# Vim/etc/exports
[Email protected] ~]# Cat/etc/exports
/nfstest 192.168.100.2 (Rw,sync,no_root_squash)//set to only read and write permissions to 192.168.100.2 users and synchronize to memory and hard disk, open client uses root identity
3) Enable the NFS-related service program.
After the Rpcbind and NFS services have started successfully, execute showmount-e to view a list of the currently published shared resources for this computer:
[[Email protected] ~]# service Rpcbind start
[[Email protected] ~]# Service NFS Start
[[email protected] ~]# chkconfig rpcbind on//Set Boot start service
[[email protected] ~]# chkconfig NFS on
[[email protected] ~]# chkconfig--list rpcbind//Ensure service boot up
Rpcbind 0:off1:off2:on3:on4:on5:on6:off
[[email protected] ~]# Chkconfig--list NFS
NFS 0:off1:off2:on3:on4:on5:on6:off
[[email protected] ~]# showmount-e localhost//view native Publishing shared resources
Export list for localhost:
/nfstest 192.168.100.2
2.2 Use the NFS client to view and access the/nfstest share.
1) The client also needs to install the appropriate software
[Email protected] ~]# rpm-q rpcbind nfs-utils
Rpcbind-0.2.0-11.el6.x86_64
Nfs-utils-1.2.3-36.el6.x86_64
2) View the List of NFS shared resources for the server from the client.
The client must have the Nfs-utils package installed in order to view the NFS resources using the Showmount command:
[Email protected] ~]# showmount-e 192.168.100.1
Export list for 192.168.100.1:
/nfstest 192.168.100.2
3) Mount the/nfstest share from the client 192.168.100.2 and test read and write permissions.
[[email protected] ~]# Mount 192.168.100.1:/NFSTEST/MNT//mount the shared directory to the local MNT directory
[Email protected] ~]# cd/mnt; Ls
Nfs.txt
[[Email protected] mnt]# CD
[Email protected] ~]# Cd/mnt;ls
Nfs.txt
[[email protected] mnt]# Touch aa.txt//Test Write permission
[email protected] mnt]# LL
Total 4
-rw-r--r--. 1 root root 0 Apr 07:40 aa.txt
-rw-r--r--. 1 root root Apr 07:18 nfs.txt
4) Set the NFS shared resources to be mounted automatically after booting.
[Email protected] ~]# Vim/etc/fstab
192.168.100.1:/nfstest/mnt NFS Defaults 0 0//File type NFS
[Email protected] ~]# umount/mnt
[Email protected] ~]# mount-a
[email protected] ~]# Mount | Tail-n 1
192.168.100.1:/NFSTESTON/MNT type NFS (rw,vers=4,addr=192.168.100.1,clientaddr=192.168.100.2)//boot Auto Mount successful
http://jinjianjun.blog.51cto.com/8539251/1395621
RHEL6.4 NFS File Sharing service Setup