1. 程式人生 > >LINUX安裝NFS 服務,通過NFS共享資料夾(linux到linux)

LINUX安裝NFS 服務,通過NFS共享資料夾(linux到linux)

[[email protected] project]# yum list installed | grep 'nfs' 檢查是否已經安裝NFS
[[email protected] project]# yum -y install nfs-utils rpcbind  安裝NFS
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
base                                                                                      | 3.7 kB     00:00
epel                                                                                      | 4.7 kB     00:00
epel/primary_db                                                                           | 6.0 MB     00:00
extras                                                                                    | 3.4 kB     00:00
updates                                                                                   | 3.4 kB     00:00
Resolving Dependencies
--> Running transaction check
---> Package nfs-utils.x86_64 1:1.2.3-75.el6_9 will be installed
--> Processing Dependency: nfs-utils-lib >= 1.1.0-3 for package: 1:nfs-utils-1.2.3-75.el6_9.x86_64
--> Processing Dependency: libtirpc >= 0.2.1-11 for package: 1:nfs-utils-1.2.3-75.el6_9.x86_64
--> Processing Dependency: keyutils >= 1.4-4 for package: 1:nfs-utils-1.2.3-75.el6_9.x86_64
--> Processing Dependency: python-argparse for package: 1:nfs-utils-1.2.3-75.el6_9.x86_64
--> Processing Dependency: libgssglue.so.1(libgssapi_CITI_2)(64bit) for package: 1:nfs-utils-1.2.3-75.el6_9.x86_6                                                                                                                            4
--> Processing Dependency: libgssglue for package: 1:nfs-utils-1.2.3-75.el6_9.x86_64
--> Processing Dependency: libevent for package: 1:nfs-utils-1.2.3-75.el6_9.x86_64
--> Processing Dependency: libtirpc.so.1()(64bit) for package: 1:nfs-utils-1.2.3-75.el6_9.x86_64
--> Processing Dependency: libnfsidmap.so.0()(64bit) for package: 1:nfs-utils-1.2.3-75.el6_9.x86_64
--> Processing Dependency: libgssglue.so.1()(64bit) for package: 1:nfs-utils-1.2.3-75.el6_9.x86_64
--> Processing Dependency: libevent-1.4.so.2()(64bit) for package: 1:nfs-utils-1.2.3-75.el6_9.x86_64
---> Package rpcbind.x86_64 0:0.2.0-13.el6_9.1 will be installed
--> Running transaction check
---> Package keyutils.x86_64 0:1.4-5.el6 will be installed
---> Package libevent.x86_64 0:1.4.13-4.el6 will be installed
---> Package libgssglue.x86_64 0:0.1-11.el6 will be installed
---> Package libtirpc.x86_64 0:0.2.1-13.el6_9 will be installed
---> Package nfs-utils-lib.x86_64 0:1.1.5-13.el6 will be installed
---> Package python-argparse.noarch 0:1.2.1-2.1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================
 Package                       Arch                 Version                          Repository             Size
=================================================================================================================
Installing:
 nfs-utils                     x86_64               1:1.2.3-75.el6_9                 updates               336 k
 rpcbind                       x86_64               0.2.0-13.el6_9.1                 updates                51 k
Installing for dependencies:
 keyutils                      x86_64               1.4-5.el6                        base                   39 k
 libevent                      x86_64               1.4.13-4.el6                     base                   66 k
 libgssglue                    x86_64               0.1-11.el6                       base                   23 k
 libtirpc                      x86_64               0.2.1-13.el6_9                   updates                82 k
 nfs-utils-lib                 x86_64               1.1.5-13.el6                     base                   71 k
 python-argparse               noarch               1.2.1-2.1.el6                    base                   48 k
Transaction Summary
=================================================================================================================
Install       8 Package(s)

