{"id":166052,"date":"2019-12-25T11:30:21","date_gmt":"2019-12-25T03:30:21","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=166052"},"modified":"2019-12-10T15:54:14","modified_gmt":"2019-12-10T07:54:14","slug":"centos-nfs-share","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/centos-nfs-share.html","title":{"rendered":"CentOS 7\u96c6\u7fa4\u95f4\u5b9e\u73b0NFS\u6587\u4ef6\u5171\u4eab"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u6700\u8fd1\u5728\u641e\u5b9e\u9a8c\u5ba4\u96c6\u7fa4\u73af\u5883\uff0c\u9700\u8981\u628a\u5b58\u50a8\u670d\u52a1\u5668\u7528\u8d77\u6765\uff0c\u4e24\u53f0\u5b58\u50a8\u670d\u52a1\u5668\u5927\u698212T\u7684\u5927\u5c0f\uff0c\u60f3\u5b9e\u73b0\u4f7f\u5176\u4ed6\u76848\u4e2a\u8ba1\u7b97\u8282\u70b9\u90fd\u80fd\u50cf\u8bbf\u95ee\u672c\u5730\u76ee\u5f55\u4e00\u6837\u8bbf\u95ee\u5b58\u50a8\u670d\u52a1\u5668\uff0c\u7c7b\u4f3cWindows\u4e0b\u7684\u6587\u4ef6\u5171\u4eab\uff0c\u56e0\u6b64\u4f7f\u7528\u4e86NFS\u670d\u52a1\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
NFS\u4ecb\u7ecd\u548c\u539f\u7406<\/strong><\/div>\n

NFS \u662fNetwork File System\u7684\u7f29\u5199\uff0c\u5373\u7f51\u7edc\u6587\u4ef6\u7cfb\u7edf\u3002\u662f\u4e00\u79cd\u4f7f\u7528\u4e8e\u5206\u6563\u5f0f\u6587\u4ef6\u7cfb\u7edf\u7684\u534f\u5b9a\uff0c\u529f\u80fd\u662f\u8ba9\u5ba2\u6237\u7aef\u901a\u8fc7\u7f51\u7edc\u8bbf\u95ee\u4e0d\u540c\u4e3b\u673a\u4e0a\u78c1\u76d8\u91cc\u7684\u6570\u636e\uff0c\u4e3b\u8981\u7528\u5728\u7c7bUnix\u7cfb\u7edf\u4e0a\u5b9e\u73b0\u6587\u4ef6\u5171\u4eab\u7684\u4e00\u79cd\u65b9\u6cd5\u3002<\/p>\n

NFS\u4f7f\u7528RPC\uff0c\u5373\u8fdc\u7a0b\u8fc7\u7a0b\u8c03\u7528 (Remote ProcedureCall) \uff0c\u5b83\u80fd\u4f7f\u5ba2\u6237\u7aef\u6267\u884c\u5176\u4ed6\u7cfb\u7edf\u4e2d\u7684\u7a0b\u5e8f\u3002NFS\u672c\u8eab\u662f\u6ca1\u6709\u63d0\u4f9b\u4fe1\u606f\u4f20\u8f93\u7684\u534f\u8bae\u548c\u529f\u80fd\u7684\uff0c\u4f46NFS\u5374\u80fd\u8ba9\u6211\u4eec\u901a\u8fc7\u7f51\u7edc\u8fdb\u884c\u8d44\u6599\u7684\u5206\u4eab\uff0c\u8fd9\u662f\u56e0\u4e3aNFS\u4f7f\u7528\u4e86\u4e00\u4e9b\u4f9d\u8d56RPC\u7684\u4f20\u8f93\u534f\u8bae\u3002\u53ef\u4ee5\u7b80\u5355\u7406\u89e3RPC\u548cNFS\u7684\u5173\u7cfb\uff1aNFS\u662f\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf\uff0c\u800cRPC\u8d1f\u8d23\u4fe1\u606f\u7684\u4f20\u8f93\u3002<\/p>\n

\"\"<\/p>\n

\u8be6\u7ec6\u914d\u7f6e<\/strong><\/div>\n
1. \u524d\u671f\u914d\u7f6e<\/strong><\/span><\/div>\n

\u5173\u95ed\u670d\u52a1\u7aef\u548c\u5ba2\u6237\u7aef\u7684\u9632\u706b\u5899\u548cselinux\uff0c\u8fd9\u91cc\u7684\u670d\u52a1\u7aef\u6307\u9700\u8981\u5171\u4eab\u51fa\u53bb\u7684\u5b58\u50a8\u670d\u52a1\u5668\uff0c\u5ba2\u6237\u7aef\u6307\u5176\u4ed6\u76848\u4e2a\u8ba1\u7b97\u8282\u70b9\u3002\u4ee5\u4e0b\u6240\u6709\u547d\u4ee4\u662f\u5728CentOS7\u73af\u5883\u4e0b<\/p>\n

1.1 \u5173\u95ed\u9632\u706b\u5899<\/p>\n

systemctl stop firewalld<\/pre>\n

1.2 \u628aselinux\u8bbe\u7f6e\u4e3a\u8bb8\u53ef\u6a21\u5f0f\uff08\u6216\u8005\u5173\u95ed\uff09<\/p>\n

etenforce 0<\/pre>\n

\uff08\u5982\u679c\u60f3\u8981\u7981\u7528\uff0c\u9700\u8981\u66f4\u6539\u914d\u7f6e\u6587\u4ef6\uff0c\u628aSELINUX\u8bbe\u7f6e\u6210disabled\uff0c\u91cd\u542f\u751f\u6548\uff09<\/p>\n

2.\u670d\u52a1\u7aef\u914d\u7f6e<\/strong><\/span><\/div>\n

2.1 \u5b89\u88c5\u9700\u8981\u7684\u8f6f\u4ef6\u5305\uff08\u4f7f\u7528yum\uff09<\/p>\n

yum install -y rpc-bind nfs-utils<\/pre>\n

2.2 \u521b\u5efa\u60f3\u8981\u5171\u4eab\u7684\u6587\u4ef6\u5939\uff0c\u4f8b\u5982 \/datas<\/p>\n

mkdir \/datas<\/pre>\n

2.3 \u628a\u5171\u4eab\u76ee\u5f55\u7684\u6743\u9650\u8bbe\u5b9a\u4e3a\u6240\u6709\u7528\u6237\u90fd\u53ef\u8bfb\u53ef\u5199\u6743\u9650<\/p>\n

chmod -R 777 \/datas<\/pre>\n

2.4 \u4fee\u6539NFS\u670d\u52a1\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6 \/etc\/exports<\/p>\n

vim \/etc\/exports<\/pre>\n

#\u6dfb\u52a0\u5982\u4e0b\u89c4\u5219<\/p>\n

\/datas *(rw,sync)<\/pre>\n

\u89c4\u5219\u8bf4\u660e\uff1a\/datas\u4ee3\u8868\u5171\u4eab\u7684\u6587\u4ef6\uff0c*\u4ee3\u8868\u6240\u6709\u4e3b\u673a\u90fd\u53ef\u4ee5\u8bbf\u95ee\uff0crw\u6307\u8bfb\u548c\u5199\u7684\u6743\u9650\uff0csync\u8868\u660e\u4f7f\u7528\u540c\u6b65\u65b9\u5f0f\u3002
\n\u5176\u4ed6\u66f4\u4e3a\u7cbe\u786e\u7684\u53ef\u9009\u914d\u7f6e\u5982\u4e0b\uff1a
\n\"\"<\/p>\n

\n2.5 \u5f00\u542fNFS\u670d\u52a1<\/p>\n

systemctl start nfs<\/pre>\n

\u81f3\u6b64\u670d\u52a1\u7aef\u7684nfs\u914d\u7f6e\u5b8c\u6bd5\uff0c\u56de\u60f3\u4e00\u4e0b\uff0c\u6211\u4eec\u4e3b\u8981\u505a\u4e86\uff1a<\/p>\n

\u5173\u95ed\u9632\u706b\u5899\u548cselinux
\n\u5c06\u6211\u4eec\u521b\u5efa\u7684\u76ee\u5f55\/datas\u901a\u8fc7nfs\u4e3b\u914d\u7f6e\u6587\u4ef6\/etc\/exports\u5171\u4eab\u51fa\u53bb
\n\u5f00\u542fnfs\u670d\u52a1<\/p>\n

Ps\uff1a\u5982\u679c\u60f3\u5171\u4eab\u670d\u52a1\u5668\u7684\u67d0\u4e2a\u786c\u76d8\uff0c\u53ea\u9700\u8981\u5c06\/datas\u76ee\u5f55\u4f7f\u7528mount\u547d\u4ee4\u6302\u8f7d\u5230\u8be5\u786c\u76d8\u5373\u53ef\u3002
\n\u67e5\u770b\u786c\u76d8\u548c\u6302\u8f7d\u60c5\u51b5\u7684\u547d\u4ee4\u4e3a\uff1a<\/p>\n

df -h<\/pre>\n

\u4f8b\u5982\u5c06\u786c\u76d8\u8bbe\u5907\/dev\/sdd \u6302\u8f7d\u5230\/datas<\/p>\n

mount \/dev\/sdd \/datas<\/pre>\n

\u63a5\u4e0b\u6765\u914d\u7f6e\u5ba2\u6237\u7aef<\/p>\n

3.\u5ba2\u6237\u7aef\u914d\u7f6e<\/strong><\/span><\/div>\n

3.1 \u5173\u95ed\u9632\u706b\u5899\u548cselinux<\/p>\n

\u540c\u4e0a<\/p>\n

3.2 \u5b89\u88c5NFS<\/p>\n

\u540c\u4e0a<\/p>\n

3.3 \u5c06\u670d\u52a1\u7aef\u7684\u5171\u4eab\u76ee\u5f55\u6302\u8f7d\u5230\u672c\u673a\u7684 \/data-nfs\u76ee\u5f55\u4e0a\uff0c\u6211\u8fd9\u91cc\u7684ip\u662fIB\u5361\u7684\u7684ip\uff0c\u6ca1\u6709IB\u9a71\u52a8\u7684\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u5185\u7f51ip\uff0c\/data-nfs\u662f\u6211\u81ea\u5b9a\u4e49\u7684\u76ee\u5f55\u3002<\/p>\n

mount -t nfs 12.12.12.29:\/datas \/data-nfs<\/pre>\n

\u81f3\u6b64\uff0c\u5ba2\u6237\u7aef\u914d\u7f6e\u5b8c\u6bd5\uff0c\u8bbf\u95ee\/data-nfs\u76ee\u5f55\u5c31\u76f8\u5f53\u4e8e\u8bbf\u95ee\u670d\u52a1\u7aef\u7684\/datas\u76ee\u5f55<\/p>\n

ps\uff1a\u4ee5\u4e0a\u914d\u7f6e\u91cd\u542f\u673a\u5668\u540e\u4f1a\u51fa\u95ee\u9898\uff0c\u5efa\u8bae\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\u6267\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

NFS \u662fNetwork File System\u7684\u7f29\u5199\uff0c\u5373\u7f51\u7edc\u6587\u4ef6\u7cfb\u7edf\u3002\u662f\u4e00\u79cd\u4f7f\u7528\u4e8e\u5206\u6563\u5f0f\u6587\u4ef6\u7cfb\u7edf\u7684\u534f\u5b9a\uff0c\u529f\u80fd […]<\/p>\n","protected":false},"author":310,"featured_media":166211,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-166052","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/166052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/310"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=166052"}],"version-history":[{"count":33,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/166052\/revisions"}],"predecessor-version":[{"id":166288,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/166052\/revisions\/166288"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/166211"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=166052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=166052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=166052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}