1. 程式人生 > >nfs共享服務搭建

nfs共享服務搭建

tin server fig serve restart 腳本 init.d 錯誤 res

[root@zhaoli Desktop]# uname -r
2.6.32-431.el6.x86_64
[root@zhaoli Desktop]# uname -m
x86_64

查看客戶端軟件是否安裝(環境準備)
1、服務端(server服務端)ip:192.168.2.68
[root@zhaoli Desktop]# rpm -aq nfs-utils portmap rpcbind   客戶端來查看是否安裝
nfs-utils-1.2.3-39.el6.x86_64
rpcbind-0.2.0-11.el6.x86_64
[root@zhaoli Desktop]# /etc/init.d/rpcbind start  利用腳本啟動或者停止服務
[root@zhaoli Desktop]# /etc/init.d/rpcbind stop
Stopping rpcbind:                                          [  OK  ]
[root@zhaoli Desktop]# /etc/init.d/rpcbind start
Starting rpcbind:                                          [  OK  ]
[root@zhaoli Desktop]# ps -ef|grep rpc   查看監聽端口號
rpcuser    1912      1  0 10:08 ?        00:00:00 rpc.statd
rpc        6585      1  0 14:01 ?        00:00:00 rpcbind
root       6616   3128  0 14:03 pts/0    00:00:00 grep rpc

[root@zhaoli data]# vim /etc/exports 
[root@zhaoli data]# cat /etc/exports 
#shared data for bbs zhaoli at 20171212  註釋行
/data 192.168.2.65/(rw,sync)  寫上共享的目錄,ip或者網段,共享目錄的權限

[root@zhaoli Desktop]# /etc/init.d/rpcbind status  查看服務狀態,運行中
rpcbind (pid  6585) is running...
[root@zhaoli Desktop]# rpcinfo -p localhost 查看房源
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
[root@zhaoli Desktop]# /etc/init.d/nfs start  啟動nfs服務
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]
[root@zhaoli Desktop]# chkconfig nfs on   設置開機自啟動
[root@zhaoli Desktop]# chkconfig rpcbind on

[root@zhaoli Desktop]# chkconfig --list nfs  查看服務狀態
nfs            	0:off	1:off	2:on	3:on	4:on	5:on	6:off
[root@zhaoli Desktop]# chkconfig --list rpcbind 
rpcbind        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
[root@xiaozhao data]# showmount -e localhost
如果有錯誤
# showmount -e localhost 報錯: 
clnt_create:RPC:Unknown host 
解決: 
# /etc/init.d/rpcsvrgssd status 
rpc.svrgssd is stopped 
# /etc/init.d/rpcsvrgssd start 
# /etc/init.d/nfs restart
=============================================================================
2、客戶端(client客戶端)ip:192.168.2.65
查看服務端軟件是否安裝
[root@xiaozhao Desktop]# rpm -aq nfs-utils portmap rpcbind
nfs-utils-1.2.3-39.el6.x86_64
rpcbind-0.2.0-11.el6.x86_64
[root@xiaozhao Desktop]# /etc/init.d/rpcbind start  只需要啟動bind服務
[root@xiaozhao Desktop]# /etc/init.d/rpcbind status  查看服務狀態
rpcbind (pid  1740) is running...   運行中
[root@xiaozhao Desktop]# chkconfig rpcbind on  開機自啟動
[root@xiaozhao Desktop]# chkconfig --list rpcbind  
rpcbind        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
 [root@xiaozhao data]# showmount -e 192.168.2.68  查看服務端的服務是啟動的
Export list for 192.168.2.68:
/data 192.168.2.65/

[root@xiaozhao data]# /etc/init.d/nfs reload   重啟服務
[root@xiaozhao data]# showmount -e localhost
[root@xiaozhao ~]# mount -t nfs 192.168.2.68:/data /mnt/  手動掛載到mnt共享目錄下
[root@xiaozhao mnt]# echo "mount -t nfs 192.168.2.68:/data /mnt" >>/etc/rc.local 開啟自啟動
如果客戶端沒有刪除寫的權限,就在服務端給data目錄授權

  

nfs共享服務搭建