14.4 exportfs命令
14.5 NFS客户端问题
15.1 FTP介绍
15.2/15.3 使用vsftpd搭建ftp
14.4 exportfs命令:
exportfs命令是跟nfs-utils包一起安装的
应用场景:我们共享了一个目录,需要更改或者增加目录,就需要更改配置文件和重启NFS服务。如果远程客户端正在挂载着使用着,如果停掉远程客户端就会挂起(nginx或者php),这个影响会很大。就是D进程不可中断的进程。只能先卸载下来(umount)在重启NFS,但有几十台机器就不合适了。就会使用exportfs
~~1.
exportfs常用选项
-a 全部挂载或者全部卸载
一般使用 -arv,就会让配置文件生效
-r 重新挂载
-u 卸载某一个目录
-v 显示共享目录
以下操作在服务端上
vim /etc/exports //增加
/tmp/ 192.168.30.0/24(rw,sync,no_root_squash)
exportfs -arv //不用重启nfs服务,配置文件就会生效
~~2.
以下操作在客户端
mount -t nfs 192.168.30.134:/tmp /tmp
或mount -t nfs -o nfsvers=3 192.168.30.134:/tmp/ /mnt/ #(为解决已经出现nobody,下一节有讲)。要先umonut /mnt/
ls -l !$
-oremount,nfsvers=3 (-o重新挂在完以后,可以使用-oremount。不卸载的话不能直接-oremount)
实例:
~~1.
[root@afeilinux-01 ~]# vim /etc/exports 打开那个配置文件
/home/nfstestdir 192.168.30.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)
/tmp/ 192.168.30.134(rw,sync,no_root_squash) 在下面加入一行配置,选了no_root_squash(不限制root)此时写的是服务端的IP
[root@afeilinux-01 ~]# exportfs -arv 再exportfs -arv 重新加载显示共享目录
报错
exportfs: No options for /home/nfstestdir : suggest (sync) to avoid warning
exportfs: No options for 192.168.30.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000) : suggest (sync) to avoid warning
exportfs: No options for 192.168.30.134/24(rw,sync,no_root_squash,no_subtree_check) : suggest (sync) to avoid warning
exporting :192.168.30.134/24(rw,sync,no_root_squash,no_subtree_check)
exportfs: Failed to stat 192.168.30.134/24(rw,sync,no_root_squash,no_subtree_check): No such file or directory
exporting :192.168.30.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)
exportfs: Failed to stat 192.168.30.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000): No such file or directory
exporting :/home/nfstestdir
检查配置文件
[root@afeilinux-01 ~]# vim /etc/exports
/home/nfstestdir 192.168.30.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)
/tmp/ 192.168.30.134/24(rw,sync,no_root_squash)
发现第一行配置文件只能写成一行,两行会报错。第二行少了/。
exporting 192.168.30.134/24:/tmp
exporting 192.168.30.0/24:/home/nfstestdir
显示有了
双方关闭防火墙和selinux,不然会报错
cat /var/log/messages | grep mount
~~2.
[root@afeilinux-02 ~]# showmount -e 192.168.30.134 在02上showmount看一下有没有
Export list for 192.168.30.134:
192.168.30.134/24(rw,sync,no_root_squash) *
192.168.30.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000) *
/home/nfstestdir
[root@afeilinux-02 ~]# mount -t nfs 192.168.30.134:/tmp/ /mnt/ 在02上挂载到/mnt(这时的IP写的是服务端的,就是制定服务端的IP及共享的目录)到本机的/mnt
此时,02的/mnt就是01的/tmp
mount.nfs: /mnt is busy or already mounted