﻿{"id":2394,"date":"2022-01-05T11:07:07","date_gmt":"2022-01-05T03:07:07","guid":{"rendered":"http:\/\/nick.txtcc.com\/?p=2394"},"modified":"2022-01-05T11:07:07","modified_gmt":"2022-01-05T03:07:07","slug":"centos%e4%b8%8b%e6%90%ad%e5%bb%banfs%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"http:\/\/nick.txtcc.com\/index.php\/linux\/2394","title":{"rendered":"CentOS\u4e0b\u642d\u5efaNFS\u670d\u52a1\u5668"},"content":{"rendered":"<pre>\u73af\u5883\u4ecb\u7ecd\uff1a \n\n1. \u670d\u52a1\u5668\uff1a 192.168.0.100 \n\n2. \u5ba2\u6237\u673a\uff1a 192.168.0.101 \n\n\u5b89\u88c5\u8f6f\u4ef6\u5305\uff1a \n\n1. \u670d\u52a1\u5668\u548c\u5ba2\u6237\u673a\u90fd\u8981\u5b89\u88c5nfs \u548c rpcbind \u8f6f\u4ef6\u5305\uff1a \n\nyum -y install nfs-utils  rpcbind \n\n2. \u53ef\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\uff0c\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u4e86nfs-uitls  rpcbind\u8fd9\u4e24\u4e2a\u8f6f\u4ef6\u5305\uff1a\u5982\u679c\u67e5\u8be2\u7ed3\u679c\u5982\u4e0b\u9762\u6240\u793a\uff0c\u8bf4\u660e\u5df2\u7ecf\u5b89\u88c5\u8fc7\u4e86\uff1a \n\n[root@Server1 ~]# rpm -qa|grep nfs \n\nnfs-utils-1.2.3-39.el6.x86_64 \n\nnfs4-acl-tools-debuginfo-0.3.3-6.el6.x86_64 \n\nnfs-utils-debuginfo-1.2.3-39.el6.x86_64 \n\nnfs-utils-lib-devel-1.1.5-6.el6.x86_64 \n\nnfs-utils-lib-1.1.5-6.el6.x86_64 \n\nnfs-utils-lib-debuginfo-1.1.5-6.el6.x86_64 \n\nnfs4-acl-tools-0.3.3-6.el6.x86_64 \n\n[root@Server1 ~]# rpm -qa|grep rpcbind \n\nrpcbind-0.2.0-11.el6.x86_64 \n\n\u670d\u52a1\u5668\u7aef\u914d\u7f6e\uff1a \n\n1. \u5728\u670d\u52a1\u5668\u4e0a\u521b\u5efaNFS\u5171\u4eab\u76ee\u5f55\uff1amkdir \/usr\/local\/test \n\n2. \u8bbe\u7f6e\u5171\u4eab\u76ee\u5f55\u7684\u8bfb\u5199\u6743\u9650: chmod 666 \/usr\/local\/test  \n\n3. \u7f16\u8f91export\u6587\u4ef6\uff1a  vi \/etc\/exports   \n\n\/usr\/local\/test\/ 192.168.0.101(rw,no_root_squash,no_all_squash,sync) \n\n\u6ce8\u610f\u5730\u5740\u548c\u53c2\u6570\u8868\u4e4b\u95f4\u6ca1\u6709\u7a7a\u683c\u3002\u5982\u679c\u4e0b\u9762\u8bbe\u7f6e\u7684mountd\u7aef\u53e3\u5927\u4e8e1024\uff0c\u9700\u8981\u5728\u53c2\u6570\u8868\u91cc\u52a0\u5165\u53c2\u6570\uff1ainsecure \n\n4. \u4f7f\u914d\u7f6e\u751f\u6548\uff1a \n\nexportfs  -r \n\n\u6ce8\uff1a\u914d\u7f6e\u6587\u4ef6\u8bf4\u660e\uff1a \n\n\/usr\/local\/test\/ \u4e3a\u5171\u4eab\u7684\u76ee\u5f55\uff0c\u4f7f\u7528\u7edd\u5bf9\u8def\u5f84\u3002\n192.168.0.101(rw,no_root_squash,no_all_squash,sync) \u4e3a\u5ba2\u6237\u7aef\u7684\u5730\u5740\u53ca\u6743\u9650\uff0c\u5730\u5740\u53ef\u4ee5\u662f\u4e00\u4e2a\u7f51\u6bb5\uff08\u5982\uff1a192.168.0.0\/24\uff09\uff0c\u4e00\u4e2aIP\u5730\u5740\u6216\u8005\u662f\u4e00\u4e2a\u57df\u540d\uff0c\u57df\u540d\u652f\u6301\u901a\u914d\u7b26\uff0c\u5982\uff1a*.hpce.cn\uff0c\u5730\u5740\u4e0e\u6743\u9650\u4e2d\u95f4\u6ca1\u6709\u7a7a\u683c\u3002 \n\n\u6743\u9650\u8bf4\u660e\uff1a\nrw\uff1aread-write\uff0c\u53ef\u8bfb\u5199\uff1b\nro\uff1aread-only\uff0c\u53ea\u8bfb\uff1b\nsync\uff1a\u6587\u4ef6\u540c\u65f6\u5199\u5165\u786c\u76d8\u548c\u5185\u5b58\uff1b\u7531\u4e8e\u6211\u4eec\u7684\u65e5\u5fd7\u9700\u8981\u540c\u6b65\u5199\uff0c\u6240\u6709\u7528sync\u9009\u9879\u3002\nasync\uff1a\u6587\u4ef6\u6682\u5b58\u4e8e\u5185\u5b58\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u5199\u5165\u5185\u5b58\uff1b\nno_root_squash\uff1aNFS\u5ba2\u6237\u7aef\u8fde\u63a5\u670d\u52a1\u7aef\u65f6\u5982\u679c\u4f7f\u7528\u7684\u662froot\u7684\u8bdd\uff0c\u90a3\u4e48\u5bf9\u670d\u52a1\u7aef\u5206\u4eab\u7684\u76ee\u5f55\u6765\u8bf4\uff0c\u4e5f\u62e5\u6709root\u6743\u9650\u3002\u663e\u7136\u5f00\u542f\u8fd9\u9879\u662f\u4e0d\u5b89\u5168\u7684\u3002\nroot_squash\uff1aNFS\u5ba2\u6237\u7aef\u8fde\u63a5\u670d\u52a1\u7aef\u65f6\u5982\u679c\u4f7f\u7528\u7684\u662froot\u7684\u8bdd\uff0c\u90a3\u4e48\u5bf9\u670d\u52a1\u7aef\u5206\u4eab\u7684\u76ee\u5f55\u6765\u8bf4\uff0c\u62e5\u6709\u533f\u540d\u7528\u6237\u6743\u9650\uff0c\u901a\u5e38\u4ed6\u5c06\u4f7f\u7528nobody\u6216nfsnobody\u8eab\u4efd\uff1b\nall_squash\uff1a\u4e0d\u8bbaNFS\u5ba2\u6237\u7aef\u8fde\u63a5\u670d\u52a1\u7aef\u65f6\u4f7f\u7528\u4ec0\u4e48\u7528\u6237\uff0c\u5bf9\u670d\u52a1\u7aef\u5206\u4eab\u7684\u76ee\u5f55\u6765\u8bf4\u90fd\u662f\u62e5\u6709\u533f\u540d\u7528\u6237\u6743\u9650\uff1b\nanonuid\uff1a\u533f\u540d\u7528\u6237\u7684UID\u503c\uff0c\u901a\u5e38\u662fnobody\u6216nfsnobody\uff0c\u53ef\u4ee5\u5728\u6b64\u5904\u81ea\u884c\u8bbe\u5b9a\uff1b\nanongid\uff1a\u533f\u540d\u7528\u6237\u7684GID\u503c\u3002 \n\n5. \u542f\u52a8\u670d\u52a1rpcbind\u3001nfs\u670d\u52a1: \n\nservice rpcbind  start  \n\nservice nfs  start  \n\n\u670d\u52a1\u5668\u7aef\u9632\u706b\u5899\u8bbe\u7f6e\uff08NFS \u5f00\u542f\u9632\u5899\u914d\u7f6e\uff09\uff1a \n\n\u4fee\u6539\/etc\/services\u6587\u4ef6\uff1a \n\n\u914d\u7f6erpc\uff0cnfsd\uff0crquotad\uff0cmountd\u4f7f\u7528\u7684\u7aef\u53e3\u3002\u914d\u7f6e\u4e4b\u524d\u5148\u68c0\u67e5\u4e00\u4e0b\u662f\u5426\u5df2\u7ecf\u914d\u7f6e\u8fc7\u4e86\uff0c\u5df2\u7ecf\u914d\u8fc7\u7684\u5c31\u4e0d\u7528\u914d\u7f6e\u4e86\u3002\u6ca1\u6709\u914d\u7f6e\u7684\uff0c\u8981\u5206\u914d\u4e00\u4e2a\u5728\u6b64\u6587\u4ef6\u4e2d\u672a\u88ab\u4f7f\u7528\u7684\u7aef\u53e3\u53f7\u3002\u6211\u7684\u673a\u5668\u9ed8\u8ba4\u914d\u7f6e\u4e86\uff1arpc\u3001nfsd\u3001rquotad \n\nmountd: \u6ca1\u6709\u914d\u7f6e\u3002\u624b\u5de5\u52a0\u4e0a\uff1a \n\nmountd          48620\/tcp               #rpc.mountd   \n\nmountd          48620\/udp               #rpc.mountd   \n\n\u5982\u679cmountd\u5360\u7528\u7aef\u53e3\u5927\u4e8e 1024\uff0c\u5728\u6587\u4ef6 \/etc\/exports\u91cc\u9700\u8981\u52a0\u5165\u53c2\u6570insecure\u3002\u5982\uff1a 192.168.0.100(insecure,rw,async,root_squash,no_all_squash) \n\n\u91cd\u542fNFS\u670d\u52a1\uff1a \n\nservice nfs restart  \n\n\u9632\u706b\u5899\u914d\u7f6e\uff1a \n\n#firewall-cmd --permanent --add-service=rpc-bind\u3000\u3000\u5141\u8bb8rpc nfs mountd\u670d\u52a1\u901a\u8fc7\u9632\u706b\u5899\n#firewall-cmd --permanent --add-service=nfs\n#firewall-cmd --permanent --add-service=mountd\u3000\u3000\u7528\u4e8eshowmount\n#firewall-cmd --reload\u3000\u3000\u5237\u65b0\u9632\u706b\u5899\u914d\u7f6e\n\n\u5ba2\u6237\u7aef\u6302\u8f7d\uff1a \n\n\u521b\u5efa\u6302\u8f7d\u76ee\u5f55\uff1a mkdir \/usr\/local\/test \n\n\u67e5\u770b\u670d\u52a1\u5668\u629b\u51fa\u7684\u5171\u4eab\u76ee\u5f55\u4fe1\u606f\uff1a \n\nshowmount -e 192.168.0.100 \n\nExport list for 192.168.0.100: \n\n\/usr\/local\/test 192.168.0.101 \n\n\u5982\u679c\u663e\u793a\uff1arpc mount export: RPC: Unable to receive; errno = No route to host\uff0c\u5219\u9700\u8981\u5728\u670d\u52a1\u7aef\u5173\u95ed\u9632\u706b\u5899\u3002 \n\n\u4e3a\u4e86\u63d0\u9ad8NFS\u7684\u7a33\u5b9a\u6027\uff0c\u4f7f\u7528TCP\u534f\u8bae\u6302\u8f7d\uff0cNFS\u9ed8\u8ba4\u7528UDP\u534f\u8bae\uff1a \n\nmount -t nfs 192.168.0.100:\/usr\/local\/test  \/usr\/local\/test  -o proto=tcp -o nolock \n\n\u6302\u8f7d\u6210\u529f\u540e\u5373\u53ef\u8bbf\u95ee\u5171\u4eab\u7684NFS\u6587\u4ef6\u7cfb\u7edf\u4e86\u3002 \n\n\u5378\u8f7d\u5df2\u6302\u5728\u7684NFS \n\numount \/usr\/local\/test \n\n\u67e5\u770b\u6302\u8f7d\u76ee\u5f55\u7684\u4fe1\u606f\uff1a \n\nfuser -m -v \/usr\/local\/test  \n\nrpcinfo \u2013p  ip  \/\/\/ \u67e5\u770b\u4e3b\u673a\u7684rpc\u670d\u52a1\u548c\u7aef\u53e3 \n\nshowmount \u2013e  ip \/\/\/ \u67e5\u770b\u4e3b\u673a\u629b\u51fa\u7684nfs\u5217\u8868 \n\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>\u73af\u5883\u4ecb\u7ecd\uff1a 1. \u670d\u52a1\u5668\uff1a 192.168.0.100 2. \u5ba2\u6237\u673a\uff1a 192.168.0.101 \u5b89\u88c5\u8f6f\u4ef6\u5305\uff1a 1. \u670d\u52a1\u5668\u548c\u5ba2\u6237\u673a\u90fd\u8981\u5b89\u88c5nfs \u548c rpcbind \u8f6f\u4ef6\u5305\uff1a yum -y ins&#46;&#46;&#46;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[516],"class_list":["post-2394","post","type-post","status-publish","format-standard","hentry","category-linux","tag-nfs"],"_links":{"self":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/2394","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/comments?post=2394"}],"version-history":[{"count":1,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/2394\/revisions"}],"predecessor-version":[{"id":2395,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/2394\/revisions\/2395"}],"wp:attachment":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/media?parent=2394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/categories?post=2394"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/tags?post=2394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}