1. 程式人生 > 實用技巧 >第六章 NFS、rsync等統一使用者相關操作

第六章 NFS、rsync等統一使用者相關操作

一、統一使用者

1.httpd
2.NFS掛載目錄
3.rsync

1.所有伺服器統一建立使用者

[root@web01 ~]# groupadd www -g 666
[root@web01 ~]# useradd www -u 666 -g 666

2.修改httpd使用者

[root@web01 ~]# vim /etc/httpd/conf/httpd.conf
User www
Group www

#重啟服務
[root@web01 ~]# systemctl restart httpd
[root@web01 ~]# ps -ef | grep httpd
root 31537 1 1 21:57 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
www 31538 31537 0 21:57 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
www 31539 31537 0 21:57 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
www 31540 31537 0 21:57 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
www 31541 31537 0 21:57 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
www 31542 31537 0 21:57 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 31544 18601 0 21:57 pts/1 00:00:00 grep --color=auto httpd

3.修改NFS服務端許可權

[root@NFS /data]# vim /etc/exports
/data 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)

#重啟
[root@NFS /data]# systemctl restart NFS

4.修改rsync使用者

[root@backup ~]#vim /etc/rsyncd.conf
uid = www
gid = www
port = 873
fake super = yes
use chroot = no
max connections = 200
timeout = 600
ignore errors
read only = false
list = false
auth users = rsync_backup
secrets file = /etc/rsync.passwd
log file = /var/log/rsyncd.log
#####################################
[backup]
comment = welcome to oldboyedu backup!
path = /backup

5.NFS服務端重新授權目錄

[root@NFS ~]# chown -R www.www /data/

6.web端重新掛載

[root@web01 /var/www/html]# umount /var/www/html/upload
[root@web01 /var/www/html]# mount -t NFS 172.16.1.31:/data ./upload

7.rsync服務端重新授權目錄

[root@backup ~]#chown -R www:www /backup

二、NFS總結

1.NFS儲存優點
1)簡單易用,部署方便
2)資料可查,服務穩定

2.NFS的服務缺點
1)存在單點故障, 如果構建高可用維護麻煩web->NFS()->backup
2)NFS資料明文, 並不對資料做任何校驗。
3)客戶端掛載NFS服務沒有密碼驗證, 安全性一般(內網使用)

3.NFS應用建議
1)開機掛載
如果希望NFS檔案共享服務能一直有效,則需要將其寫入到fstab檔案中
#編輯fstab檔案
[root@NFS-client ~]# vim /etc/fstab
172.16.1.31:/data /NFSdir NFS defaults 0 0
#驗證fstab是否寫正確
[root@NFS-client ~]# mount -a

2)生產場景應將靜態資料儘可能往前端推,減少後端儲存壓力
3)必須將儲存裡的靜態資源通過CDN快取,jpg\png\mp4\avi\css\js
4)如果沒有快取或架構本身歷史遺留問題太大, 在多儲存也無用

三、rsync+NFS解決單點故障

1.環境準備

主機

角色IP
backup rsync服務端,NFS服務端 172.16.1.41
NFS rsync客戶端,NFS服務端 172.16.1.31
web01 rsync客戶端,NFS客戶端 172.16.1.7,10.0.0.7

2.web01搭載上傳作業平臺

1.安裝httpd和php
[root@web01 ~]# yum install -y httpd php

2.上傳程式碼
[root@web01 ~]# rz kaoshi.zip
[root@web01 ~]# yum unzip
[root@web01 ~]# unzip kaoshi.zip -d /var/www/html/

3.建立httpd使用者
[root@web01 ~]# groupadd www -g 666
[root@web01 ~]# useradd www -u 666 -g 666

4.配置httpd服務
[root@web01 ~]# vim /etc/httpd/conf/httpd.conf
User www
Group www

#開啟服務
[root@web01 ~]# systemctl start httpd

5.修改許可權
[root@web01 ~]# chown -R www.www /var/www/html/

