1.NFS服務部署服務準備:兩臺安裝了centos 6.7服務器(假如是虛擬機也可)。centos
查看服務器版本:[root@nfsSERVER]# cat /etc/redhat-release
CentOS release 6.7 (Final)服務器
[root@nfsSERVER ~]# uname -r
2.6.32-573.18.1.el6.x86_64
[root@nfsSERVER ~]# uname -m
x86_64
app
[root@NFSCLIENT ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)tcp
前期把服務器端和客戶端分清楚,不要混亂。能夠用hostname 名字 更改服務器的名稱。server
2.服務器端的安裝與配置:NFS服務有兩個軟件包,一個是nfs-utils 是NFS服務主程序,另外一個是 rpcbind。ip
經過「[root@nfsSERVER ~]# ,也可「yum groupinstall "NFS file server" 」安裝。ci
安裝好事後再檢查一下。我用的是「[root@nfsSERVER ~]# rpm -aq nfs-utils portmap rpcbind
rpcbind-0.2.0-11.el6_7.x86_64
nfs-utils-1.2.3-64.el6.x86_64」檢查。rpc
[root@nfsSERVER ~]# service iptables stop #關閉防火牆#
部署
服務器端啓動nfs服務:[root@nfsSERVER ~]# /etc/init.d/rpcbind start #啓動RPC服務#虛擬機
[root@nfsSERVER ~]# ps -ef|grep rpc #查看RPC服務的啓動#
rpc 1291 1 0 19:11 ? 00:00:00 rpcbind
rpcuser 1313 1 0 19:11 ? 00:00:00 rpc.statd
root 1527 2 0 19:11 ? 00:00:00 [rpciod/0]
root 2628 1 0 20:36 ? 00:00:00 rpc.rquotad
root 2633 1 0 20:36 ? 00:00:00 rpc.mountd
root 2680 1 0 20:36 ? 00:00:00 rpc.idmapd
root 3478 3317 0 21:57 pts/0 00:00:00 grep rpc
[root@nfsSERVER ~]# /etc/init.d/rpcbind status #查看啓動狀態#
rpcbind (pid 1291) is running... #啓動成功#
[root@nfsSERVER ~]# rpcinfo -p localhost #查看RPC的端口(默認)#
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmappe
[root@nfsSERVER ~]# /etc/init.d/nfs start #啓動NFS服務#
[root@nfsSERVER ~]# chkconfig nfs on #設置NFS開機自啓動#
[root@nfsSERVER ~]# chkconfig rpcbind on #設置RPC開機自啓動#
[root@nfsSERVER ~]# chkconfig --list nfs #檢查NFS是否啓動#
nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@nfsSERVER ~]# chkconfig --list rpcbind #檢查RPC是否啓動#
rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
RPC先啓動,NFS先中止。
[root@nfsSERVER ~]# mkdir /opt/centos6 -p #建立一個共享的文件夾#
客服端NFS安裝配置;[root@NFSCLIENT ~]# yum install nfs-utils rpcbind -y 進行安裝。
[root@NFSCLIENT ~]# service iptables stop #關閉防火牆#
[root@NFSCLIENT ~]# /etc/init.d/rpcbind start #啓動RPC服務#
[root@NFSCLIENT ~]# /etc/init.d/nfs start #啓動NFS服務#
[root@NFSCLIENT ~]# chkconfig nfs on #設置開機自啓動#
[root@NFSCLIENT ~]# chkconfig rpcbind on #設置開機自啓動#
3.配置服務:[root@nfsSERVER ~]# ll /etc/exports #nfs配置文件#
[root@nfsSERVER ~]# vi /etc/exports #配置NFS#
-rw-r--r--. 1 root root 74 Apr 14 20:35 /etc/exports
##nfs server 20160414##
/opt/centos6 192.168.204.131/24(rw,sync) #文件名 共享電腦的地址 權限 寫入磁盤#
[root@nfsSERVER ~]# /etc/init.d/nfs reload #平滑重啓#
[root@nfsSERVER ~]# showmount -e localhost #檢查本機#
Export list for localhost:
/opt/centos6 192.168.204.131/24
[root@NFSCLIENT ~]# showmount -e 192.168.204.131 #客服端檢查#
Export list for 192.168.204.131:
/opt/centos6 192.168.204.131/24
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 4.2G 14G 24% /
tmpfs 497M 72K 497M 1% /dev/shm
/dev/sda1 190M 36M 145M 20% /boot
[root@NFSCLIENT ~]# mount -t nfs 192.168.204.131:/opt/centos6 /mnt #進行掛載,掛載到/mnt下或者別的路勁均可以#
[root@nfsSERVER ~]# chmod 777 /opt/centos6 #權限設置,有的時候會出現權限不夠,能夠更改下權限#。