电脑疯子技术论坛|电脑极客社区

微信扫一扫 分享朋友圈

已有 1941 人浏览分享

CentOS 6.x 实现NFS共享

[复制链接]
1941 0

网络环境:

一台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程序是否安装

  1. [root@server ~]# rpm -qa |grep nfs 查看nfs是否安装
  2. nfs-utils-1.2.3-39.el6.i686
  3. [root@server ~]# rpm -qa |grep rpcbind 查看RPC是否安装
  4. rpcbind-0.2.0-11.el6.i686
复制代码


2:启动服务并设为开机启动

  1. [root@server ~]# service nfs start
  2. [root@server ~]# service rpcbind start
  3. [root@server ~]# chkconfig rpcbind on
  4. [root@server ~]# chkconfig nfs on
复制代码


3:开启相应端口

  1. iptables  -I INPUT -p tcp --dport 111 -j ACCEPT
  2. iptables  -I INPUT -p udp --dport 111 -j ACCEPT
  3. iptables  -I INPUT -p tcp --dport 2049 -j ACCEPT
  4. iptables  -I INPUT -p udp --dport 2049 -j ACCEPT
  5. iptables  -I INPUT -p tcp --dport 30001:30004 -j ACCEPT
  6. iptables  -I INPUT -p udp --dport 30001:30004 -j ACCEPT
  7. service iptables save
  8. service iptables restart
复制代码


4:编辑配置文件实现需求1,2要求

  1. [root@server ~]# vim /etc/exports
  2. /root 192.168.93.129(rw,sync,no_root_squash)
  3. /var/www/html 192.168.93.0/24(rw,async)
复制代码


5:重启服务

  1. [code][root@server ~]# service nfs restart
  2. [root@server ~]# service rpcbind restart
复制代码
[/code]

6:服务器端设置/var/www/html本地写权限

[root@server ~]# chmod o+w /var/www/html

7:客户机测试

  1. [root@client ~]# mkdir -p /data/root
  2. [root@client ~]# mount 192.168.93.128:/root /data/root/
  3. [root@client ~]# mkdir -p /var/www/html_client
  4. [root@client ~]# mount 192.168.93.128:/var/www/html /var/www/html_client
  5. [root@client ~]# mount |tail -2
复制代码



您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

关注

0

粉丝

9021

主题
精彩推荐
热门资讯
网友晒图
图文推荐

Powered by Pcgho! X3.4

© 2008-2022 Pcgho Inc.