3.NFS伺服器搭建NFS服務端

1.安裝NFS
[root@NFS ~]# yum install -y NFS-utils rpcbind

2.配置NFS
[root@backup ~]# vim /etc/exports
/data 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)

3.檢視配置生效
[root@backup ~]# cat /var/lib/nfs/etab
/data 172.16.1.0/24(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=666,anongid=666,sec=sys,rw,secure,root_squash,all_squash)

4.建立使用者
[root@web01 ~]# groupadd www -g 666
[root@web01 ~]# useradd www -u 666 -g 666

5.建立目錄
[root@web01 ~]# mkdir /data
[root@web01 ~]# chown -R www.www /data

4.掛載web01資料目錄

[root@web01 ~]# showmount -e 172.16.1.31

[root@web01 ~]# mount -t nfs 172.16.1.31:/data /var/www/html/upload

5.backup搭建rsync服務端

1.安裝rsync
[root@backup ~]# yum -y install rsyncd

2.配置rsync
[root@backup ~]# cat /etc/rsyncd.conf
uid = www
gid = www
port = 873
fake super = yes
use chroot = no
max connections = 200
timeout = 600
ignore errors
read only = false
list = true
auth users = rsync_backup
secrets file = /etc/rsync.passwd
log file = /var/log/rsyncd.log
#####################################
[backup]
comment = "檔案備份目錄"
path = /backup

[data]
comment = "資料備份目錄"
path = /data

3.重啟rsync
[root@backup ~]# systemctl restart rsyncd

6.NFS資料實時備份到backup伺服器

1.安裝inotify
[root@nfs ~]# yum -y install inotify-tools

2.編寫指令碼實時備份data目錄
[root@nfs /data]# vim /scripts/backup_data.sh
#!/bin/bash
dir=/data
export RSYNC_PASSWORD=123456
/usr/bin/inotifywait -mrq --format '%w %f' -e create,delete,attrib,close_write $dir | while read line;do
cd $dir && rsync -az -R --delete . [email protected]::data >/dev/null 2>&1
done &

3.啟動指令碼
[root@nfs /data]# sh /scripts/backup_data.sh

7.測試

1.訪問交作業頁面,上傳圖片
2.檢視web伺服器
[root@web01 ~]# ll /var/www/html/upload
3.檢視nfs伺服器data目錄
[root@nfs ~]# ll /data/
4.檢視backup伺服器data目錄
[root@backup ~]# ll /data

8.backup搭建NFS服務端

1.安裝NFS
[root@backup ~]# yum install -y nfs-utils rpcbind

2.配種NFS
[root@backup ~]# vim /etc/exports
/data 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)

3.建立使用者
[root@backup ~]# groupadd www -g 666
[root@backup ~]# useradd www -u 666 -g 666

4.啟動服務
[root@backup ~]# systemctl start nfs

9.測試

1.NFS伺服器出現故障
[root@nfs ~]# systemctl stop nfs

2.切換掛載機器
[root@web01 ~]# umount -lf /var/www/html/upload
[root@web01 ~]# mount -t nfs 172.16.1.41:/data /var/www/html/upload

四、實時同步

1.實時同步簡單介紹

1.概述
實時同步是一種只要當前目錄發生變化則會觸發一個事件,事件觸發後會將變化的目錄同步至遠端伺服器

2.為什麼要實時同步
保證資料的連續性, 減少人力維護成本,解決nfs單點故障

3.實時同步資料選擇
sersync+RSYNC(√)、inotify+rsync
Inotify是一個通知介面,用來監控檔案系統的各種變化,如果檔案存取,刪除,移動。可以非常方便地實現檔案異動告警,增量備份,並針對目錄或檔案的變化及時作出響應。rsync+inotify可以實觸發式實時同步增量備份

sersync是國人基於rsync+inotify-tools開發的工具,不僅保留了優點同時還強化了實時監控,檔案過濾,簡化配置等功能,幫助使用者提高執行效率,節省時間和網路資源。

