ubuntu 20.04系统离线安装nfs
前提
OS:ubuntu 20.04 LTS
1,下载对应安装包
下载地址:
https://ubuntu.pkgs.org/20.04/ubuntu-updates-main-amd64/nfs-common_1.3.4-2.5ubuntu3.7_amd64.deb.html
也可以采用我整理好的资源:
https://download.csdn.net/download/m0_62464865/90424458
通过在无网络的机器上执行apt install nfs-kernel-server
可以查看对应的版本
- libtirpc-common 1.2.5-1ubuntu0.1
- libtirpc3 1.2.5-1ubuntu0.1
- rpcbind 1.2.5-8
- keyutils 1.6-6ubuntu1.1
- Libnfsidmap2 0.25-5.1ubuntu1
- nfs-commmon 1:1.3.4-2.5ubuntu3.7 amd64
- nfs-kernel-server 1:1.3.4-2.5ubuntu3.7 amd64
2,安装
sudo dpkg -i *.deb
3,配置NFS服务端
# 创建共享目录
sudo mkdir -p /nfs_share
sudo chmod 777 /nfs_share
# 编辑配置文件
sudo tee /etc/exports <<EOF
/nfs_share 192.168.0.0/16(rw,sync,no_subtree_check,no_root_squash)
EOF
# 启动服务(注意顺序)
sudo systemctl enable --now rpcbind
sudo systemctl enable --now nfs-server
上面的 /etc/exports中,可以通过来允许所有IP访问,如:
echo "/nfs_share \*(rw,sync,no_subtree_check,insecure)" | sudo tee -a /etc/exports
4,验证服务状态
# 检查服务进程
sudo rpcinfo -p | grep nfs
# 查看共享列表
sudo showmount -e localhost
# 预期输出:
# Export list for localhost:
# /nfs_share 192.168.0.0/16
5,客户端配置(在所有k8s节点执行)
5.1,安装客户端软件
# 仅安装客户端所需
sudo dpkg -i nfs-common_*.deb rpcbind_*.deb libtirpc3_*.deb
sudo apt-get --fix-broken install -y --allow-unauthenticated
5.2,配置挂载
# 创建挂载点
sudo mkdir -p /mnt/nfs_share
# 手动挂载测试
sudo mount -t nfs <NFS_SERVER_IP>:/nfs_share /mnt/nfs_share
# 永久挂载配置
echo "<NFS_SERVER_IP>:/nfs_share /mnt/nfs_share nfs rw,hard,intr,noatime 0 0" | sudo tee -a /etc/fstab
sudo mount -a
5.3 验证客户端
# 写入测试文件
echo "offline-nfs-test" | sudo tee /nfs_share/testfile
# 查看服务端文件
cat /nfs_share/testfile # 应显示"offline-nfs-test"