将/root 共享给主机192.168.10.20 可写、同步,允许客户机以root权限访问


一、查看有没有安装软件包


[root@localhost ~]# rpm -q nfs-utils portmap

nfs-utils-1.0.9-66.el5

portmap-4.0-65.2.2.1


二、修改配置文件

[root@localhost ~]# cat /etc/exports

/root 192.168.10.20(rw,sync,no_root_squash)


三、启动服务


[root@localhost ~]# service portmap restart

停止 portmap:                                             [确定]

启动 portmap:                                             [确定]


[root@localhost ~]# service nfs restart

关闭 NFS mountd:                                          [确定]

关闭 NFS 守护进程:                                        [确定]

关闭 NFS quotas:                                          [确定]

关闭 NFS 服务:                                            [确定]

启动 NFS 服务:                                            [确定]

关掉 NFS 配额:                                            [确定]

启动 NFS 守护进程:                                        [确定]

启动 NFS mountd:                                          [确定]

Stopping RPC idmapd:                                       [确定]

正在启动 RPC idmapd:                                      [确定]

[root@localhost ~]# chkconfig portmap on

[root@localhost ~]# chkconfig nfs on


四、客户端测试


[root@localhost ~]# showmount -e 192.168.10.10

Export list for 192.168.10.10:

/root 192.168.10.20

[root@localhost ~]# mkdir -p /nfs/root

[root@localhost ~]# showmount -e 192.168.10.10

Export list for 192.168.10.10:

/root 192.168.10.20

[root@localhost ~]# mount -t nfs 192.168.10.10:/root /nfs/root/

[root@localhost ~]# df -h | grep nfs

192.168.10.10:/root    76G  2.9G   69G   4% /nfs/root

[root@localhost ~]# cd /nfs/root/

[root@localhost root]# touch 1.txt

[root@localhost root]# ls -l 1.txt

-rw-r--r-- 1 root root 0 04-20 13:33 1.txt


五、查看防火墙有没有关闭

关闭防火墙

[root@localhost root]#iptables F

[root@localhost root]#service iptables save

关闭Selinux

[root@localhost root]#vim /etc/sysconfig/selinux

SELINUX=disabled

[root@localhost root]#setenforce 0