nfs 安装日记
NFS是Net File System的简写,即网络文件系统.
网络文件系统是FreeBSD支持的文件系统中的一种,也被称为NFS. NFS允许一个系统在网络上与它人共享目录和文件。通过使用NFS,用户和程序可以象访问本地文件一样访问远端系统上的文件。
服务器端
1) yum install nfs-*
启动nfs
service portmap start
service nfs start
查看nfs是否启动
netstat -tunlp
opt]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN 2536/dovecot
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 2394/xinetd
tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN 2536/dovecot
tcp 0 0 0.0.0.0:646 0.0.0.0:* LISTEN 26754/rpc.rquotad
tcp 0 0 127.0.0.1:10024 0.0.0.0:* LISTEN 2600/amavisd (maste
tcp 0 0 127.0.0.1:10025 0.0.0.0:* LISTEN 29440/master
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2506/mysqld
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN 29440/master
tcp 0 0 0.0.0.0:750 0.0.0.0:* LISTEN 26859/rpc.mountd
tcp 0 0 0.0.0.0:50990 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 2536/dovecot
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 26684/portmap
tcp 0 0 127.0.0.1:10031 0.0.0.0:* LISTEN 13216/policyd
tcp 0 0 127.0.0.1:783 0.0.0.0:* LISTEN 2561/spamd.pid
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 2536/dovecot
tcp 0 0 127.0.0.1:2000 0.0.0.0:* LISTEN 2819/python
tcp 0 0 0.0.0.0:465 0.0.0.0:* LISTEN 29440/master
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 29440/master
tcp 0 0 :::587 :::* LISTEN 29440/master
tcp 0 0 :::80 :::* LISTEN 2694/httpd
tcp 0 0 :::465 :::* LISTEN 29440/master
tcp 0 0 :::22 :::* LISTEN 2378/sshd
tcp 0 0 :::25 :::* LISTEN 29440/master
tcp 0 0 :::443 :::* LISTEN 2694/httpd
udp 0 0 0.0.0.0:2049 0.0.0.0:* -
udp 0 0 0.0.0.0:643 0.0.0.0:* 26754/rpc.rquotad
udp 0 0 0.0.0.0:1194 0.0.0.0:* 2355/openvpn
udp 0 0 0.0.0.0:32814 0.0.0.0:* -
udp 0 0 0.0.0.0:747 0.0.0.0:* 26859/rpc.mountd
udp 0 0 0.0.0.0:111 0.0.0.0:* 26684/portmap
主要是111 和2049
其他rpc.daemons启动的端口则是随即产生的 因此需要向port 111注册
查看rpc服务的注册情况
rpcinfo -p 192.168.1.238
[root@mail opt]# rpcinfo -p 192.168.1.238
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100011 1 udp 643 rquotad
100011 2 udp 643 rquotad
100011 1 tcp 646 rquotad
100011 2 tcp 646 rquotad
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100021 1 udp 32814 nlockmgr
100021 3 udp 32814 nlockmgr
100021 4 udp 32814 nlockmgr
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100021 1 tcp 50990 nlockmgr
100021 3 tcp 50990 nlockmgr
100021 4 tcp 50990 nlockmgr
100005 1 udp 747 mountd
100005 1 tcp 750 mountd
100005 2 udp 747 mountd
100005 2 tcp 750 mountd
100005 3 udp 747 mountd
100005 3 tcp 750 mountd
2) vi /etc/exports
[root@mail scenic]# cat /etc/exports
/opt/webnfs/images 192.168.1.239/24(rw,sync)
/opt/webnfs/commonupload 192.168.1.239/24(rw,sync)
/opt/webnfs/scenic 192.168.1.239/24(rw,sync)
/opt/webnfs/scenic 192.168.1.240/24(rw,sync)
/opt/webnfs/images 192.168.1.240/24(rw,sync)
/opt/webnfs/commonupload 192.168.1.240/24(rw,sync)
3)cd /opt
chown nfsnobody:nfsnobody /opt/webnfs/images
/opt/webnfs/commonupload
/opt/webnfs/scenic
chmod 777 /opt/webnfs/images
/opt/webnfs/commonupload
/opt/webnfs/scenic
4)showmount -e 192.168.1.238 # 显示目前主机与客户端的NFS联机共享状态
[root@mail opt]# showmount -e 192.168.1.238
Export list for 192.168.1.238:
/opt/webnfs/scenic 192.168.1.240/24,192.168.1.239/24
/opt/webnfs/images 192.168.1.240/24,192.168.1.239/24
/opt/webnfs/commonupload 192.168.1.240/24,192.168.1.239/24
5)如果重新添加nfs共享或者修改/etc/exports文件 就需要执行命令 exportfs [-arur]
[root@mail webnfs]# exportfs -r
[root@mail webnfs]# exportfs
/opt/webnfs/commonupload 192.168.1.239/24
/opt/webnfs/commonupload 192.168.1.240/24
/opt/webnfs/images 192.168.1.239/24
/opt/webnfs/images 192.168.1.240/24
/opt/webnfs/scenic 192.168.1.239/24
/opt/webnfs/scenic 192.168.1.240/24
6)关于NFS服务器关机/重启前的注意事项:
在关机或重启前应该先关闭portmap和nfs这两个daemon 如果无法正常关闭,可查找PID,再Kill的方式将它关掉。
也可无使用 showmount -a 192.168.1.238的方式查处还有那个客户端在联机
[root@mail opt]# showmount -a 192.168.1.238
All mount points on 192.168.1.238:
192.168.1.239:/opt/webnfs/commonupload
192.168.1.239:/opt/webnfs/images
192.168.1.239:/opt/webnfs/scenic
192.168.1.240:/opt/webnfs/commonupload
192.168.1.240:/opt/webnfs/images
192.168.1.240:/opt/webnfs/scenic
客户端
1) 确认本地端已经启动了portmap服务
service portmap start
service nfslock start
2) 扫面NFS服务器共享目录有哪些 (showmount)
[root@mail opt]# showmount -a 192.168.1.238
All mount points on 192.168.1.238:
192.168.1.239:/opt/webnfs/commonupload
192.168.1.239:/opt/webnfs/images
192.168.1.239:/opt/webnfs/scenic
192.168.1.240:/opt/webnfs/commonupload
192.168.1.240:/opt/webnfs/images
192.168.1.240:/opt/webnfs/scenic
3) 在本地端创建预计挂载的挂载点目录
先备份mv
/usr/local/www/
/usr/local/www/source.test.com/commonupload/commonupload
/usr/local/www/source.test.com/commonupload/images
至/opt/wwwback
然后重新创建相关目录 mkdir
/usr/local/www/
/usr/local/www/source.test.com/commonupload/commonupload
/usr/local/www/source.test.com/commonupload/images
4) 利用mount将远程主机直接挂在之相关目录
挂载:
mount -t nfs 192.168.1.238:/opt/webnfs/commonupload /usr/local/www/source.test.com/commonupload/commonupload
mount -t nfs 192.168.1.238:/opt/webnfs/images /usr/local/www/source.test.com/commonupload/images
mount -t nfs 192.168.1.238:/opt/webnfs/scenic /usr/local/www//
卸载:
umount /usr/local/www/
umount /usr/local/www/source.test.com/commonupload/commonupload
umount /usr/local/www/source.test.com/commonupload/images
阅读(789) | 评论(0) | 转发(0) |