Total download size: 716 k
Installed size: 2.0 M
Downloading Packages:
(1/8): keyutils-1.4-5.el6.x86_64.rpm                                                      |  39 kB     00:00
(2/8): libevent-1.4.13-4.el6.x86_64.rpm                                                   |  66 kB     00:00
(3/8): libgssglue-0.1-11.el6.x86_64.rpm                                                   |  23 kB     00:00
(4/8): libtirpc-0.2.1-13.el6_9.x86_64.rpm                                                 |  82 kB     00:00
(5/8): nfs-utils-1.2.3-75.el6_9.x86_64.rpm                                                | 336 kB     00:00
(6/8): nfs-utils-lib-1.1.5-13.el6.x86_64.rpm                                              |  71 kB     00:00
(7/8): python-argparse-1.2.1-2.1.el6.noarch.rpm                                           |  48 kB     00:00
(8/8): rpcbind-0.2.0-13.el6_9.1.x86_64.rpm                                                |  51 kB     00:00
-----------------------------------------------------------------------------------------------------------------
Total                                                                            2.8 MB/s | 716 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : libgssglue-0.1-11.el6.x86_64                                                                  1/8
  Installing : libtirpc-0.2.1-13.el6_9.x86_64                                                                2/8
  Installing : rpcbind-0.2.0-13.el6_9.1.x86_64                                                               3/8
  Installing : python-argparse-1.2.1-2.1.el6.noarch                                                          4/8
  Installing : libevent-1.4.13-4.el6.x86_64                                                                  5/8
  Installing : keyutils-1.4-5.el6.x86_64                                                                     6/8
  Installing : nfs-utils-lib-1.1.5-13.el6.x86_64                                                             7/8
  Installing : 1:nfs-utils-1.2.3-75.el6_9.x86_64                                                             8/8
  Verifying  : rpcbind-0.2.0-13.el6_9.1.x86_64                                                               1/8
  Verifying  : libtirpc-0.2.1-13.el6_9.x86_64                                                                2/8
  Verifying  : keyutils-1.4-5.el6.x86_64                                                                     3/8
  Verifying  : libevent-1.4.13-4.el6.x86_64                                                                  4/8
  Verifying  : nfs-utils-lib-1.1.5-13.el6.x86_64                                                             5/8
  Verifying  : libgssglue-0.1-11.el6.x86_64                                                                  6/8
  Verifying  : 1:nfs-utils-1.2.3-75.el6_9.x86_64                                                             7/8
  Verifying  : python-argparse-1.2.1-2.1.el6.noarch                                                          8/8

Installed:
  nfs-utils.x86_64 1:1.2.3-75.el6_9                       rpcbind.x86_64 0:0.2.0-13.el6_9.1

Dependency Installed:
  keyutils.x86_64 0:1.4-5.el6       libevent.x86_64 0:1.4.13-4.el6       libgssglue.x86_64 0:0.1-11.el6
  libtirpc.x86_64 0:0.2.1-13.el6_9  nfs-utils-lib.x86_64 0:1.1.5-13.el6  python-argparse.noarch 0:1.2.1-2.1.el6

Complete! 安裝完成
[
[email protected]
project]# service nfs status 檢視當前NFS 服務狀態 rpc.svcgssd is stopped 並未啟動 rpc.mountd is stopped nfsd is stopped [[email protected] project]# service rpcbind start 啟動服務 Starting rpcbind: [ OK ] [[email protected] project]# service nfs start 啟動服務 Starting NFS services: [ OK ] Starting NFS mountd: rpc.mountd: svc_tli_create: could not open connection for udp6 rpc.mountd: svc_tli_create: could not open connection for tcp6 rpc.mountd: svc_tli_create: could not open connection for udp6 rpc.mountd: svc_tli_create: could not open connection for tcp6 rpc.mountd: svc_tli_create: could not open connection for udp6 rpc.mountd: svc_tli_create: could not open connection for tcp6 [ OK ] Starting NFS daemon: rpc.nfsd: address family inet6 not supported by protocol TCP [ OK ] Starting RPC idmapd: [ OK ] [
[email protected]
project]#

共享設定

1、在172.17.150.79設定共享目錄,把該目錄開放給*********,編輯/etc/exports,增加一行

/data/project/insurance_web/upload 172.17.150.79(rw,no_root_squash,no_all_squash,sync)

使配置生效,輸入命令:exportfs -r

3、檢視已共享的目錄,命令:
本機:showmount -e
其他:showmount -e IP

