{"id":383,"date":"2016-10-26T14:58:13","date_gmt":"2016-10-26T06:58:13","guid":{"rendered":"https:\/\/yyshell.com\/?p=383"},"modified":"2016-10-26T14:58:13","modified_gmt":"2016-10-26T06:58:13","slug":"centos6ubuntu-16-04%e5%ae%89%e8%a3%85%e3%80%81%e4%bd%bf%e7%94%a8nis%ef%bc%8cnfs%ef%bc%8cautofs%e6%95%99%e7%a8%8b%ef%bc%882%ef%bc%89","status":"publish","type":"post","link":"https:\/\/yyshell.com\/?p=383","title":{"rendered":"CentOS6,Ubuntu 16.04\u5b89\u88c5\u3001\u4f7f\u7528NIS\uff0cNFS\uff0cAutoFS\u6559\u7a0b\uff082\uff09"},"content":{"rendered":"<p>\u672c\u7bc7\uff0c\u6211\u4eec\u5c06\u8bb2\u89e3\u7528CentOS6\u4f5c\u4e3a\u5ba2\u6237\u7aef\uff0c\u8fde\u63a5\u6211\u4eec\u4e0a\u7bc7\u642d\u5efa\u7684nis\u548cnfs\u670d\u52a1\u7aef\uff0c\u6211\u4eec\u7684\u5ba2\u6237\u7aefip\u662f192.168.42.102\uff0chostname\u5c31\u53ebclient\u3002<\/p>\n<h3>\u5b89\u88c5NFS<\/h3>\n<pre class=\"lang:sh decode:true \">[root@client ~]# yum -y install nfs-utils<\/pre>\n<p>\u542f\u52a8\u76f8\u5173\u670d\u52a1\uff0c\u5e76\u8bbe\u7f6e\u4e3a\u5f00\u673a\u542f\u52a8<\/p>\n<pre class=\"lang:sh decode:true \">[root@client ~]# service rpcbind start\r\nStarting rpcbind:                                          [  OK  ]\r\n[root@client ~]# service netfs start\r\nMounting filesystems:                                      [  OK  ]\r\n[root@client ~]# chkconfig rpcbind on\r\n[root@client ~]# chkconfig netfs on<\/pre>\n<h3>\u5b89\u88c5Autofs<\/h3>\n<pre class=\"lang:sh decode:true \">[root@client ~]# yum -y install autofs<\/pre>\n<p>\u914d\u7f6e\u81ea\u52a8\u6302\u8f7d\u8bbe\u7f6e<\/p>\n<pre class=\"lang:sh decode:true\">[root@client ~]# echo -e \"\/home\\t\/etc\/auto.home\" &gt;&gt; \/etc\/auto.master\r\n[root@client ~]# echo -e \"*\\t192.168.42.101:\/home\/&amp;\" &gt;&gt; \/etc\/auto.home<\/pre>\n<p>\u6ce8\u610f\uff0cauto.home\u6587\u4ef6\u4e2d\u95f4\u53ef\u4ee5\u6dfb\u52a0nfs\u4e00\u4e9b\u6302\u8f7d\u9009\u9879\uff0c\u672c\u6587\u76f4\u63a5\u7528\u9ed8\u8ba4\u9009\u9879\uff0c\u6545\u6ca1\u6709\u6dfb\u52a0\u989d\u5916\u5185\u5bb9\u3002<\/p>\n<p>\u542f\u52a8\u670d\u52a1\uff0c\u5e76\u52a0\u5165\u5f00\u673a\u81ea\u542f\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@client ~]# chkconfig autofs on\r\n[root@client ~]# service autofs start<\/pre>\n<h3>\u5b89\u88c5NIS\u5ba2\u6237\u7aef<\/h3>\n<pre class=\"lang:sh decode:true \">[root@client ~]# yum -y install ypbind<\/pre>\n<p>\u4e34\u65f6\u6307\u5b9anis\u57df\u540d\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@client ~]# ypdomainname yyshell.com<\/pre>\n<p>\u6c38\u4e45\u751f\u6548\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@client ~]# echo \"NISDOMAIN=yyshell.com\" &gt;&gt; \/etc\/sysconfig\/network<\/pre>\n<p>\u914d\u7f6e\u4e00\u4e0b\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@client ~]# authconfig --enablenis \\\r\n&gt; --nisdomain=yyshell.com \\\r\n&gt; --nisserver=192.168.42.101 \\\r\n&gt; --enablemkhomedir \\\r\n&gt; --update<\/pre>\n<p>\u56e0\u4e3a\u672c\u6b21\u6211\u4eec\u662f\u901a\u8fc7autofs\u6302\u8f7dhome\u76ee\u5f55\uff0c\u5176\u5b9e\u672c\u6b21\u6211\u4eec\u6ca1\u6709\u5fc5\u8981\u4f7f\u7528&#8211;enablemkhomedir\u9009\u9879\u7684\uff0c\u8fd9\u4e2a\u9009\u9879\u4e3b\u8981\u662f\u7ed9\u672c\u5730\u7684nis\u7528\u6237\u4f7f\u7528\u7684\uff0c\u6211\u4eec\u8fd9\u91cc\u52a0\u4e0a\u4e5f\u65e0\u59a8\u3002<\/p>\n<p>\u4e0a\u9762\u7684\u914d\u7f6e\u4f1a\u81ea\u52a8\u542f\u52a8ypbind\u670d\u52a1\uff0c\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u53ea\u9700\u8981\u628a\u8fd9\u4e2a\u52a0\u5165\u5f00\u673a\u542f\u52a8\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<pre class=\"lang:sh decode:true \">[root@client ~]# chkconfig ypbind on<\/pre>\n<h3>\u5b89\u5168\u8bbe\u5b9a<\/h3>\n<p>\u6307\u5b9aypbind\u7aef\u53e3\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@client ~]# vim \/etc\/init.d\/ypbind<\/pre>\n<p>\u7b2c18\u884c\uff0c\u628aOTHER_YPBIND_OPTS=&#8221;&#8221;\u4fee\u6539\u6210\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">OTHER_YPBIND_OPTS=\"-p 666\"<\/pre>\n<p>\u628aNFS\u76f8\u5173\u7684\u7aef\u53e3\u4e5f\u6307\u5b9a\u4e0b\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@client ~]# vim \/etc\/sysconfig\/nfs<\/pre>\n<p>20\u548c22\u884c\u5206\u522b\u53d6\u6d88\u6ce8\u91ca\uff1a<br \/>\nLOCKD_TCPPORT=32803<br \/>\nLOCKD_UDPPORT=32769<br \/>\n57\u884c\u53d6\u6d88\u6ce8\u91ca\uff1a<br \/>\nMOUNTD_PORT=892<br \/>\n63\u884c\u53d6\u6d88\u6ce8\u91ca\uff1a<br \/>\nSTATD_PORT=662<\/p>\n<p>\u63a5\u4e0b\u6765\u5c31\u662f\u5f00\u653e\u9632\u706b\u5899\uff1a<\/p>\n<pre class=\"lang:sh decode:true\">[root@client ~]# iptables -I INPUT -m multiport -p tcp --dport 111,662,666 -j ACCEPT\r\n[root@client ~]# iptables -I INPUT -m multiport -p udp --dport 111,662,666 -j ACCEPT\r\n[root@client ~]# service iptables save\r\niptables: Saving firewall rules to \/etc\/sysconfig\/iptables:[  OK  ]\r\n[root@client ~]# service iptables restart\r\niptables: Setting chains to policy ACCEPT: filter          [  OK  ]\r\niptables: Flushing firewall rules:                         [  OK  ]\r\niptables: Unloading modules:                               [  OK  ]\r\niptables: Applying firewall rules:                         [  OK  ]<\/pre>\n<p>\u5229\u7528tcp_wrapper\u9650\u5236rpc\u8bbf\u95ee\u5730\u5740\uff1a<br \/>\nvim \/etc\/hosts.deny<\/p>\n<pre class=\"lang:sh decode:true \">rpcbind: ALL<\/pre>\n<p>vim \/etc\/hosts.allow<\/p>\n<pre class=\"lang:sh decode:true\">rpcbind: 127. 192.168.42.101<\/pre>\n<h3>NIS\u7528\u6237\u6302\u8f7d\u6d4b\u8bd5<\/h3>\n<p>\u6211\u4eec\u73b0\u5728server\u7684\u673a\u5668\u4e0a\u6dfb\u52a0\u7528\u6237alice\u6d4b\u8bd5\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@server ~]# useradd alice\r\n[root@server ~]# passwd alice<\/pre>\n<p>\u66f4\u65b0\u4e0bnis\u6570\u636e\u5e93\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@server ~]# cd \/var\/yp\r\n[root@server yp]# make<\/pre>\n<p>\u6211\u4eec\u5148\u5728client\u7684\u673a\u5668\u4e0a\u770b\u4e0b\u80fd\u5426\u83b7\u53d6alice\u7528\u6237\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[root@client ~]# getent passwd<\/pre>\n<p>\u663e\u793a\u8fd9\u4e9b\u5185\u5bb9\uff1a<\/p>\n<blockquote><p>root:x:0:0:root:\/root:\/bin\/bash<br \/>\n&#8230;\u7701\u7565\u82e5\u5e72\u884c&#8230;<br \/>\nrpc:x:32:32:Rpcbind Daemon:\/var\/cache\/rpcbind:\/sbin\/nologin<br \/>\nrpcuser:x:29:29:RPC Service User:\/var\/lib\/nfs:\/sbin\/nologin<br \/>\nnfsnobody:x:65534:65534:Anonymous NFS User:\/var\/lib\/nfs:\/sbin\/nologin<br \/>\nalice:x:500:500::\/home\/alice:\/bin\/bash<\/p><\/blockquote>\n<p>\u63a5\u4e0b\u6765\u7528alice\u7528\u6237\u767b\u5f55:<\/p>\n<pre class=\"lang:sh decode:true \">[alice@client ~]$ whoami\r\nalice\r\n[alice@client ~]$ pwd\r\n\/home\/alice\r\n<\/pre>\n<p>\u663e\u793a\u767b\u5f55\u6210\u529f\u3002\u518d\u67e5\u770b\u4e0bhome\u76ee\u5f55\u6743\u9650\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">[alice@client home]$ ll\r\ntotal 4\r\ndrwx------. 2 alice alice 4096 Oct 26 22:53 alice<\/pre>\n<p>\u6743\u9650\u4e5f\u6ca1\u6709\u95ee\u9898\uff0c\u8bf4\u660enfsidmap\u4e5f\u6210\u6548\u4e86\u3002<\/p>\n<div id=\"icibaCirclePointer\" style=\"position: absolute; top: 481px; left: -171px;\"><\/div>\n<div id=\"icibaCirclePointer\" style=\"position: absolute; top: 720px; left: -1px;\"><\/div>\n<div id=\"icibaCirclePointer\" style=\"position: absolute; top: 1376px; left: -12px;\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u7bc7\uff0c\u6211\u4eec\u5c06\u8bb2\u89e3\u7528CentOS6\u4f5c\u4e3a\u5ba2\u6237\u7aef\uff0c\u8fde\u63a5\u6211\u4eec\u4e0a\u7bc7\u642d\u5efa\u7684nis\u548cnfs\u670d\u52a1<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,8,12,7],"tags":[49,45,51,50,48,53],"class_list":["post-383","post","type-post","status-publish","format-standard","hentry","category-linux","category-web","category-12","category-7","tag-autofs","tag-centos6","tag-iptables","tag-nfs","tag-nis","tag-ubuntu16-04"],"_links":{"self":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=383"}],"version-history":[{"count":2,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/383\/revisions"}],"predecessor-version":[{"id":388,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/383\/revisions\/388"}],"wp:attachment":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}