centos 7.9部署nfs
一、 前言
StorageClass
在centos
上使用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) | 客户端 |
# 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
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)
# 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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?