网络环境:
一台Linux server ip 192.168.1.254,一台Linux client ip 192.168.1.100
操作系统:CentOS 6.5
需求描述:
1:将/root 共享给192.168.93.129,可写、同步,允许客户机以root权限访问
2:将/var/www/html 共享给192.168.93.0/24网段,可写、异步
步骤:
1:查看nfs程序是否安装
- [root@server ~]# rpm -qa |grep nfs 查看nfs是否安装
- nfs-utils-1.2.3-39.el6.i686
- [root@server ~]# rpm -qa |grep rpcbind 查看RPC是否安装
- rpcbind-0.2.0-11.el6.i686
复制代码
2:启动服务并设为开机启动
- [root@server ~]# service nfs start
- [root@server ~]# service rpcbind start
- [root@server ~]# chkconfig rpcbind on
- [root@server ~]# chkconfig nfs on
复制代码
3:开启相应端口
- iptables -I INPUT -p tcp --dport 111 -j ACCEPT
- iptables -I INPUT -p udp --dport 111 -j ACCEPT
- iptables -I INPUT -p tcp --dport 2049 -j ACCEPT
- iptables -I INPUT -p udp --dport 2049 -j ACCEPT
- iptables -I INPUT -p tcp --dport 30001:30004 -j ACCEPT
- iptables -I INPUT -p udp --dport 30001:30004 -j ACCEPT
- service iptables save
- service iptables restart
复制代码
4:编辑配置文件实现需求1,2要求
- [root@server ~]# vim /etc/exports
- /root 192.168.93.129(rw,sync,no_root_squash)
- /var/www/html 192.168.93.0/24(rw,async)
复制代码
5:重启服务
- [code][root@server ~]# service nfs restart
- [root@server ~]# service rpcbind restart
复制代码 [/code]
6:服务器端设置/var/www/html本地写权限
[root@server ~]# chmod o+w /var/www/html
7:客户机测试
- [root@client ~]# mkdir -p /data/root
- [root@client ~]# mount 192.168.93.128:/root /data/root/
- [root@client ~]# mkdir -p /var/www/html_client
- [root@client ~]# mount 192.168.93.128:/var/www/html /var/www/html_client
- [root@client ~]# mount |tail -2
复制代码
|