{"id":389,"date":"2016-10-27T17:44:40","date_gmt":"2016-10-27T09:44:40","guid":{"rendered":"https:\/\/yyshell.com\/?p=389"},"modified":"2018-02-24T22:11:27","modified_gmt":"2018-02-24T14:11:27","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%883%ef%bc%89","status":"publish","type":"post","link":"https:\/\/yyshell.com\/?p=389","title":{"rendered":"CentOS6,Ubuntu 16.04\u5b89\u88c5\u3001\u4f7f\u7528NIS\uff0cNFS\uff0cAutoFS\u6559\u7a0b\uff083\uff09"},"content":{"rendered":"<p>\u672c\u7bc7\u5c06\u6ce8\u91cd\u4ecb\u7ecdUbuntu 16.04\u670d\u52a1\u5668\u4f5c\u4e3a\u5ba2\u6237\u7aef\u63a5\u5165CentOS6\u7684nis\u548cnfs server\u7684\u8fc7\u7a0b\u3002\u4e3b\u673a\u540d\uff1aubuntu\uff0cIP\uff1a192.168.42.15\uff0c\u672c\u6b21\u64cd\u4f5c\u5168\u90e8\u4f7f\u7528root\u64cd\u4f5c\uff0c\u5982\u679c\u4f60\u4e0d\u662froot\u7528\u6237\uff0c\u5927\u90e8\u5206\u547d\u4ee4\u524d\u9700\u8981\u52a0sudo\u3002<\/p>\n<h3>\u5b89\u88c5NFS\uff08\u4f5c\u4e3a\u5ba2\u6237\u7aef\uff09<\/h3>\n<pre class=\"lang:sh decode:true \">root@ubuntu:~# apt -y install nfs-common<\/pre>\n<h3>\u5b89\u88c5AutoFS<\/h3>\n<pre class=\"lang:sh decode:true \">root@ubuntu:~# apt -y install autofs<\/pre>\n<p>\u914d\u7f6eautofs\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">root@ubuntu:~# echo -e \"\/home\\t\/etc\/auto.home\" &gt;&gt; \/etc\/auto.master<\/pre>\n<pre class=\"lang:sh decode:true \">root@ubuntu:~# echo -e \"*\\t192.168.42.101:\/home\/&amp;\" &gt;&gt; \/etc\/auto.home<\/pre>\n<p>\u91cd\u542f\u4e0bautofs\u670d\u52a1\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">root@ubuntu:~# systemctl restart autofs.service<\/pre>\n<h3>\u5b89\u88c5NIS<\/h3>\n<pre class=\"lang:sh decode:true \">root@ubuntu:~# apt -y install nis<\/pre>\n<p>\u6839\u636e\u63d0\u793a\uff0c\u8f93\u5165\u6211\u4eec\u7684nis\u57df\u540dyyshell.com<br \/>\n<a href=\"https:\/\/yyshell.com\/wp-content\/uploads\/2016\/10\/nis.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-390 size-full\" src=\"https:\/\/yyshell.com\/wp-content\/uploads\/2016\/10\/nis.png\" alt=\"nis\" width=\"1310\" height=\"227\" \/><\/a>\u8f93\u5165\u5b8c\u6bd5\u540e\uff0c\u56de\u8f66\u786e\u5b9a\u5373\u53ef\u3002<\/p>\n<p>\u914d\u7f6e\u4e0b\uff1a<\/p>\n<pre class=\"lang:sh decode:true\">root@ubuntu:~# echo \"ypserver 192.168.42.101\" &gt;&gt; \/etc\/yp.conf<\/pre>\n<pre class=\"lang:sh decode:true\">root@ubuntu:~# vim \/etc\/nsswitch.conf<\/pre>\n<p>passwd:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 compat\u00a0 <span style=\"color: #ff0000;\">nis<\/span><br \/>\ngroup:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 compat\u00a0 <span style=\"color: #ff0000;\">nis<\/span><br \/>\nshadow:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 compat\u00a0 <span style=\"color: #ff0000;\">nis<\/span><\/p>\n<p>hosts:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 files dns\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: #ff0000;\">nis<\/span><\/p>\n<p>\u5728\u4e0a\u8ff0\u51e0\u884c\uff0c\u7ea2\u8272\u7684nis\u662f\u9700\u8981\u6dfb\u52a0\u7684\u3002<\/p>\n<p>\u91cd\u542fNIS:<\/p>\n<pre class=\"lang:sh decode:true \">root@ubuntu:~# systemctl restart nis.service<\/pre>\n<p>\u67e5\u770b\u662f\u5426\u8fde\u63a5nis\u6210\u529f\uff1a<br \/>\n\u6211\u4eec\u4e4b\u524d\u670d\u52a1\u7aef\u6dfb\u52a0\u4e86\u4e00\u4e2anis\u7528\u6237alice\uff0c\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b\u662f\u5426\u5b58\u5728\u8fd9\u4e2auid\u4e3a500\u7684\u7528\u6237\uff0c\u770b\u770b\u662f\u5426\u8fde\u63a5nis\u6210\u529f\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">root@ubuntu:~# getent passwd<\/pre>\n<blockquote><p>root:x:0:0:root:\/root:\/bin\/bash<br \/>\ndaemon:x:1:1:daemon:\/usr\/sbin:\/usr\/sbin\/nologin<br \/>\nbin:x:2:2:bin:\/bin:\/usr\/sbin\/nologin<br \/>\n&#8230;\u7701\u7565\u82e5\u5e72\u884c<br \/>\nalice:x:500:500::\/home\/alice:\/bin\/bash<\/p><\/blockquote>\n<p>\u53ef\u4ee5\u770b\u5230\u6210\u529f\u4e86\u3002<\/p>\n<h3>\u767b\u5f55<\/h3>\n<p>\u4e0b\u9762\u6211\u4eec\u6d4b\u8bd5\u4e0b\u7528alice\u7528\u6237\u767b\u5f55<\/p>\n<pre class=\"lang:sh decode:true \">alice@ubuntu:~$ whoami\r\nalice\r\nalice@ubuntu:~$ pwd\r\n\/home\/alice<\/pre>\n<p>\u7528mount\u547d\u4ee4\u67e5\u770b\u4e0b\uff0c\u53d1\u73b0home\u76ee\u5f55\u662f\u6302\u8f7d\u7684\uff1a<br \/>\n192.168.42.101:\/home\/alice on \/home\/alice type nfs4 (rw,relatime,vers=4.0,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.42.15,local_lock=none,addr=192.168.42.101)<\/p>\n<h3>\u5b89\u5168\u8bbe\u7f6e<\/h3>\n<p>\u4e0eCentOS\u4e0d\u540c\uff0cUbuntu\u9ed8\u8ba4\u7684\u9632\u706b\u5899\u662f\u4e0d\u542f\u7528\u7684\uff0c\u9ed8\u8ba4\u4e5f\u4e0d\u5b89\u88c5selinux\u7b49\u8f6f\u4ef6\uff0c\u8fd9\u4e5f\u8bb8\u5c31\u662f\u5b83\u66f4\u4e3a\u201c\u6613\u7528\u201d\u7684\u539f\u56e0\u4e4b\u4e00\u3002\u6211\u4eec\u672c\u6b21\u5c06\u4f7f\u7528\u9632\u706b\u5899\u548ctcp_wrapper\u6765\u505a\u5b89\u5168\u52a0\u56fa\u5de5\u4f5c\u3002<\/p>\n<p>\u4fee\u6539ypbind\u7684\u7aef\u53e3\uff1a<br \/>\nypbind\u4e5f\u662f\u901a\u8fc7rpcbind\u6765\u52a8\u6001\u5206\u914d\u7aef\u53e3\u7684\uff0c\u6211\u4eec\u624b\u52a8\u6307\u5b9a\u4e0b\u5b83\u7684\u7aef\u53e3\uff0c\u597d\u901a\u8fc7\u9632\u706b\u5899\u6765\u9650\u5236\u8bbf\u95ee<\/p>\n<pre class=\"lang:sh decode:true \">root@ubuntu:~# vim \/etc\/default\/nis<\/pre>\n<p>\u628a28\u884cYPBINDARGS=-no-dbus\u4fee\u6539\u6210YPBINDARGS=&#8221;-no-dbus -p 666&#8243;<br \/>\n\u91cd\u542fnis\u670d\u52a1\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">root@ubuntu:~# systemctl restart nis.service<\/pre>\n<p>\u4e0b\u9762\u6dfb\u52a0\u9632\u706b\u5899\u89c4\u5219\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">root@ubuntu:~# ufw allow ssh\r\nroot@ubuntu:~# ufw allow from 192.168.42.101 to any port 111\r\nroot@ubuntu:~# ufw allow from 192.168.42.101 to any port 666<\/pre>\n<p>\u7b2c\u4e00\u6761\u5c24\u4e3a\u91cd\u8981\uff0c\u6ca1\u6709\u8fd9\u6761\u89c4\u5219\uff0c\u5f85\u4f1a\u542f\u7528\u9632\u706b\u5899\u540e\u4f60\u5c31\u6ca1\u6cd5\u8fde\u63a5\u4e86\u3002<br \/>\n\u542f\u7528\u9632\u706b\u5899\uff1a<\/p>\n<pre class=\"lang:sh decode:true\">root@ubuntu:~# ufw enable<\/pre>\n<p>\u8fd8\u53ef\u4ee5\u4f7f\u7528tcp_wrapper\u6765\u9650\u5236rpc\u7aef\u53e3\u7684\u8bbf\u95ee\uff1a<\/p>\n<pre class=\"lang:sh decode:true\">root@ubuntu:~# echo \"rpcbind: 127. 192.168.42.101\" &gt;&gt; \/etc\/hosts.allow\r\nroot@ubuntu:~# echo \"rpcbind: ALL\" &gt;&gt; \/etc\/hosts.deny<\/pre>\n<p>\u7ecf\u8fc7\u68c0\u67e5\uff0c\u5404\u9879\u529f\u80fd\u6b63\u5e38\uff0c\u5b89\u5168\u52a0\u56fa\u6ca1\u6709\u5bfc\u81f4\u5404\u9879\u670d\u52a1\u5f02\u5e38\u3002<\/p>\n<h3>\u4e00\u70b9\u5751\u7239\u7684\u5730\u65b9<\/h3>\n<p>ubuntu 16.04\u5f00\u673a\u542f\u52a8\u7684\u65f6\u5019\uff0c\u901a\u8fc7systemd\u4f1a\u5148\u542f\u52a8nis\uff0c\u540e\u542f\u52a8rpcbind\uff0c\u5bfc\u81f4nis\u670d\u52a1\u6ca1\u6709\u6b63\u786e\u542f\u52a8\uff0c\u65e0\u6cd5\u83b7\u53d6nis\u8d26\u53f7\u4fe1\u606f\uff08redhat\u7cfb\u597d\u50cf\u6ca1\u8fd9\u4e2a\u6bdb\u75c5\uff09\uff0c\u8fd9\u662f\u4e00\u4e2abug\uff0c\u89e3\u51b3\u7684\u529e\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">root@ubuntu:~# systemctl add-wants multi-user.target rpcbind.service<\/pre>\n<h3>\u4e00\u70b9\u603b\u7ed3\uff1a<\/h3>\n<p>\u672c\u6b21\u6559\u7a0b\u4e2d\uff0c\u670d\u52a1\u7aef\u5230\u5ba2\u6237\u7aef\uff0c\u6240\u6709\u7684nfs\u548cnis\u90fd\u6ca1\u6709\u4f7f\u7528\u4f7f\u7528\u57df\u540dFQDN\u6765\u914d\u7f6e\u8fde\u63a5\u3002\u4e00\u822c\u90fd\u662f\u76f4\u63a5\u7528IP\u5730\u5740\u8fde\u63a5\u7684\u3002\u4e2a\u4eba\u8ba4\u4e3a\u8fd9\u6837\u5e76\u4e0d\u662f\u5f88\u597d\uff0c\u6211\u63a8\u8350\u5728\/etc\/hosts\u6587\u4ef6\u4e2d\u6dfb\u52a0FQDN\u4fe1\u606f\uff0c\u4f8b\u5982\uff1a<\/p>\n<blockquote>\n<div>192.168.42.101 server.yyshell.com server<br \/>\n192.168.42.102 client.yyshell.com client<br \/>\n192.168.42.15 ubuntu.yyshell.com ubuntu<\/div>\n<\/blockquote>\n<div>\u53e6\u5916\uff0c\/etc\/sysconfig\/network\u4e2d\u7684HOSTNAME\u4ee5\u53ca\/etc\/idmapd.conf\u90fd\u662f\u53ef\u4ee5\u8003\u8651\u914d\u7f6eFQDN\u7684\uff08\u4e00\u822c\u8fd9\u4e24\u4e2a\u5730\u65b9\uff0c\u5982\u679c\u4e0a\u9762hosts\u6587\u4ef6\u6539\u52a8\u540e\u6ca1\u6709\u95ee\u9898\uff0c\u5c31\u4e0d\u662f\u5fc5\u987b\u914d\u7f6e\u7684\uff09\uff0c\u50cf\u672c\u6b21\u6559\u7a0b\u4e2d\u90a3\u6837\u4ec0\u4e48\u90fd\u4e0d\u914d\u7f6e\uff0cnfs\u9ed8\u8ba4\u4f7f\u7528\u7684\u662flocaldomain\uff0c\u6240\u4ee5\u4e5f\u6ca1\u6709\u51fa\u9519\uff08\u76f8\u5f53\u4e8e\u8d1f\u8d1f\u5f97\u6b63\uff09\u3002\u5982\u679chosts\u4e2d\u5df2\u7ecf\u6709\u4e86\u89e3\u6790\uff0c\u6211\u4eec\u6dfb\u52a0nis\u5ba2\u6237\u7aef\u7684\u65f6\u5019\u4e5f\u4f7f\u7528\u57df\u540d\uff0c\u8fd9\u6837\u5982\u679c\u6211\u4eec\u66f4\u6362\u673a\u5668ip\uff0c\u76f4\u63a5\u6539\u4e0bhosts\u6587\u4ef6\u5c31\u53ef\u4ee5\u4e86\u3002<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u7bc7\u5c06\u6ce8\u91cd\u4ecb\u7ecdUbuntu 16.04\u670d\u52a1\u5668\u4f5c\u4e3a\u5ba2\u6237\u7aef\u63a5\u5165CentOS6\u7684nis<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,12,7],"tags":[49,54,50,48,55,56],"class_list":["post-389","post","type-post","status-publish","format-standard","hentry","category-linux","category-12","category-7","tag-autofs","tag-centos","tag-nfs","tag-nis","tag-ubuntu","tag-ufw"],"_links":{"self":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/389","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=389"}],"version-history":[{"count":10,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/389\/revisions"}],"predecessor-version":[{"id":459,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/389\/revisions\/459"}],"wp:attachment":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}