linux添加nfs路径,Linux服务NFS配置详细步骤
1.环境准备以用户名[root@doudou ~] ip:192.168.24.181/24为服务端以用户名[root@linfan ~] ip:192.168.24.132/24为客户端服务端配置2.基础环境配置关闭firewalld防火墙[root@doudou ~]# systemctl disable firewalld[root@doudou ~]# systemctl stop fir
1.环境准备
以用户名[root@doudou ~] ip:192.168.24.181/24为服务端
以用户名[root@linfan ~] ip:192.168.24.132/24为客户端
服务端配置
2.基础环境配置
关闭firewalld防火墙
[root@doudou ~]# systemctl disable firewalld
[root@doudou ~]# systemctl stop firewalld
关闭selinux
[root@doudou ~]# sed -ri '#^SELINUX=#cSELINUX=Disabled' /etc/selinux/config
[root@doudou ~]# setenforce 0
安装NFS-Server
//安装nfs服务主程序
[root@doudou ~]# yum -y install nfs-utils rpcbind
3.启动NFS-server
//启动rpcbind服务,并查看rpc注册信息
[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
4.查看系统中运行的NFS相关进程
[root@doudou ~]# ps -ef | egrep "rpc|nfs"
5.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/
重启nfs-server服务生效
[root@doudou ~]# systemctl restart nfs-server
客户端
1.关闭防火墙,关闭selinux
[root@linfan ~]# systemctl stop firewalld
[root@linfan ~]# systemctl disable firewalld
[root@doudou ~]# sed -ri '#^SELINUX=#cSSELINUX=Disabled' /etc/selinux/config
[root@doudou ~]# setenforce 0
2.安装相关服务,仅启动rpcbind服务即可
[root@linfan ~]# yum -y install nfs-utils rpcbind
[root@linfan ~]# systemctl enable rpcbind
[root@linfan ~]# systemctl start rpcbind
3.客户端查看远程服务器提供可挂载信息
[root@linfan ~]# showmount -e 192.168.24.181
Export list for 192.168.24.181:
/data 192.168.24.132/24
4.客户端挂载共享data
[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
5.测试nfs是否成功
客户端操作
在客户端mnt下创建一个文件hello
## [root@linfan ~]# ls /mnt/
[root@linfan ~]# cd /mnt/
[root@linfan mnt]# touch hello
[root@linfan mnt]# ls
hello
服务端操作
在服务端查看data下是否存在文件hello
[root@doudou ~]# ls /data
hello
更多推荐
所有评论(0)