网络环境:
一台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程序是否安装
2:启动服务并设为开机启动
Box-sizing: border-Box;"># service nfs start</span> [root<span class="hljs-variable" style="padding: 0px; margin: 0px; color: rgb(102,0); Box-sizing: border-Box;"># service rpcbind start</span> [root<span class="hljs-variable" style="padding: 0px; margin: 0px; color: rgb(102,0); Box-sizing: border-Box;"># chkconfig rpcbind on</span> [root<span class="hljs-variable" style="padding: 0px; margin: 0px; color: rgb(102,0); Box-sizing: border-Box;"># chkconfig nfs on</span></code>
3:开启相应端口
<code class="hljs lasso has-numbering" style="padding: 0px; margin: 0px; display: block; color: inherit; Box-sizing: border-Box; font-family: 'Source Code Pro',monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">iptables <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-I</span> INPUT <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-p</span> tcp <span class="hljs-subst" style="padding: 0px; margin: 0px; color: rgb(0,0); Box-sizing: border-Box;">--</span>dport <span class="hljs-number" style="padding: 0px; margin: 0px; color: rgb(0,102); Box-sizing: border-Box;">111</span> <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-j</span> ACCEPT iptables <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-I</span> INPUT <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-p</span> udp <span class="hljs-subst" style="padding: 0px; margin: 0px; color: rgb(0,102); Box-sizing: border-Box;">111</span> <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-j</span> ACCEPT iptables <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-I</span> INPUT <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-p</span> tcp <span class="hljs-subst" style="padding: 0px; margin: 0px; color: rgb(0,102); Box-sizing: border-Box;">2049</span> <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-j</span> ACCEPT iptables <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-I</span> INPUT <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-p</span> udp <span class="hljs-subst" style="padding: 0px; margin: 0px; color: rgb(0,102); Box-sizing: border-Box;">2049</span> <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-j</span> ACCEPT iptables <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-I</span> INPUT <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-p</span> tcp <span class="hljs-subst" style="padding: 0px; margin: 0px; color: rgb(0,102); Box-sizing: border-Box;">30001</span>:<span class="hljs-number" style="padding: 0px; margin: 0px; color: rgb(0,102); Box-sizing: border-Box;">30004</span> <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-j</span> ACCEPT iptables <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-I</span> INPUT <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-p</span> udp <span class="hljs-subst" style="padding: 0px; margin: 0px; color: rgb(0,102); Box-sizing: border-Box;">30004</span> <span class="hljs-attribute" style="padding: 0px; margin: 0px; Box-sizing: border-Box;">-j</span> ACCEPT service iptables save service iptables restart</code>
4:编辑配置文件实现需求1,2要求
<code class="hljs cs has-numbering" style="padding: 0px; margin: 0px; display: block; color: inherit; Box-sizing: border-Box; font-family: 'Source Code Pro',monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">[root@server ~]<span class="hljs-preprocessor" style="padding: 0px; margin: 0px; color: rgb(68,68,68); Box-sizing: border-Box;"># vim /etc/exports</span> /root <span class="hljs-number" style="padding: 0px; margin: 0px; color: rgb(0,102); Box-sizing: border-Box;">192.168</span><span class="hljs-number" style="padding: 0px; margin: 0px; color: rgb(0,102); Box-sizing: border-Box;">.93</span><span class="hljs-number" style="padding: 0px; margin: 0px; color: rgb(0,102); Box-sizing: border-Box;">.129</span>(rw,sync,no_root_squash) /<span class="hljs-keyword" style="padding: 0px; margin: 0px; color: rgb(0,136); Box-sizing: border-Box;">var</span>/www/html <span class="hljs-number" style="padding: 0px; margin: 0px; color: rgb(0,102); Box-sizing: border-Box;">.0</span>/<span class="hljs-number" style="padding: 0px; margin: 0px; color: rgb(0,102); Box-sizing: border-Box;">24</span>(rw,<span class="hljs-keyword" style="padding: 0px; margin: 0px; color: rgb(0,136); Box-sizing: border-Box;">async</span>)</code>
5:重启服务
Box-sizing: border-Box;"># service nfs restart</span> [root<span class="hljs-variable" style="padding: 0px; margin: 0px; color: rgb(102,0); Box-sizing: border-Box;"># service rpcbind restart</span></code>
6:服务器端设置/var/www/html本地写权限
Box-sizing: border-Box;"># chmod o+w /var/www/html</span></code>
7:客户机测试
Box-sizing: border-Box;">@client</span> ~]<span class="hljs-comment" style="padding: 0px; margin: 0px; color: rgb(136,0); Box-sizing: border-Box;"># mkdir -p /data/root</span> [root<span class="hljs-variable" style="padding: 0px; margin: 0px; color: rgb(102,0); Box-sizing: border-Box;"># mount 192.168.93.128:/root /data/root/</span> [root<span class="hljs-variable" style="padding: 0px; margin: 0px; color: rgb(102,0); Box-sizing: border-Box;"># mkdir -p /var/www/html_client</span> [root<span class="hljs-variable" style="padding: 0px; margin: 0px; color: rgb(102,0); Box-sizing: border-Box;"># mount 192.168.93.128:/var/www/html /var/www/html_client</span> [root<span class="hljs-variable" style="padding: 0px; margin: 0px; color: rgb(102,0); Box-sizing: border-Box;"># mount |tail -2</span></code>原文链接:https://www.f2er.com/centos/381134.html