07 NFS搭建

我們這里把NFS服務器搭建再K8s的一個master節(jié)點上

1、在NFS服務器上安裝服務端軟件

# yum -y install  nfs-utils

編輯/etc/exports

[root@centos7 /]# vi /etc/exports
/backup 192.168.108.0/24(rw,sync,no_root_squash)

若是想讓所有主機都可以掛載,可以配置為 /backup *(rw,sync,no_root_squash)

[root@k8s-master03 ~]# mkdir /backup
[root@k8s-master03 ~]# chmod -R 777 /backup/

啟動服務并設置為開機自動啟動

[root@k8s-master03 ~]# systemctl enable rpcbind.service
[root@k8s-master03 ~]# systemctl enable nfs-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
[root@k8s-master03 ~]# systemctl start rpcbind.service
[root@k8s-master03 ~]# systemctl start nfs-server.service

加載配置并確認最終配置情況

[root@k8s-master03 ~]# exportfs -r
[root@k8s-master03 ~]# exportfs
/backup         192.168.108.0/24
[root@k8s-master03 ~]#

完整過程:
image.png

2、在NFS客戶端上安裝軟件

2.1 比如在K8s所有work node上安裝

# yum -y install nfs-utils

2.2 檢查掛載目錄

[root@k8s-master03 Chapter05]# showmount -e 192.168.108.88
Export list for 192.168.108.88:
/backup3 192.168.108.0/16
/backup2 192.168.108.0/16
/backup  192.168.108.0/16

2.3 新建掛載點并掛載:

# mkdir /nfs

掛載共享目錄:

# mount -t nfs 192.168.108.88:/backup /nfs

開啟自動掛載:

[root@k8s-node1 ~]# cat /etc/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
mount -t nfs 192.168.108.88:/backup /nfs
[root@k8s-node1 ~]#

3、測試

image.png
image.png
image.png
最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容