2.安裝sersync(NFS伺服器)

1.安裝sersync和inotify
[root@nfs01 ~]# yum install rsync inotify-tools -y

2.下載serdync軟體包
[root@nfs01 ~]# wget https://raw.githubusercontent.com/wsgzao/sersync/master/sersync2.5.4_64bit_binary_stable_final.tar.gz

3.解壓安裝包
[root@nfs ~]# tar xf sersync2.5.4_64bit_binary_stable_final.tar.gz

4.移動並改名
[root@nfs ~]# mv GNU-Linux-x86 /usr/local/sersync

5.修改配置檔案
[root@nfs ~]# cat /usr/local/sersync/confxml.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
#主機IP
<host hostip="localhost" port="8008"></host>
#除錯模式
<debug start="false"/>
<fileSystem xfs="false"/>
#檔案過濾
<filter start="false">
<exclude expression="(.*)\.svn"></exclude>
<exclude expression="(.*)\.gz"></exclude>
<exclude expression="^info/*"></exclude>
<exclude expression="^static/*"></exclude>
</filter>
#inotify監控配置
<inotify>
#inotify監控的行為
<delete start="true"/>
<createFolder start="true"/>
<createFile start="true"/>
<closeWrite start="true"/>
<moveFrom start="true"/>
<moveTo start="true"/>
<attrib start="true"/>
<modify start="true"/>
</inotify>
#推送部分
<sersync>
#本地監控的目錄
<localpath watch="/data">
#遠端IP及模組名字
<remote ip="172.16.1.41" name="data"/>
</localpath>
<rsync>
#rsync同步時的引數
<commonParams params="-artuz"/>
#開啟認證
<auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
#如果rsync服務不是873埠,需要開啟
<userDefinedPort start="false" port="874"/><!-- port=874 -->
#超時時間
<timeout start="false" time="100"/><!-- timeout=100 -->
<ssh start="false"/>
</rsync>
#指定錯誤日誌
<failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
#定時任務,預設600分鐘進行一次全備
<crontab start="false" schedule="600"><!--600mins-->
#定時任務檔案過濾
<crontabfilter start="false">
<exclude expression="*.php"></exclude>
<exclude expression="info/*"></exclude>
</crontabfilter>
</crontab>
<plugin start="false" name="command"/>
</sersync>

<plugin name="command">
<param prefix="/bin/sh" suffix="" ignoreError="true"/> <!--prefix /opt/tongbu/mmm.sh suffix-->
<filter start="false">
<include expression="(.*)\.php"/>
<include expression="(.*)\.sh"/>
</filter>
</plugin>

<plugin name="socket">
<localpath watch="/opt/tongbu">
<deshost ip="192.168.138.20" port="8009"/>
</localpath>
</plugin>
<plugin name="refreshCDN">
<localpath watch="/data0/htdocs/cms.xoyo.com/site/">
<cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>
<sendurl base="http://pic.xoyo.com/cms"/>
<regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
</localpath>
</plugin>
</head>
[root@nfs ~]#

6.建立密碼檔案
[root@nfs ~]# echo 123456 > /etc/rsync.password
[root@nfs ~]# chmod 600 /etc/rsync.password

7.啟動
#檢視引數
[root@nfs ~]# /usr/local/sersync/sersync2 -h
set the system param
execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
parse the command param
_______________________________________________________
引數-d:啟用守護程序模式
引數-r:在監控前,將監控目錄與遠端主機用rsync命令推送一遍
c引數-n: 指定開啟守護執行緒的數量,預設為10個
引數-o:指定配置檔案,預設使用confxml.xml檔案
引數-m:單獨啟用其他模組,使用 -m refreshCDN 開啟重新整理CDN模組
引數-m:單獨啟用其他模組,使用 -m socket 開啟socket模組
引數-m:單獨啟用其他模組,使用 -m http 開啟http模組
不加-m引數,則預設執行同步程式

