nfs 共享挂载 常用命令及安装方式
cat /etc/issue 或cat /etc/redhat-release
1:配置共享⽬目录
/etc/exports
#/opt/app/tools/apache-tomcat-8.5.9/webapps/QAAutomationWeb/result10.221.198.162(rw,sync,no_root_squash)/opt/app/tools/apache-tomcat-8.5.9/webapps/QAAutomationWeb/result10.221.198.162(rw)
2:exports⽬目录⽣生效
exportfs -a
[root@T-RHEL6U5 webapps]# exportfs -v
/DATA/app/tools/apache-tomcat-8.5.9/webapps/QAAutomationWeb/result 10.221.198.162(rw,wdelay,root_squash,no_subtree_check)
3:portmap注册的程序的信息
rpcinfo -p localhost
rpcinfo实⽤用⼯工具显示那些使⽤用portmap注册的程序的信息,并向程序进⾏行行RPC调⽤用,检查它们是否正常运⾏行行。
4:安装nfs服务,检测安装是否成功
yum install nfs-utils rpcbindrpm -q rpcbind nfs-utils
5:启动nfs服务相关程序
rpcbind和nfs服务均启动成功后,执⾏行行showmount -e可查看本机当前已发布的共享资源列列表:
service rpcbind start
service nfs start
chkconfig rpcbind on //设置开机启动服务
chkconfig nfs onchkconfig --list rpcbind //确保服务开机启动
rpcbind 0:off1:off2:on3:on4:on5:on6:off
chkconfig --list nfsnfs 0:off1:off2:on3:on4:on5:on6:off
showmount -e localhost //查看本机发布共享资源
Export list for localhost:/nfstest 192.168.100.2
6:设置开机⾃自动挂载nfs共享资源
[root@client01 ~]# vim /etc/fstab
192.168.100.1:/nfstest /mnt nfs defaults 0 0 //⽂文件类型为nfs
[root@client01 ~]# umount /mnt
[root@client01 ~]# mount -a
[root@client01 ~]# mount | tail -n 1
192.168.100.1:/nfsteston/mnt type nfs
(rw,vers=4,addr=192.168.100.1,clientaddr=192.168.100.2)
//开机⾃自动挂载成功
7:mount挂载命令
[root@T-RHEL6U5 ~]# mount -t nfs 10.221.198.89:/opt/app/tools/apache-tomcat-8.5.9/webapps/QAAutomationWeb/result /DATA/app/shared
[root@T-RHEL6U5 ~]# df -hv
Filesystem Size Used Avail Use%
Mounted on
/dev/mapper/vg_root-lv_root 3.0G 305M 2.6G11%
/tmpfs 1.9G 72K 1.9G 1%/dev/shm/dev/vda1 485M 56M 404M 13%/boot/dev/mapper/vg_root-lv_home 1008M 34M924M 4% /home/dev/mapper/vg_root-lv_opt 1008M 34M924M 4% /opt/dev/mapper/vg_root-lv_adm 5.0G 139M4.6G 3% /opt/adm/dev/mapper/vg_root-lv_tmp 1008M 34M
924M 4% /tmp/dev/mapper/vg_root-lv_usr 6.0G 2.5G 3.2G45% /usr/dev/mapper/vg_root-lv_var 4.0G 292M 3.5G8% /var/dev/mapper/vg_dev-dev 40G 652M 37G2% /DATA10.221.198.89:/opt/app/tools/apache-tomcat-8.5.9/webapps/QAAutomationWeb/result 40G 4.3G 34G 12%/DATA/app/shared
8:更改nfs服务的配置文件
vi /etc/sysconfig/nfs
需要打开下面的端口
a] TCP/UDP 111 – RPC 4.0 portmapper
b] TCP/UDP 2049 – NFSD (nfs server)
c] Portmap 静态端又—在/etc/sysconfig/nfs文件中定义的一系列TCP/UDP端又按nfs默认启动的话,很多服务如rpc.mounted,端又都不是固定的,这样不方便在防火墙上进行管理,所以我们需要把每个启动的服务的端又固定下来,需要做的就是编辑/etc/sysconfig/nfs文件.1. # vi /etc/sysconfig/nfs更改下面的配置,将端又分配为一个没被占用的1. # TCP port rpc.lockd should listen on.2. LOCKD_TCPPORT=lockd-port-number3. # UDP port rpc.lockd should listen on.4. LOCKD_UDPPORT=lockd-port-number5. # Port rpc.mountd should listen on.6. MOUNTD_PORT=mountd-port-number7. # Port rquotad should listen on.8. RQUOTAD_PORT=rquotad-port-number9. # Port rpc.statd should listen on.10. STATD_PORT=statd-port-number11. # Outgoing port statd should used. The default is port israndom12. STATD_OUTGOING_PORT=statd-outgoing-port-numbe下面是我用于测试的机器上修改的内容1. RQUOTAD_PORT=60052. LOCKD_TCPPORT=60043. LOCKD_UDPPORT=6004
4. MOUNTD_PORT=60025. STATD_PORT=60036. STATD_OUTGOING_PORT=6006保存退出后就可以重启nfs服务,portmap服务1. # service portmap restart2. # service nfs restart