一、 前言

为了研究StorageClasscentos上使用nfs方式同步,所有节点都需要挂载目录。🧑‍💻🧑‍💻🧑‍💻

节点:

ip address hostname 系统 nfs服务
192.168.80.100 nfs01 CentOS Linux release 7.9.2009 (Core) 服务端
192.168.80.200 nfs02 CentOS Linux release 7.9.2009 (Core) 客户端

二、安装nfs

  • 所有主机操作

# 1.查看系统版本
cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
# 2.查看并关闭防火墙
systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld
# 3.永久关闭
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config

安装 NFS 和 RPC

  • 所有主机操作

rpm -qa | grep nfs
rpm -qa | grep rpcbind
yum install -y nfs-utils rpcbind

rpm -qa | grep nfs
nfs4-acl-tools-0.3.3-21.el7.x86_64
nfs-utils-1.3.0-0.68.el7.2.x86_64
libnfsidmap-0.25-19.el7.x86_64
rpm -qa | grep rpcbind
rpcbind-0.2.0-49.el7.x86_64

三、服务端配置

  • 192.168.80.100

mkdir -p /root/data/k8s
echo "/root/data/k8s *(rw,sync,no_root_squash,fsid=0)" >> /etc/exports
# 1.生效配置
exportfs -r
# 2.启动
systemctl enable rpcbind && systemctl start rpcbind
systemctl enable nfs && systemctl restart nfs
# 3.服务器注册端口:111
rpcinfo -p
# 4.查看是否成功
showmount -e localhost
Export list for localhost:
/root/data/k8s *

# 5.查看启动挂载
cat /var/lib/nfs/etab
/root/data/k8s       *(rw,sync,wdelay,hide,nocrossmnt,secure,no_root_squash,no_all_squash,no_subtree_check,secure_locks,acl,no_pnfs,fsid=0,anonuid=65534,anongid=65534,sec=sys,rw,secure,no_root_squash,no_all_squash)

四、客户端

  • 192.168.80.200

# 1.创建挂载目录
mkdir -p /root/data/k8s
# 2.查看挂载ip
showmount -e 192.168.80.100
# 3.挂载
mount -t nfs 192.168.80.100:/root/data/k8s /root/data/k8s
# 4.查看磁盘
df -h
Filesystem                Size  Used Avail Use% Mounted on
devtmpfs                  471M     0  471M   0% /dev
tmpfs                     487M     0  487M   0% /dev/shm
tmpfs                     487M  8.4M  478M   2% /run
tmpfs                     487M     0  487M   0% /sys/fs/cgroup
/dev/sda3                  78G  5.1G   73G   7% /
/dev/sda1                 297M  152M  145M  52% /boot
tmpfs                      98M   12K   98M   1% /run/user/42
tmpfs                      98M     0   98M   0% /run/user/0
192.168.80.200:/root/nfs/data   78G  5.2G   73G   7% /root/nfs/data
# 5.启动挂载
cat /etc/fstab
192.168.80.100:/root/nfs/data            /root/nfs/data           nfs     defaults        1 1

五、测试同步

# 1.客户端
cd /root/nfs/data && touch 1.txt
# 2.服务端
cd /root/nfs/data && ls 1.txt

 

原文地址:http://www.cnblogs.com/Mercury-linux/p/16927549.html

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长! 2. 分享目的仅供大家学习和交流,请务用于商业用途! 3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 如有链接无法下载、失效或广告,请联系管理员处理! 6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员! 8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载 声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性