[root@nfs ~]# /usr/local/sersync/sersync2 -dro /usr/local/sersync/confxml.xml
set the system param
execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
parse the command param
option: -d run as a daemon
option: -r rsync all the local files to the remote servers before the sersync work
option: -o config xml name: /usr/local/sersync/confxml.xml
daemon thread num: 10
parse xml config file
host ip : localhost host port: 8008
will ignore the inotify createFile event
daemon start,sersync run behind the console
use rsync password-file :
user is rsync_backup
passwordfile is /etc/rsync.password
config xml parse success
please set /etc/rsyncd.conf max connections=0 Manually
sersync working thread 12 = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads)
Max threads numbers is: 22 = 12(Thread pool nums) + 10(Sub threads)
please according your cpu ,use -n param to adjust the cpu rate
------------------------------------------
rsync the directory recursivly to the remote servers once
working please wait...
execute command: cd /data && rsync -artuz -R --delete ./ [email protected]::data --password-file=/etc/rsync.password >/dev/null 2>&1
run the sersync:
watch path is: /data

五、作業:sersync+NFS實戰

1.需求

1.恢復快照
2.搭建交作業系統
3.配置掛載資料目錄
4.NFS的資料目錄實時備份到backup伺服器(要求使用sersync)

2.環境準備

主機角色IP
backup rsync服務端,NFS服務端 172.16.1.41
NFS rsync客戶端,NFS服務端 172.16.1.31
web01 rsync客戶端,NFS客戶端 172.16.1.7,10.0.0.7

3.web01搭載上傳作業平臺

1.關閉防火牆
[root@web01 ~]# systemctl stop firewalld
[root@web01 ~]# systemctl disable firewalld

2.關閉selinux
[root@web01 ~]# setenforce 0
[root@web01 ~]# vim /etc/selinux/config
SELINUX=disabled

3.安裝httpd和php
[root@web01 ~]# yum -y install httpd php

4.上傳作業平臺程式碼並解壓到指定目錄
[root@web01 ~]# rz -bye

[root@web01 ~]# ll
total 36
-rw-------. 1 root root 1350 Jun 9 21:42 anaconda-ks.cfg
-rw-r--r--. 1 root root 497 Aug 5 16:53 hostname_ip.sh
-rw-r--r-- 1 root root 26995 Aug 13 16:42 kaoshi.zip
[root@web01 ~]# unzip kaoshi.zip -d /var/www/html/
Archive: kaoshi.zip
inflating: /var/www/html/info.php
inflating: /var/www/html/bg.jpg
inflating: /var/www/html/index.html
inflating: /var/www/html/upload_file.php

5.修改httpd配置
[root@web01 ~]# vim /etc/httpd/conf/httpd.conf
User www
Group www

6.建立統一使用者
[root@web01 ~]# groupadd -g 666 www
[root@web01 ~]# useradd -u 666 -g 666 www

7.修改使用者許可權
[root@web01 ~]# chown -R www:www /var/www/html/

8.重啟服務並驗證服務
[root@web01 ~]# systemctl restart httpd
[root@web01 ~]# ps aux |grep http
root 24063 0.8 0.5 314580 12128 ? Ss 19:49 0:00 /usr/sbin/httpd -DFOREGROUND
www 24064 0.0 0.3 314712 6160 ? S 19:49 0:00 /usr/sbin/httpd -DFOREGROUND
www 24065 0.0 0.3 314712 6160 ? S 19:49 0:00 /usr/sbin/httpd -DFOREGROUND
www 24066 0.0 0.3 314712 6160 ? S 19:49 0:00 /usr/sbin/httpd -DFOREGROUND
www 24067 0.0 0.3 314712 6160 ? S 19:49 0:00 /usr/sbin/httpd -DFOREGROUND
www 24068 0.0 0.3 314712 6160 ? S 19:49 0:00 /usr/sbin/httpd -DFOREGROUND
root 24070 0.0 0.0 112708 976 pts/0 R+ 19:49 0:00 grep --color=auto http

