Skip to content

Instantly share code, notes, and snippets.

@novohool
Last active July 4, 2018 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save novohool/b7ef13305a0066193fda4b42e6e89845 to your computer and use it in GitHub Desktop.
Save novohool/b7ef13305a0066193fda4b42e6e89845 to your computer and use it in GitHub Desktop.
由于k8s服务并不是在固定一台机器上面,容器文件需要永久存储,这时候就需要一台远程nfs服务器作为固定存储服务,简单安全步骤如下:
**服务端安装**:
```
yum -y install nfs-utils rpcbind
mkdir -p /data/nfs
chmod 666 /data/nfs/
echo '/data/nfs 192.168.1.0/24(rw,no_root_squash,no_all_squash,sync)' > /etc/exports
exportfs -r
cat>>/etc/sysconfig/nfs<<EOF
RQUOTAD_PORT=30001
LOCKD_TCPPORT=30002
LOCKD_UDPPORT=30002
MOUNTD_PORT=30003
STATD_PORT=30004
EOF
cat>>/etc/modprobe.d/lockd.conf<<EOF
options lockd nlm_tcpport=3002
options lockd nlm_udpport=3002
EOF
service rpcbind start
service nfs start
```
**检测**:
```
[root@localhost ~]# showmount -e 192.168.1.147
Export list for 192.168.1.147:
/data/nfs 192.168.1.0/24
```
**客户端挂载**
```
mount -t nfs 192.168.1.147:/data/nfs /data/tmp
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment