CentOS7安装NFS
一.环境
服务器192.168.7.11
客户端192.168.7.12
系统版本:CentOS Linux release 7.9.2009
### 服务器端磁盘分区挂载:
parted /dev/sdb mklabel gpt mkpart sdb1 xfs 1 27.3T
mkfs.xfs /dev/sdb1
mount /dev/sdb1 /data
二.服务器端
1.安装nfs
yum -y install nfs-utils
2.启动rpc服务
systemctl start rpcbind
[root@nfs ~]# ss -ntpl |grep 111
LISTEN 0 128 *:111 *:* users:(("rpcbind",pid=17446,fd=8))
LISTEN 0 128 [::]:111 [::]:* users:(("rpcbind",pid=17446,fd=11))
注意:centos7自带rpcbind,所以不用安装rpc服务(监听111端口)
3.编辑配置文件/etc/exports,添加内容/data/linux *(rw,async)。
4.查看配置权限:
[root@nfs ~]# exportfs -v
/data <world>(async,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)
5.启动nfs服务
systemctl start nfs
6.使用rpcinfo查看。
[root@nfs ~]# rpcinfo -p
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 57980 status
100024 1 tcp 56488 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 57531 nlockmgr
100021 3 udp 57531 nlockmgr
100021 4 udp 57531 nlockmgr
100021 1 tcp 38499 nlockmgr
100021 3 tcp 38499 nlockmgr
100021 4 tcp 38499 nlockmgr
7.使用showmount查看。
[root@nfs ~]# showmount -e
Export list for nfs:
/data/linux *
8.创建测试文件,并修改文件夹属主属组。
[root@nfs ~]# touch /data/linux/nfs.txt
[root@nfs ~]# echo "this is nfserver" >>/data/linux/nfs.txt
[root@nfs ~]# chown -R nfsnobody.nfsnobody /data/linux/
三.客户端配置。
1.安装nfs
yum -y intall nfs-utils
2.启动rpc服务
systemctl start rpcbind
3.查看服务器的共享目录
[root@ansible shell]# showmount -e 192.168.7.11
Export list for 192.168.7.11:
/data/linux *
4.挂载到本地mnt
[root@ansible shell]# mount -t nfs 192.168.7.11:/data/linux /mnt
[root@ansible shell]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/sdb1 xfs 3.0T 5.9G 3.0T 1% /
devtmpfs devtmpfs 17G 0 17G 0% /dev
tmpfs tmpfs 17G 0 17G 0% /dev/shm
tmpfs tmpfs 17G 19M 17G 1% /run
tmpfs tmpfs 17G 0 17G 0% /sys/fs/cgroup
/dev/sda2 xfs 521M 27M 495M 6% /home
/dev/sda1 xfs 2.2G 144M 2.0G 7% /boot
tmpfs tmpfs 3.4G 0 3.4G 0% /run/user/0
192.168.7.11:/data/linux nfs4 28T 35M 28T 1% /mnt
5.验证。
[root@ansible shell]# cd /mnt/
[root@ansible mnt]# ll
total 4
-rw-r--r--. 1 nfsnobody nfsnobody 17 May 11 16:54 nfs.txt
[root@ansible mnt]# cat nfs.txt
this is nfserver
[root@ansible mnt]# touch 123
[root@ansible mnt]# rm -rf 123
浙公网安备 33010602011771号