标签:查看系统 touch set 递归 selinux df -h 相关 ice 主程序
1.环境准备以用户名[root@doudou ~] ip:192.168.24.181/24为服务端
以用户名[root@linfan ~] ip:192.168.24.132/24为客户端
[root@doudou ~]# systemctl disable firewalld
[root@doudou ~]# systemctl stop firewalld
[root@doudou ~]# sed -ri ‘#^SELINUX=#cDELINUX=Disabled‘ /etc/selinux/config
[root@doudou ~]# setenforce 0
[root@doudou ~]# yum -y install nfs-utils rpcbind
[root@doudou ~]# systemctl start rpcbind
[root@doudou ~]# systemctl enable rpcbind
[root@doudou ~]# systemctl start nfs-server
[root@doudou ~]# systemctl enable nfs-server
[root@doudou ~]# 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@doudou ~]# ps -ef | egrep "rpc|nfs"
编辑nfs主配置文件,共享目录linfan至192.168.24.132/24,可读写,统一用户
[root@doudou ~]# vi /etc/exports
/data 192.168.24.132/24(rw,sync,all_squash)
创建需要共享的目录
[root@doudou ~]# mkdir /data
重启NFS-server服务,查看共享文件是否存在
[root@doudou ~]# systemctl restart nfs-server
[root@doudou ~]# cat /var/lib/nfs/etab
/data 192.168.24.132/24(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=65534,anongid=65534,sec=sys,secure,root_squash,all_squash)
nfs统一给客户端为65534用户权限,查看65534属于哪个用户,递归赋予data目录nfsnobody
[root@doudou ~]# grep "65534" /etc/passwd
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
[root@doudou ~]# chown -R nfsnobody.nfsnobody /data/
[root@doudou ~]# ls /data/ -dl
drwxr-xr-x. 2 nfsnobody nfsnobody 6 Aug 2 16:12 /data/
[root@doudou ~]# systemctl restart nfs-server
[root@linfan ~]# systemctl stop firewalld
[root@linfan ~]# systemctl disable firewalld
[root@doudou ~]# sed -ri ‘#^SELINUX=#cDELINUX=Disabled‘ /etc/selinux/config
[root@doudou ~]# setenforce 0
[root@linfan ~]# yum -y install nfs-utils rpcbind
[root@linfan ~]# systemctl enable rpcbind
[root@linfan ~]# systemctl start rpcbind
[root@linfan ~]# showmount -e 192.168.24.181
Export list for 192.168.24.181:
/data 192.168.24.132/24
[root@linfan ~]# mount -t nfs 192.168.24.181:/data /mnt
[root@linfan ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 17G 6.0G 12G 35% /
devtmpfs 478M 0 478M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 26M 464M 6% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 1014M 125M 890M 13% /boot
tmpfs 98M 0 98M 0% /run/user/0
192.168.24.181:/data 17G 1.8G 16G 11% /mnt
## [root@linfan ~]# ls /mnt/
[root@linfan ~]# cd /mnt/
[root@linfan mnt]# touch hello
[root@linfan mnt]# ls
hello
[root@doudou ~]# ls /data
hello
标签:查看系统 touch set 递归 selinux df -h 相关 ice 主程序
原文地址:http://blog.51cto.com/13858192/2153718