部署 NFS
本文档为NFS部署说明,NFS通过网络挂载,让不同的机器、操作系统可以共享彼此的文件。天枢平台使用NFS作为集群内的文件存储系统,用于存储数据集、模型、算法文件等。
部署方案
这里会提供两种部署方式:
- 快速部署
- 分步骤部署
快速部署
执行如下命令后等待部署完成。
note
部署指南:
$ wget http://tianshu.org.cn/static/upload/file/dubheDeployScriptfile.zip
$ unzip dubheDeployScriptfile.zip
# 目录结构如下
$ tree dubheDeployScriptfile
dubheDeployScriptfile
├── efk
│ └── efk-deployment.yaml
├── harbor
│ └── harborubuntu.sh
├── init-algorithm
│ ├── algorithm-annotation-hpa.yaml
│ ├── algorithm-annotation.yaml
│ ├── algorithm-imagenet-hpa.yaml
│ ├── algorithm-imagenet.yaml
│ ├── algorithm-imgprocess-hpa.yaml
│ ├── algorithm-imgprocess.yaml
│ ├── algorithm-ofrecord-hpa.yaml
│ ├── algorithm-ofrecord.yaml
│ ├── algorithm-track.yaml
│ ├── algorithm-videosample-hpa.yaml
│ ├── algorithm-videosample.yaml
│ └── Dockerfile
├── k8s1.16.2-ubuntu
│ ├── base.config
│ ├── calico.yml
│ ├── del_kube.sh
│ ├── k8s1.16.2.sh
│ ├── node_install_k8s.sh
│ ├── README.md
│ ├── setup.log
│ ├── ssh_trust_add.exp
│ └── ssh_trust_init.exp
├── metrics-server
│ └── metrics-server-deployment.yaml
├── monitor
│ └── monitor-pod.yaml
└── nfs
├── nfs-client.sh
└── nfs-server.sh
对于 nfs 目录下的文件:
- NFS 服务端的挂载目录默认为 /nfs,可以在 nfs-server.sh 更改
- NFS 客户端中的 $ip/nfs 目录可以根据 NFS 服务端更换
执行脚本进行部署
$ wget http://tianshu.org.cn/static/upload/file/dubheDeployScriptfile.zip
$ unzip dubheDeployScriptfile.zip
$ cd dubheDeployScriptfile/nfs/
$ chmod a+x nfs-server.sh
$ sed -i "s/\r//" nfs-server.sh
$ ./nfs-server.sh
$ chmod a+x nfs-client.sh
$ sed -i "s/\r//" nfs-client.sh
$ ./nfs-client.sh
如果你想看更详细的部署过程,可以往下看分步骤部署过程。
分步骤部署
服务端
- 安装 NFS 服务
#执行以下命令安装 NFS 服务,
#apt 会自动安装 nfs-common、rpcbind 等软件包
sudo apt install nfs-kernel-server
- 创建共享目录
在服务器端创建 /nfs 目录。
- 编写配置文件
vim /etc/exports
#[任意主机所有权限]
/nfs *(rw,sync,insecure,no_subtree_check,no_root_squash)
- 重启 NFS 服务
sudo service nfs-kernel-server restart
- 常用命令工具
#在安装 NFS 服务器时,已包含常用的命令行工具,无需额外安装
#显示已经 mount 到本机 NFS 目录的客户端机器
sudo showmount -e localhost
#将配置文件中的目录全部重新 export 一次,无需重启服务
sudo exportfs -rv
#查看 NFS 的运行状态
sudo nfsstat
#查看 rpc 执行信息,可以用于检测 rpc 运行情况
sudo rpcinfo
客户端
- 安装客户端工具
#在需要连接到 NFS 服务器的客户端机器上,
#需要执行以下命令,安装 nfs-common 软件包。
#apt 会自动安装 nfs-common、rpcbind 等软件包
sudo apt install nfs-common
- 查看 NFS 服务器上的共享目录
#显示指定的 NFS 服务器(假设 IP 地址为 192.168.3.167)上 export 出来的目录
sudo showmount -e 192.168.3.167
- 创建本地挂载目录
sudo mkdir -p /nfs
- 挂载共享目录
#假设 NFS 服务器 IP为 192.168.3.167,可以如下设置挂载
sudo mount -t nfs 192.168.3.167:/nfs /nfs
- 查看客户端挂载信息
df -h