centos nfs 文件共享

文件共享服务端
 
查看是否已安装服务
[root@bogon ~]# rpm -qa | grep nfs
[root@bogon ~]# rpm -qa | grep rpcbind
[root@bogon ~]# 
1、安装nfs服务
[root@localhost home]# yum install -y nfs-utils
 
2、修改/etc/exports文件
[root@localhost home]# vi /etc/exports
加上: /home/testnfs 172.26.167.140(rw,sync,no_root_squash)
 
3、启动服务
[root@localhost home]# systemctl start rpcbind
[root@localhost home]# systemctl start nfs
 
4、查看发布的共享目录
[root@localhost home]# showmount -e localhost
Export list for localhost:
/home/testnfs 172.26.167.140
[root@localhost home]# 
 
5、查看RPC服务注册情况
[root@localhost home]# 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
100024 1 udp 38490 status
100024 1 tcp 49260 status
100005 1 udp 20048 mountd
100005 1 tcp 20048 mountd
100005 2 udp 20048 mountd
100005 2 tcp 20048 mountd
100005 3 udp 20048 mountd
100005 3 tcp 20048 mountd
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100227 3 tcp 2049 nfs_acl
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100227 3 udp 2049 nfs_acl
100021 1 udp 53678 nlockmgr
100021 3 udp 53678 nlockmgr
100021 4 udp 53678 nlockmgr
100021 1 tcp 39161 nlockmgr
100021 3 tcp 39161 nlockmgr
100021 4 tcp 39161 nlockmgr
[root@localhost home]#
 
6、关闭防火墙 或者 开发相应端口 111、20048
[root@localhost home]# systemctl stop firewalld
 
文件共享客户端
 
1、安装nfs服务
[root@localhost home]# yum install -y nfs-utils
 
2、查看服务端发布的共享目录
[root@localhost nfs]# showmount -e 172.26.174.39
Export list for 172.26.174.39:
/home/testnfs 172.26.167.140
[root@localhost nfs]#
 
3、设置永久挂载
[root@localhost nfs]# vi /etc/fstab
末尾加上: 172.26.174.39:/home/testnfs /home/nfs nfs rw,_netdev 0 0
 
4、重启客户端,挂载生效。在客户端可以读取、修改共享服务端的文件
 
posted @ 2021-10-15 10:03  ShuChang  阅读(253)  评论(0编辑  收藏  举报