[TOC]
參考資料
將圖片服務和應用服務分離
大型網(wǎng)站架構 圖片服務器分離
Nginx服務器上搭建圖片緩存服務的基本配置解析
CentOS7 minimal nfs 服務器、客戶端和 win7 nfs 客戶端
centos7 下nfs的配置
CentOS 7.3 配置NFS
網(wǎng)絡拓撲結構
安裝配置 nfs 服務
# 包含 nfs 和 rpcbind
yum install -y nfs-utils
/opt/data/dev.reading.zt *(rw,sync,no_root_squash)
# 設置開機啟動 rpcbing亏钩,nfs
systemctl enable rpcbind
systemctl enable nfs
# 啟動 rpcbing,nfs 服務
systemctl start rpcbind
systemctl start nfs
# 防火墻配置
firewall-cmd --permanent --add-service nfs
firewall-cmd --reload
編輯/etc/exports配置文件 vi /etc/exports
/opt/data/dev.reading.zt *(rw,sync,no_root_squash)
- 代表共享目錄
/opt/data/dev.reading.zt
- 允許訪問的主機蛤签,可以是IP或者IP段,
*
表示通配符 - 括號中的部分
- rw:可讀可寫震肮;
- sync:內(nèi)存中數(shù)據(jù)寫入磁盤留拾;
- no_root_squash:NFS客戶端連接服務器時如果使用的是root權限,那么對服務器分享的目錄來說痴柔,也擁有root權限,此項不安全咳蔚。
- 括號中逗號后邊不需要空格,否則會報錯:exportfs: /etc/exports:1: syntax error: bad option list
使配置文件生效 exportfs -r
查看 nfs 掛載 showmount -e
nfs 服務端配置 自動化執(zhí)行腳本
vi /opt/nfs-service-conf.sh
#!/bin/bash
# 包含 nfs 和 rpcbind
yum install -y nfs-utils
# 設置開機啟動 rpcbing侈询,nfs
systemctl enable rpcbind
systemctl enable nfs
# 啟動 rpcbing糯耍,nfs 服務
systemctl start rpcbind
systemctl start nfs
# 防火墻配置
firewall-cmd --permanent --add-service nfs
firewall-cmd --reload
folder=/opt/data/dev.reading.zt
# 創(chuàng)建路徑
mkdir -p ${folder}
# 在 NFS 服務中添加目錄,配置文件 /etc/exports
echo "${folder} *(rw,sync,no_root_squash)">>/etc/exports
# 使配置文件生效
exportfs -r
賦予可執(zhí)行權限温技,并運行
# 賦予可執(zhí)行權限
chmod +x /opt/nfs-service-conf.sh
# 執(zhí)行
. /opt/nfs-service-conf.sh
安裝配置 nfs 客戶端
yum install -y nfs-utils
# 設置開機啟動
systemctl enable rpcbind
# 啟動 rpcbing 服務
systemctl start rpcbind
創(chuàng)建要掛載的目錄 mkdir /opt/mnt
設置開機自動掛載舵鳞, vi /etc/fstab
192.168.0.12:/opt/data/dev.reading.zt /opt/mnt nfs defaults 0 0