作者:flymaster
qq:908601287
blog:http://www.cnblogs.com/flymaster500/
nfs
[root@flymaster ~]# rpm -qa nfs-utils rpcbind
nfs-utils-1.2.3-75.el6.x86_64
rpcbind-0.2.0-13.el6_9.1.x86_64
[root@flymaster ~]#
[root@flymaster ~]# /etc/init.d/rpcbind status
rpcbind 已停
[root@flymaster ~]# /etc/init.d/rpcbind start
Starting rpcbind: [ OK ]
[root@flymaster ~]# /etc/init.d/rpcbind status
rpcbind (pid 1632) is running...
[root@flymaster ~]# lsof -i :111
-bash: lsof: command not found
[root@flymaster ~]# yum install -y lsof
[root@flymaster ~]# lsof -i :111
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rpcbind 1632 rpc 6u IPv4 13600 0t0 UDP *:sunrpc
rpcbind 1632 rpc 8u IPv4 13603 0t0 TCP *:sunrpc (LISTEN)
rpcbind 1632 rpc 9u IPv6 13605 0t0 UDP *:sunrpc
rpcbind 1632 rpc 11u IPv6 13608 0t0 TCP *:sunrpc (LISTEN)
[root@flymaster ~]# netstat -lnup|grep rpcbind
udp 0 0 0.0.0.0:959 0.0.0.0:* 1632/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 1632/rpcbind
udp 0 0 :::959 :::* 1632/rpcbind
udp 0 0 :::111 :::* 1632/rpcbind
[root@flymaster ~]# chkconfig --list rpcbind
rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@flymaster ~]#
[root@flymaster ~]# 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@flymaster ~]# /etc/init.d/nfs status
rpc.svcgssd 已停
rpc.mountd is stopped
nfsd is stopped
[root@flymaster ~]# /etc/init.d/nfs start
Starting NFS services: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
正在启动 RPC idmapd: [确定]
[root@flymaster ~]# netstat -lntup|grep 2049
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp 0 0 :::2049 :::* LISTEN -
udp 0 0 0.0.0.0:2049 0.0.0.0:* -
udp 0 0 :::2049 :::*
[root@flymaster ~]# 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
100005 1 udp 32888 mountd
100005 1 tcp 34816 mountd
100005 2 udp 60305 mountd
100005 2 tcp 53106 mountd
100005 3 udp 60915 mountd
100005 3 tcp 43298 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 50673 nlockmgr
100021 3 udp 50673 nlockmgr
100021 4 udp 50673 nlockmgr
100021 1 tcp 60233 nlockmgr
100021 3 tcp 60233 nlockmgr
100021 4 tcp 60233 nlockmgr
[root@flymaster ~]# less /etc/init.d/nfs
#!/bin/sh
#
# nfs This shell script takes care of starting and stopping
# the NFS services.
#
# chkconfig: - 30 60
# description: NFS is a popular protocol for file sharing across networks.
# This service provides NFS server functionality, which is
# configured via the /etc/exports file.
# probe: true
# config: /etc/sysconfig/nfs
### BEGIN INIT INFO
# Provides: nfs
# Required-Start: $local_fs $network $syslog $rpcbind
# Required-Stop: $local_fs $network $syslog $rpcbind
# Default-Stop: 0 1 6
# Short-Description: Start up the NFS server sevice
# Description: NFS is a popular protocol for file sharing across networks
# This service provides NFS server functionality,
# which is configured via the /etc/exports file.
### END INIT INFO
[root@flymaster ~]# ps -ef|egrep "rpc|nfs"
root 1734 2 0 15:23 ? 00:00:00 [rpciod/0]
root 1943 1 0 15:27 ? 00:00:00 rpc.mountd
root 1950 2 0 15:27 ? 00:00:00 [nfsd4]
root 1951 2 0 15:27 ? 00:00:00 [nfsd4_callbacks]
root 1952 2 0 15:27 ? 00:00:00 [nfsd]
root 1953 2 0 15:27 ? 00:00:00 [nfsd]
root 1954 2 0 15:27 ? 00:00:00 [nfsd]
root 1955 2 0 15:27 ? 00:00:00 [nfsd]
root 1956 2 0 15:27 ? 00:00:00 [nfsd]
root 1957 2 0 15:27 ? 00:00:00 [nfsd]
root 1958 2 0 15:27 ? 00:00:00 [nfsd]
root 1959 2 0 15:27 ? 00:00:00 [nfsd]
root 1986 1 0 15:27 ? 00:00:00 rpc.idmapd
rpc 2077 1 0 15:32 ? 00:00:00 rpcbind
root 2132 1445 0 15:55 pts/0 00:00:00 egrep rpc|nfs
[root@flymaster ~]# ls -l /etc/exports (nfs配置文件)
-rw-r--r--. 1 root root 0 Jan 12 2010 /etc/exports
echo "/data 192.168.1.*(insecure,rw,sync,no_root_squash)" >/etc/exports
[root@nfs-server101 ~]# mkdir /data
[root@nfs-server101 ~]# /etc/init.d/nfs reload(平滑生效)
[root@nfs-server101 ~]# exportfs -rv
exporting 192.168.1.*:/data
[root@nfs-server101 ~]# showmount -e 127.0.0.1
Export list for 127.0.0.1:
/data 192.168.1.*
[root@nfs-server101 ~]# mount -t nfs 192.168.70.101:/data /mnt
[root@nfs-server101 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_flymaster-lv_root
18G 977M 16G 6% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 477M 28M 425M 6% /boot
192.168.70.101:/data 18G 977M 16G 6% /mnt
[root@nfs-server101 ~]# touch /data/fly.txt
[root@nfs-server101 ~]# cd /mnt/
[root@nfs-server101 mnt]# ls
fly.txt
Export list for 192.168.70.101:
/data 192.168.70.*
[root@lamp102 /]# mount -t nfs 192.168.70.101:/data /mnt
[root@lamp102 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_flymaster-lv_root
18G 976M 16G 6% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 477M 28M 425M 6% /boot
192.168.70.101:/data 18G 977M 16G 6% /mnt
[root@lamp102 mnt]# grep 65534 /etc/passwd
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
作者:flymaster
qq:908601287
blog:http://www.cnblogs.com/flymaster500/