4.NFS伺服器搭建NFS服務端

1.關閉防火牆
[root@nfs ~]# systemctl stop firewalld
[root@nfs ~]# systemctl disable firewalld

2.關閉selinux
[root@NFS ~]# setenforce 0
[root@NFS ~]# vim /etc/selinux/config
SELINUX=disabled

3.安裝nfs和rpcbind
[root@nfs ~]# yum -y install nfs-utils rpcbind

4.配置nfs服務
[root@nfs ~]# vim /etc/exports
/web/data 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)

5.重啟服務並驗證
[root@nfs ~]# systemctl restart nfs
[root@nfs ~]# cat /var/lib/nfs/etab
/web/data 172.16.1.0/24(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=666,anongid=666,sec=sys,rw,secure,root_squash,all_squash)

6.建立統一使用者
[root@nfs ~]# groupadd -g 666 www
[root@nfs ~]# useradd -u 666 -g 666 www

7.建立掛載目錄並修改許可權
[root@nfs ~]# mkdir -p /web/data
[root@nfs ~]# chown -R www:www /web/data/

5.web01客戶端掛載目錄

1.安裝nfs和rpcbind
[root@web01 ~]# yum -y install nfs rpcbind

2.啟動rpcbind
[root@web01 ~]# systemctl start rpcbind

3.檢視掛載點
[root@web01 ~]# showmount -e 172.16.1.31
Export list for 172.16.1.31:
/web/data 172.16.1.0/24

4.掛載目錄
[root@web01 ~]# mount -t nfs 172.16.1.31:/web/data /var/www/html/upload