[[email protected] project]# exportfs -r
[[email protected] project]# showmount -e
Export list for insurance:
/data/project/insurance_web/upload 172.17.150.79
4、在********掛載共享資料夾,輸入命令:
[[email protected] insurance-mall]# mount -t nfs 172.17.150.79:/data/project/insurance_web/upload/ /data/project/insurance-mall/upload
[[email protected] insurance-mall]# ls
css  detail.html  fonts  form.html  images  index.html  index.jsp  js  META-INF  payment.html  pay-success.html  upload  WEB-INF
[[email protected] insurance-mall]# ls upload/
20180428120107263854.jpg  20180503105220526107.png  20180503123215672584.png  20180503135022174694.png  20180503152644483515.jpg  201805031806495746.jpg    20180504172445484913.jpg  20180510165903984799.jpg  20180515100239888142.png
20180428120303367285.jpg  20180503105348438164.png  20180503123252897243.png  2018050313583141970.png   20180503152856893189.jpg  20180504092426276881.jpg  20180504172634183370.jpg  20180510165946326882.png  20180515100309974224.png
20180428120506834278.jpg  20180503105350096980.png  20180503123549638868.png  20180503135845444243.png  20180503153119032462.jpg  20180504115041780679.jpg  20180504172739446406.jpg  20180510170000883910.png  20180515101627862971.png
20180428120759467189.jpg  20180503105553595891.txt  20180503124856857812.png  20180503140000035940.png  20180503153858556445.jpg  20180504115114842953.jpg  2018050417322546729.jpg   20180510170014895122.jpg  20180515102732738279.png
20180428120836170972.jpg  20180503112516938675.png  20180503124918949759.png  20180503140643997635.png  20180503154007183550.jpg  20180504115227816876.jpg  20180504175512363259.jpg  20180510170028731721.jpg  20180515103238561509.png
20180428121106825248.jpg  20180503112800561585.png  20180503125124155430.png  20180503140803692109.png  20180503155138478341.jpg  20180504115559724856.jpg  20180504181041667857.jpg  2018051017110829167.png   20180515103822699619.png
20180428142928142350.jpg  20180503113315568287.png  20180503125146198840.png  20180503140844160699.png  20180503155215376605.jpg  20180504115851041980.jpg  20180504182340754177.jpg  201805101711532413.jpg    20180515104302200943.png
20180428143144053113.jpg  20180503113340177304.png  20180503125234137231.png  20180503140850811284.png  20180503155413262760.jpg  20180504124000965117.jpg  20180504182721751873.jpg  20180510171217809702.jpg  20180515173900150773.png
20180428143511609876.jpg  20180503113540889585.png  20180503125317371246.png  20180503141250053511.png  20180503160012380142.jpg  20180504143411680467.jpg  20180504184424844985.jpg  20180511155233591987.jpg  20180516142601347497.png
20180428143701975532.jpg  20180503113622747675.png  20180503125429621246.png  2018050314162540750.png   20180503161337421993.jpg  20180504144228098566.jpg  20180507120503685564.png  20180511155421343984.jpg  20180518155240109825.png
20180428143753463104.jpg  20180503114302753620.png  20180503125612074698.png  20180503141630126214.png  20180503161639457248.jpg  20180504145900031454.jpg  20180507121119930691.png  20180511155508163733.png  20180518155659402994.png
20180428143949763466.jpg  20180503114704582415.png  2018050312564058336.png   20180503141634831689.png  20180503162125501895.jpg  20180504150020163627.jpg  2018050712135390043.png   20180511160410283600.png  20180518155936698602.jpg
2018042815193138872.jpg   20180503115213554499.png  20180503125908553267.png  20180503142037861616.png  20180503162155798106.jpg  20180504151434770809.jpg  20180507122346529893.png  20180511170658464210.png  20180518155954983586.jpg
20180428152646455694.jpg  20180503115411345865.png  20180503133222177944.png  20180503142046269156.png  20180503162553864987.jpg  20180504151953494341.jpg  20180507122641960158.png  20180511181559935780.jpg  20180518160123849368.png
20180428153349611431.jpg  20180503115523874309.png  20180503134150205479.png  20180503142130532478.png  20180503162703833497.jpg  20180504152950708380.jpg  20180509153819107909.jpg  20180511181619615275.png  20180518160142449575.jpg
201804281657209049