centos6下安装配置NFS

1、检查NFS和rpcbind包是否已安装

[root@h1 ~]# rpm -qa | grep nfs
nfs-utils-1.2.3-15.el6.x86_64
nfs-utils-lib-1.1.5-4.el6.x86_64
nfs4-acl-tools-0.3.3-5.el6.x86_64
[root@h1 ~]# rpm -qa | grep rpcbind
rpcbind-0.2.0-8.el6.x86_64

2、检查NFS和rpcbind是否启动

[root@h1 ~]# service nfs status
rpc.svcgssd is stopped
rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped
[root@h1 ~]# service rpcbind status
rpcbind (pid  1187) is running...

nfs已经停止

3、启动服务

[root@h1 ~]# service nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]

设置开机启动

[root@h1 ~]# chkconfig nfs on
[root@h1 ~]# chkconfig rpcbind on

4、设置/home/grid为共享目录

[root@h1 ~]# vim /etc/exports
[root@h1 ~]# cat /etc/exports
/home/grid *(sync,rw)

5、重启服务(已关闭防火墙)

[root@h1 ~]# service rpcbind restart
Stopping rpcbind:                                          [  OK  ]
Starting rpcbind:                                          [  OK  ]
[root@h1 ~]# service nfs restart
Shutting down NFS mountd:                                  [  OK  ]
Shutting down NFS daemon:                                  [  OK  ]
Shutting down NFS quotas:                                  [  OK  ]
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]

6、输出本地挂载点

[root@h1 ~]# showmount -e localhost
Export list for localhost:
/home/grid *

7、客户端h2配置

[root@h2 ~]# mkdir /nfs_share
[root@h2 ~]# mount -t nfs 192.168.137.2:/home/grid /nfs_share
[root@h2 ~]# su grid
[grid@h2 root]$ cd /nfs_share

8、设置开机后自动挂载nfs目录

[root@h2 nfs_share]# vi /etc/fstab

9、客户端配置

[root@h2 nfs_share]# su grid
[grid@h2 nfs_share]$ cd .ssh
[grid@h2 .ssh]$ pwd
/nfs_share/.ssh
[grid@h2 .ssh]$ rm -rf /home/grid/.ssh/authorized_keys
[grid@h2 .ssh]$ ln -s /nfs_share/.ssh/authorized_keys ~/.ssh/authorized_keys
[grid@h2 .ssh]$ pwd
/nfs_share/.ssh
[grid@h2 .ssh]$ cd /home/grid/.ssh
[grid@h2 .ssh]$ cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAnow+jCfOBP097tsi95GnQqARrfMdKBcAZFpyZSumTPI2m/ZhDV9utosW5g3aVZtbJDlUdkVndXfKMQyE7Dp27gpHBWFq+NOyIQCRntUUXYtNWU+6lssTcRaLmXOEkkwTiiJt6EhJb5krufDK2JKLo6LmWJvdGFzNShXbvH/qGrbOgM2nctca5yC6pikIJ0tQGM62qwW+m2oBOAidllhSE8jnM5eMwPhJfRcnHHeJI8NRRS2tuxb/eUr/+JKRTICeJVPp/JPXPmGPE9fzOrHchhkd6GlZBXr3WHKsJjhqHdAP/n5Z4p6oMMBFfGZxEyQqi2J3nlqyMS3eGIwkFuxMvw== grid@h1

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq1w0rEWcB89+sRP2nDYAyTh8SjeDeznIzy5CUmN43Q3Z5V9oFo6+xOW518tUK8QtqyuH5OTPpBidGxav1Ic9ug5X6B5zziy3xSfhh58NWyp+7/qXmex+LIZGxnXlHio4AqHimgnA2Dh6czxQb5i9gxnRjA06ha6VPoWz4wJtSVFWky96xGucZDFVN7nCwIB0urnulvggnNJ7U8RKmqBxlDq+BGM3ClIrvG3n+qutYf/3wyNocyPfYE5rgDRM950VX4RN+8YEC0BuAF3295Q+dhQjY1lBbMQh4xHcOhRU41bd4xlCtUclszADa3Mvs581qbkOW7XhfNStLX7nyAYcwQ== grid@h2

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAumv63KKyYD5EQE+1HLQbwpU7sJaB72e3gXDEJ8TlT2MC1j7OqKUbzSw1KVWMpj9W6CnLPwneva4aTNkNH4bRcU3iv+H29cA6g+XOV58a61KkOcgw6JTgIxqLCTAYu9gRg4DYl/cPvYI+OpseoXcRQAvdTaxHNEbys7k/e6zljuQ4GRw6ga9kPtopXO/LYgwakApmHZtCqsaXHJDdFWyTsW4GDQVM1yu5GbikWFVkl5KxX6fM9yrgmqVHocsuUN/IqysMtwi5gYZgypCX4goFo9rFZMN3trKfmlm+PoqE+xlfD4rm4eg3kb0Q7NjCfg8SoSily862aJi7K4bCp4OIkQ== grid@h3
原文地址:https://www.cnblogs.com/melodyluo/p/2986421.html