5.檢視掛載點
[root@web01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 98G 1.7G 96G 2% /
devtmpfs 980M 0 980M 0% /dev
tmpfs 991M 0 991M 0% /dev/shm
tmpfs 991M 9.6M 981M 1% /run
tmpfs 991M 0 991M 0% /sys/fs/cgroup
/dev/sda1 497M 120M 378M 25% /boot
tmpfs 199M 0 199M 0% /run/user/0
172.16.1.31:/web/data 98G 1.7G 96G 2% /var/www/html/upload

6.backup搭建rsync服務端

1.關閉防火牆
[root@backup ~]# systemctl stop firewalld
[root@backup ~]# systemctl disable firewalld

2.關閉selinux
[root@backup ~]# setenforce 0
[root@backup ~]# vim /etc/selinux/config
SELINUX=disabled

3.安裝rsync服務
[root@backup ~]# yum -y install rsync

4.配置rsync服務
[root@backup ~]# vim /etc/rsyncd.conf
uid = www
gid = www
port = 873
fake super = yes
use chroot = no
max connections =200
timeout = 600
ignore errors
read only =false
list = true
auth users = rsync_backup
secrets file = /etc/rsync.passwd
log file = /var/log/rsyncd.log
#####################################
[backup]
comment = "檔案備份目錄"
path = /backup

[data]
comment = "資料備份目錄"
path = /data

5.建立統一使用者
[root@backup ~]# groupadd -g 666 www
[root@backup ~]# useradd -u 666 -g 666 www

6.建立密碼檔案並修改許可權
[root@backup ~]# echo "rsync_backup:123456" >/etc/rsync.passwd
[root@backup ~]# chmod 600 /etc/rsync.passwd

7.建立備份目錄並修改許可權
[root@backup ~]# mkdir /backup
[root@backup ~]# mkdir /data
[root@backup ~]# chown -R www:www /backup/
[root@backup ~]# chown -R www:www /data/

8,重啟服務並驗證服務
[root@backup ~]# systemctl restart rsyncd
[root@backup ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 24097/rsync
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 6135/rpcbind
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 7151/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 7291/master
tcp6 0 0 :::873 :::* LISTEN 24097/rsync
tcp6 0 0 :::111 :::* LISTEN 6135/rpcbind
tcp6 0 0 :::22 :::* LISTEN 7151/sshd
tcp6 0 0 ::1:25 :::* LISTEN 7291/master

7.NFS資料實時備份到backup伺服器

1.安裝inotify
[root@nfs ~]# yum install rsync inotify-tools -y

2.上傳serdync軟體包
[root@nfs ~]# rz -bye

[root@nfs ~]# ll
-rw-r--r-- 1 root root 727290 Aug 14 17:15 sersync2.5.4_64bit_binary_stable_final.tar.gz

3.解壓安裝包
[root@nfs ~]# [root@nfs ~]# tar -xf sersync2.5.4_64bit_binary_stable_final.tar.gz

4.移動並改名
[root@nfs ~]# mv GNU-Linux-x86 /usr/local/sersync

5.修改配置檔案
[root@nfs ~]# vim /usr/local/sersync/confxml.xml
</crontab>
<plugin start="false" name="command"/>
</sersync>
<plugin name="command">
<param prefix="/bin/sh" suffix="" ignoreError="true"/> <!--prefix /opt/tongbu/mmm.sh suffix-->
<filter start="false">
<include expression="(.*)\.php"/>
<include expression="(.*)\.sh"/>
</filter>
</plugin>

<plugin name="socket">
<localpath watch="/opt/tongbu">
<deshost ip="192.168.138.20" port="8009"/>
</localpath>
</plugin>
<plugin name="refreshCDN">
<localpath watch="/data0/htdocs/cms.xoyo.com/site/">
<cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>
<sendurl base="http://pic.xoyo.com/cms"/>
<regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
</localpath>
</plugin>
</head>

6.建立密碼檔案並設定許可權
[root@nfs ~]# echo "123456" >/etc/rsync.password
[root@nfs ~]# chmod 600 /etc/rsync.password

7.啟動資料實時同步
[root@nfs ~]# /usr/local/sersync/sersync2 -dro /usr/local/sersync/confxml.xml
set the system param
execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
parse the command param
option: -d run as a daemon
option: -r rsync all the local files to the remote servers before the sersync work
option: -o config xml name: /usr/local/sersync/confxml.xml
daemon thread num: 10
parse xml config file
host ip : localhost host port: 8008
will ignore the inotify createFile event
daemon start,sersync run behind the console
use rsync password-file :
user is rsync_backup
passwordfile is /etc/rsync.password
config xml parse success
please set /etc/rsyncd.conf max connections=0 Manually
sersync working thread 12 = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads)
Max threads numbers is: 22 = 12(Thread pool nums) + 10(Sub threads)
please according your cpu ,use -n param to adjust the cpu rate
------------------------------------------
rsync the directory recursivly to the remote servers once
working please wait...
execute command: cd /web/data && rsync -artuz -R --delete ./ [email protected]::data --password-file=/etc/rsync.password >/dev/null 2>&1
run the sersync:
watch path is: /web/data

8.backup搭建NFS服務端

1.安裝nfs和rpcbind
[root@backup ~]# yum -y install nfs rpcbind

2.配置nfs服務
[root@backup ~]# vim /etc/exports
/backup 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)

3.重啟服務並驗證
[root@backup ~]# cat /var/lib/nfs/etab
/backup 172.16.1.0/24(rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=666,anongid=666,sec=sys,rw,secure,root_squash,all_squash)

9.測試

1.訪問交作業頁面,上傳圖片

2.檢視web伺服器
[[root@web01 /var/www/html/upload]# ll
total 48
-rw-r--r-- 1 www www 46257 Aug 14 21:05 1_jh.jpg

3.檢視nfs伺服器data目錄
[root@nfs /web/data]# ll
total 48
-rw-r--r-- 1 www www 46257 Aug 14 21:05 1_jh.jpg

4.檢視backup伺服器data目錄
[root@backup /data]# ll
total 48
-rw-r--r-- 1 www www 46257 Aug 14 21:05 1_jh.jpg