|
服务器IP地址规划:
NFS服务端IP地址:192.168.10.106
NFS客户端IP地址: 192.168.10.183
一、NFS服务端部署:
[iyunv@oldboy ~]# hostname
nfsserver
[iyunv@oldboy ~]# logout
[oldboy@oldboy ~]$
[oldboy@oldboy ~]$ sudo su -
[iyunv@nfsserver ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[iyunv@nfsserver ~]# uname -r
2.6.32-431.el6.x86_64
[iyunv@nfsserver ~]# uname -m
x86_64
[iyunv@nfsserver ~]# rpm -qa nfs-utils portmap rpcbind
[iyunv@nfsserver ~]# yum -y install nfs-utils portmap rpcbind
[iyunv@nfsserver ~]# rpm -qa nfs-utils portmap rpcbind
rpcbind-0.2.0-11.el6.x86_64
nfs-utils-1.2.3-64.el6.x86_64
[iyunv@nfsserver ~]# /etc/init.d/rpcbind start
Starting rpcbind: [ OK ]
[iyunv@nfsserver ~]# ps -ef|grep rpcbind
rpc 3674 1 0 14:27 ? 00:00:00 rpcbind
root 3678 3460 0 14:27 pts/0 00:00:00 grep --color rpcbind
[iyunv@nfsserver ~]# /etc/init.d/rpcbind status
rpcbind (pid 3674) is running...
[iyunv@nfsserver ~]# 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
[iyunv@nfsserver ~]# /etc/init.d/rpcbind stop
Stopping rpcbind: [ OK ]
[iyunv@nfsserver ~]# rpcinfo -p localhost
rpcinfo: can't contact portmapper: RPC: Remote system error - Connection refused
[iyunv@nfsserver ~]#
[iyunv@nfsserver ~]# /etc/init.d/rpcbind start
Starting rpcbind: [ OK ]
[iyunv@nfsserver ~]# /etc/init.d/nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
[iyunv@nfsserver ~]# 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
100011 1 udp 875 rquotad
100011 2 udp 875 rquotad
100011 1 tcp 875 rquotad
100011 2 tcp 875 rquotad
100005 1 udp 49747 mountd
100005 1 tcp 4876 mountd
100005 2 udp 38193 mountd
100005 2 tcp 64733 mountd
100005 3 udp 33538 mountd
100005 3 tcp 49065 mountd
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100227 2 tcp 2049 nfs_acl
100227 3 tcp 2049 nfs_acl
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100227 2 udp 2049 nfs_acl
100227 3 udp 2049 nfs_acl
100021 1 udp 53540 nlockmgr
100021 3 udp 53540 nlockmgr
100021 4 udp 53540 nlockmgr
100021 1 tcp 42422 nlockmgr
100021 3 tcp 42422 nlockmgr
100021 4 tcp 42422 nlockmgr
[iyunv@nfsserver ~]#
[iyunv@nfsserver ~]# chkconfig nfs on
[iyunv@nfsserver ~]# chkconfig rpcbind on
[iyunv@nfsserver ~]# chkconfig --list nfs
nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[iyunv@nfsserver ~]# chkconfig --list rpcbind
rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[iyunv@nfsserver ~]# ll /etc/exports
-rw-r--r--. 1 root root 0 Jan 12 2010 /etc/exports
[iyunv@nfsserver ~]# ll /data
total 4
-rw-r--r-- 1 root root 0 Aug 27 00:05 a.txt
-rw-r--r-- 1 root root 0 Aug 27 00:09 b.txt
drwxr-xr-x 2 root root 4096 Sep 1 22:06 oldboy
[iyunv@nfsserver ~]# cat >>/etc/exports>>EOF
#shared /data for 192.168.10.0/24
/data 192.168.10.0/24(rw,sync)
EOF
[iyunv@nfsserver ~]# cat /etc/exports
#shared /data for 192.168.10.0/24
/data 192.168.10.0/24(rw,sync)
[iyunv@nfsserver ~]# /etc/init.d/nfs reload
[iyunv@nfsserver ~]# showmount -e localhost
Export list for localhost:
/data 192.168.10.0/24
[iyunv@nfsserver ~]# ls -ld /data
drwxr-xr-x. 3 root root 4096 Sep 1 21:51 /data
[iyunv@nfsserver ~]# chmod 777 /data
[iyunv@nfsserver ~]# ll /data
total 4
-rw-r--r-- 1 root root 0 Aug 27 00:05 a.txt
-rw-r--r-- 1 root root 0 Aug 27 00:09 b.txt
drwxr-xr-x 2 root root 4096 Sep 1 22:06 oldboy
-rw-r--r-- 1 nfsnobody nfsnobody 0 Sep 25 15:39 test.log
[iyunv@nfsserver ~]# ls -ld /data
drwxrwxrwx. 3 root root 4096 Sep 25 15:39 /data
[iyunv@nfsserver ~]# chown -R nfsnobody:nfsnobody /data
[iyunv@nfsserver ~]# ll /data
total 4
-rw-r--r-- 1 nfsnobody nfsnobody 0 Aug 27 00:05 a.txt
-rw-r--r-- 1 nfsnobody nfsnobody 0 Aug 27 00:09 b.txt
drwxr-xr-x 2 nfsnobody nfsnobody 4096 Sep 1 22:06 oldboy
二、NFS客户端部署:
Last login: Fri Sep 25 13:22:51 2015 from 192.168.10.113
[oldboy@clientserver ~]$ sudo su -
[iyunv@clientserver ~]# rpm -qa nfs-utils portmap rpcbind
[iyunv@clientserver ~]# yum -y install nfs-utils portmap rpcbind
[iyunv@clientserver ~]# rpm -qa nfs-utils portmap rpcbind
rpcbind-0.2.0-11.el6.x86_64
nfs-utils-1.2.3-64.el6.x86_64
[iyunv@clientserver ~]# /etc/init.d/rpcbind start
Starting rpcbind: [ OK ]
[iyunv@clientserver ~]# /etc/init.d/rpcbind status
rpcbind (pid 27339) is running...
[iyunv@clientserver ~]# chkconfig rpcbind on
[iyunv@clientserver ~]# chkconfig --list rpcbind
rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[iyunv@clientserver ~]# showmount -e 192.168.10.106
Export list for 192.168.10.106:
/data 192.168.10.0/24
[iyunv@clientserver ~]# mount -t nfs 192.168.10.106:/data /mnt
[iyunv@clientserver ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 7.7G 2.1G 5.3G 28% /
tmpfs 491M 0 491M 0% /dev/shm
/dev/sda1 194M 29M 155M 16% /boot
192.168.10.106:/data 7.7G 2.4G 5.0G 32% /mnt
[iyunv@clientserver ~]# cd /mnt/
[iyunv@clientserver mnt]# ll
total 4
-rw-r--r-- 1 root root 0 Aug 27 00:05 a.txt
-rw-r--r-- 1 root root 0 Aug 27 00:09 b.txt
drwxr-xr-x 2 root root 4096 Sep 1 22:06 oldboy
[iyunv@clientserver mnt]# touch test.log
[iyunv@clientserver mnt]# ll
total 4
-rw-r--r-- 1 root root 0 Aug 27 00:05 a.txt
-rw-r--r-- 1 root root 0 Aug 27 00:09 b.txt
drwxr-xr-x 2 root root 4096 Sep 1 22:06 oldboy
-rw-r--r-- 1 nfsnobody nfsnobody 0 Sep 25 15:39 test.log
|
|
|
|
|
|
|