Centos7筆記之NFS服務安裝和設定

2021-09-26 09:54:05 字數 3059 閱讀 6167

一、目標

centos7下nfs服務安裝和設定。

二、平台

centos7.6,

三、解析

貌似centos7.6已經預設安裝了nfs,搞不清楚了。

所需要軟體nfs-utils, rpc-bind

nfs共享資料夾配置檔案/etc/exports

四、服務端主要步驟

1.服務端安裝nfs相關元件

yum install nfs-untils rpcbind -y

2.啟動nfs相關的服務,並設定nfs相關服務開機自動啟動

[root@localhost ~]# systemctl restart rpcbind.service

[root@localhost ~]# systemctl restart nfs

[root@localhost ~]# systemctl restart nfs-server

[root@localhost ~]# 

[root@localhost ~]# systemctl enable rpcbind.service

[root@localhost ~]# systemctl enable nfs-server

3.防火牆放行nfs及相關服務

[root@localhost ~]# firewall-cmd --permanent --add-service=nfs

success

[root@localhost ~]# firewall-cmd --permanent --add-service=mountd

success

success

[root@localhost ~]# firewall-cmd --reload

success

4.編輯nfs配置檔案/etc/exports,這個檔案本身是個空白檔案,新增一行東西進去

/kahnnfs	10.100.100.0/24(rw,sync)

#kahnnfs戴錶的是nfs共享資料夾

#10.100.100.0/24戴錶的是誰能訪問這個共享資料夾

#rw戴錶讀寫,

#sync我也不知道是什麼鬼。

# /kahnnfs *(rw,sync) 這樣寫是允許所有主機訪問,生產環境不建議這麼玩

5.重啟nfs相關服務

[root@localhost ~]# systemctl restart rpcbind.service

[root@localhost ~]# systemctl restart nfs-server.service

五、客戶端訪問nfs服務的方法

1.在客戶端上看對方伺服器nfs是否共享出來了

[root@localhost ~]# showmount -e 10.100.100.210     #這裡的ip位址指的是nfs伺服器位址

export list for 10.100.100.210:

/kahnnfs * #這代表伺服器端的nfs配置檔案寫的是允許所有主機訪問

[root@localhost ~]#

[root@localhost ~]# showmount -e 10.100.100.210

export list for 10.100.100.210:

/kahnnfs 10.100.100.0/24 #這代表伺服器端的nfs配置檔案寫的是允許指定網段的主機訪問

2.客戶端上新建掛載點

[root@localhost ~]# mkdir /mnt/kahnc7share
3.掛載nfs到本地資料夾/mnt/kahnc7share  (這是永久掛載,也可以使用mount -t ......去一次性掛載)

[root@localhost ~]# cat /etc/fstab

## /etc/fstab

# created by anaconda on sun aug 25 05:48:17 2019

## accessible filesystems, by reference, are maintained under '/dev/disk'

# see man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#uuid=b4ebcd44-cc68-41f1-9827-183b9ae509e2 / xfs defaults 0 0

uuid=04831407-96fa-4947-8a81-07080b70c0cd /boot xfs defaults 0 0

uuid=e1c86d8c-1cf7-405e-a87d-6348e2d268c5 swap swap defaults 0 0

10.100.100.210:/kahnnfs /mnt/kahnc7share nfs defaults 0 0

# 最後一行寫上10.100.100.210是伺服器位址,後面跟冒號以及伺服器端的nfs路徑。

#後面跟上客戶端的要掛載的目標掛載點/mnt/kahnc7share,後面照抄不解釋,我乙個保安也解釋不了什麼。

一次性掛載的命令: mount -t nfs 10.100.100.210:/kahnnfs /mnt/kahnc7share

4.客戶端掛載:執行命令mount -a    , 執行df -ht檢視掛載情況。

5.至此在客戶端就能訪問/mnt/kahnc7share/ 就相當於訪問到了伺服器端的nfs共享資料夾了。但是,但是蛋疼的是這僅僅是唯讀,我也不知道為啥。

2023年8月25日23:22:25。

Centos7筆記之NFS服務安裝

一 目標 centos7下安裝nfs服務 二 平台 centos7.6 三 配置解析 1.軟體名 nsf 2.服務名 nsf server 3.配置檔案 etc exports 四 安裝nfs服務 1.yum install nfs y 安裝nfs服務 2.systemctl restart nfs...

Centos7筆記之目錄介紹

一 目標 centos7的檔案目錄結構的初步認識 二 平台 centos7.6 三 centos7目錄介紹 1.boot 用於存放系統引導檔案和核心檔案 2.bin 用於存放可執行檔案 二進位制檔案 如ls cat mkdir 3.sbin 用於存放root使用者可以執行的命令 4.home 普通使...

Centos7筆記之Docker CE安裝

一 目標 centos7.6下安裝docker ce 二 平台 root hiibm uname r 3.10.0 957.el7.x86 64 root hiibm cat etc redhat release centos linux release 7.6.1810 core docker版本...