第一部分:配置Rsyncweb
1、介紹Rsync工具算法
rsync是一個遠程數據同步工具,可經過LAN/WAN快速同步多臺主機間的文件。它使用所謂的「Rsync演算法」來使本地和遠程兩個主機之間的文件達到同步,這個算法只傳送兩個文件的不一樣部分,而不是每次都整份傳送,所以速度至關快。因此一般能夠做爲備份工具來使用。apache
Rsync的特性以下:vim
1)支持拷貝特殊文件如連接,設備等tomcat
2)能夠有排除指定文件或目錄同步的功能,至關於打包命令tar安全
3)能夠保持原來文件或目錄的權限,時間,軟硬連接等全部屬性均不改變。bash
4)可實現增量同步,即只同步發生變化的數據,所以數據傳輸效率更高服務器
5)可使用rcp,rsh,ssh等方式來配合傳輸文件,也能夠經過直接的socker連接app
6)支持匿名的或認證的進程模式傳輸,方便進行數據備份及鏡像。ssh
2、測試環境
Server:CentOS74-01 192.168.1.160
Client: CentOS74-02 192.168.1.161
[root@CentOS74-01 ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@CentOS74-02 ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
3、配置rsync服務端
(1)參數介紹
comment = public archive #模塊描述
path = /var/www/pub #須要同步的路徑
use chroot = yes #默認是yes|true,若是爲true,那麼在rsync在傳輸文件之前首先chroot到path參數指定的目錄下。這樣作的緣由是實現額外的安全防禦,可是缺點是須要root權限,而且不能備份指向外部的符號鏈接指向的目錄文件。
max connections=10 #最大鏈接數
lock file = /var/lock/rsyncd #指定支持max connections參數的鎖文件。
the default for read only is yes...
read only = yes #只讀選項
list = yes #客戶請求時可用模塊時是否列出該模塊
uid = nobody #設定該模塊傳輸文件時守護進程應該具備的uid
gid = nogroup #設定該模塊傳輸文件時守護進程應具備的gid,此項與uid配合能夠肯定文件的訪問權限
exclude = #用來指定多個由空格隔開的多個模式列表,並將其添加到exclude列表中。這等同於在客戶端命令中使用--exclude來指定模式,不過配置文件中指定的exlude模式不會傳遞給客戶端,而僅僅應用於服務器。一個模塊只能指定一個exlude選項,可是能夠在模式前面使用"-"和"+"來指定是exclude仍是include #這個個人理解是排除目錄中不需同步的文件
exclude from = #能夠指定一個包含exclude模式定義的文件名
include = #與exclude類似
include from = #能夠指定一個包含include模式定義的文件名
auth users = #該選項指定由空格或逗號分隔的用戶名列表,只有這些用戶才容許鏈接該模塊。這裏的用戶和系統用戶沒有任何關係。若是"auth users"被設置,那麼客戶端發出對該模塊的鏈接請求之後會被rsync請求challenged進行驗證身份這裏使用的 challenge/response認證協議。用戶的名和密碼以明文方式存放在"secrets file"選項指定的文件中。默認狀況下無需密碼就能夠鏈接模塊(也就是匿名方式)
secrets file = /etc/rsyncd.secrets #該文件每行包含一個username:password對,以明文方式存儲,只有在auth users被定義時,此選項才生效。同時咱們須要將此文件權限設置爲0600
strict modes = yes #該選項指定是否監測密碼文件的權限,若是該選項值爲true那麼密碼文件只能被rsync服務器運行身份的用戶訪問,其餘任何用戶不能夠訪問該文件。默認值爲true
hosts allow = #容許的主機
hosts deny = #拒絕訪問的主機
ignore errors = no #設定rsync服務器在運行delete操做時是否忽略I/O錯誤
ignore nonreadable = yes #設定rysnc服務器忽略那些沒有訪問文件權限的用戶
transfer logging = no #使rsync服務器使用ftp格式的文件來記錄下載和上載操做在本身單獨的日誌中
log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes. #設定日誌格式
timeout = 600 #超時設置(秒)
refuse options = checksum dry-run #定義一些不容許客戶對該模塊使用的命令選項列表
dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz #告訴rysnc那些文件在傳輸前不用壓縮,默認已設定壓縮包再也不進行壓縮
(2)rsync服務端配置
建立用戶rsync:
[root@CentOS74-01 ~]# useradd rsync [root@CentOS74-01 ~]# passwd rsync Changing password for user rsync. New password: BAD PASSWORD: The password is shorter than 8 characters Retype new password: passwd: all authentication tokens updated successfully. [root@CentOS74-01 ~]# [root@CentOS74-01 ~]# cat /etc/passwd | grep rsync rsync:x:1000:1000::/home/rsync:/bin/bash
修改配置文件/etc/rsyncd.conf:
[root@CentOS74-01 ~]# cat /etc/rsyncd.conf uid = rsync gid = rsync use chroot = no log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock hosts allow = 192.168.1.161 [apache] path = /data/apache/ read only = yes auth users = tom (跟系統用戶沒有關係) secrets file = /etc/rsyncd.secrets [tomcat] path = /data/tomcat/ read only = yes
設置rsyncd服務開機啓動:
[root@CentOS74-01 ~]# systemctl enable rsyncd.service Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
啓動rsyncd服務:
[root@CentOS74-01 ~]# systemctl start rsyncd.service
查看 rsyncd 的端口:
[root@CentOS74-01 ~]# netstat -nltp | grep 873 tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 1690/rsync
建立密碼文件並賦權限:
[root@CentOS74-01 ~]# vim /etc/rsyncd.secrets tom:tom [root@CentOS74-01 ~]# chmod 600 /etc/rsyncd.secrets [root@CentOS74-01 ~]# chown root.root /etc/rsyncd.* (由於rsyncd服務是由root啓動的,因此配置文件和密碼文件的權限要設置爲root.root) [root@CentOS74-01 ~]# ll /etc/rsyncd.* -rw-r--r-- 1 root root 818 Jul 7 14:55 /etc/rsyncd.conf -rw------- 1 root root 8 Jul 7 14:38 /etc/rsyncd.secrets
建立測試用的文件:
[root@CentOS74-01 ~]# ll /data/apache/ total 8 -rw-r--r-- 1 root root 7 Jul 7 14:40 apache_1.log -rw-r--r-- 1 root root 8 Jul 7 14:41 apache_2.log [root@CentOS74-01 ~]# ll /data/tomcat/ total 8 -rw-r--r-- 1 root root 7 Jul 7 14:41 tomcat_1.log -rw-r--r-- 1 root root 13 Jul 7 14:41 tomcat_2.log
(3)rsync客戶端配置:
[root@CentOS74-02 ~]# cat /etc/rsyncd.secrets tom [root@CentOS74-02 ~]# chown root.root /etc/rsyncd.secrets [root@CentOS74-02 ~]# chmod 600 /etc/rsyncd.secrets [root@CentOS74-02 ~]#
(4)測試
遇到錯誤一:
[root@CentOS74-02 ~]# rsync -avz --password-file=/etc/rsyncd.secrets tom@192.168.1.160::web /data/web/ rsync: failed to connect to 192.168.1.160 (192.168.1.160): No route to host (113) rsync error: error in socket IO (code 10) at clientserver.c(122) [Receiver=3.0.9]
查看服務器 CentOS74-01 上的防火牆,發現是running的狀態:
[root@CentOS74-01 ~]# firewall-cmd --state running
關閉防火牆:
[root@CentOS74-01 ~]# systemctl stop firewalld.service [root@CentOS74-01 ~]# firewall-cmd --state not running
關閉防火牆開機啓動:
[root@CentOS74-01 ~]# systemctl disable firewalld.service Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
遇到錯誤二:
[root@CentOS74-02 ~]# rsync -avz --password-file=/etc/rsyncd.secrets tom@192.168.1.160::apache /data/apache/ receiving incremental file list rsync: mkdir "/data/apache" failed: No such file or directory (2) rsync error: error in file IO (code 11) at main.c(587) [Receiver=3.0.9] [root@CentOS74-02 ~]#
須要如今客戶端上面建立文件夾/data/apache/:
[root@CentOS74-02 ~]# mkdir -pv /data/apache/ mkdir: created directory ‘/data’ mkdir: created directory ‘/data/apache/’ [root@CentOS74-02 ~]# rsync -avz --password-file=/etc/rsyncd.secrets tom@192.168.1.160::apache /data/apache/ receiving incremental file list ./ apache_1.log apache_2.log sent 96 bytes received 229 bytes 30.95 bytes/sec total size is 15 speedup is 0.05 [root@CentOS74-02 ~]#
在服務器 CentOS74-01 上面新建立apache_3.log,並把權限設置爲640:
[root@CentOS74-01 apache]# chmod 640 apache_3.log [root@CentOS74-01 apache]# ll total 12 -rw-r--r-- 1 root root 7 Jul 7 14:40 apache_1.log -rw-r--r-- 1 root root 8 Jul 7 14:41 apache_2.log -rw-r----- 1 root root 6 Jul 7 15:25 apache_3.log [root@CentOS74-01 apache]#
而後再在客戶端 CentOS74-02 上運行如下命令:
[root@CentOS74-02 ~]# rsync -avz --password-file=/etc/rsyncd.secrets tom@192.168.1.160::apache /data/apache/ receiving incremental file list ./ rsync: send_files failed to open "apache_3.log" (in apache): Permission denied (13) sent 77 bytes received 260 bytes 674.00 bytes/sec total size is 21 speedup is 0.06 rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1518) [generator=3.0.9] [root@CentOS74-02 ~]#
緣由:由於在服務器 CentOS74-01 上面,/etc/rsyncd.conf 裏面的uid = rsync gid = rsync,而 rsync 對apache_3.log並無讀權限,因此報 Permission denied (13)。
(5)使用無密碼方式拷貝
因爲/etc/rsyncd.conf中的[tomcat]模塊並無配置須要認證選項,因此可使用無密碼方式同步文件:
目前/data/tomcat的屬主屬組是root.root:
[root@CentOS74-02 ~]# ll /data total 0 drwxr-xr-x 2 root root 46 Jul 7 15:25 apache drwxr-xr-x 2 root root 6 Jul 7 16:04 tomcat
修改屬主屬組爲tomcat.tomcat:
[root@CentOS74-02 ~]# chown tomcat.tomcat /data/tomcat/ [root@CentOS74-02 ~]# ll /data/ total 0 drwxr-xr-x 2 root root 46 Jul 7 15:25 apache drwxr-xr-x 2 tomcat tomcat 6 Jul 7 16:04 tomcat
su到tomcat用戶,使用tomcat用戶身份用rsync同步文件:
[root@CentOS74-02 ~]# su tomcat [tomcat@CentOS74-02 root]$ cd /data/tomcat/ [tomcat@CentOS74-02 tomcat]$ rsync -avz 192.168.1.160::tomcat /data/tomcat/ receiving incremental file list ./ tomcat_1.log tomcat_2.log sent 69 bytes received 196 bytes 25.24 bytes/sec total size is 20 speedup is 0.08 [tomcat@CentOS74-02 tomcat]$ ll total 8 -rw-r--r-- 1 tomcat tomcat 7 Jul 7 14:41 tomcat_1.log -rw-r--r-- 1 tomcat tomcat 13 Jul 7 14:41 tomcat_2.log
刪除tomcat日誌文件,使用root用戶同步文件:
[tomcat@CentOS74-02 tomcat]$ rm -fr tomcat_* [tomcat@CentOS74-02 tomcat]$ exit exit
在客戶端上面使用root從服務器端拷貝文件到/data/tomcat/下面,會把該目錄的屬主屬組修改成root.root:
[root@CentOS74-02 ~]# rsync -avz 192.168.1.160::tomcat /data/tomcat/ receiving incremental file list ./ tomcat_1.log tomcat_2.log sent 69 bytes received 196 bytes 25.24 bytes/sec total size is 20 speedup is 0.08 [root@CentOS74-02 ~]# ll /data/ total 0 drwxr-xr-x 2 root root 46 Jul 7 15:25 apache drwxr-xr-x 2 root root 46 Jul 7 14:41 tomcat [root@CentOS74-02 ~]# ll /data/tomcat/ total 8 -rw-r--r-- 1 root root 7 Jul 7 14:41 tomcat_1.log -rw-r--r-- 1 root root 13 Jul 7 14:41 tomcat_2.log [root@CentOS74-02 ~]#
4、rsync的不足
與傳統的cp、tar備份方式相比,rsync具備安全性高、備份迅速、支持增量備份等優勢,經過rsync能夠解決對實時性要求不高的數據備份需求,例如按期的備份文件
服務器數據到遠端服務器,對本地磁盤按期作數據鏡像等。
隨着應用系統規模的不斷擴大,對數據的安全性和可靠性也提出的更好的要求,rsync在高端業務系統中也逐漸暴露出了不少不足,首先,rsync同步數據時,須要掃描
全部文件後進行比對,進行差量傳輸。若是文件數量達到了百萬甚至千萬量級,掃描全部文件將是很是耗時的。並且正在發生變化的每每是其中不多的一部分,這是很是
低效的方式。其次,rsync不能實時的去監測、同步數據,雖然它能夠經過crontab方式進行觸發同步,可是兩次觸發動做必定會有時間差,這樣就致使了服務端和客戶端
數據可能出現不一致,沒法在應用故障時徹底的恢復數據。基於以上緣由,rsync+inotify組合出現了!
第二部分:配置Rsync + inotify
1、inotify簡介
inotify其實是Linux系統的一個內核特性(在Linux2.6.13中開始引入),它是一種高精度的異步文件系統事件監控機制,它監控文件系統操做,好比增刪改、移動等細微事件,並且至關靈敏。
能夠經過如下命令判斷當前內核是否支持,出現如下三個文件表明已支持該特性。
[root@CentOS74-01 ~]# ll /proc/sys/fs/inotify/ total 0 -rw-r--r-- 1 root root 0 Jul 7 17:02 max_queued_events -rw-r--r-- 1 root root 0 Jul 7 17:02 max_user_instances -rw-r--r-- 1 root root 0 Jul 7 17:02 max_user_watches
參數含義:
max_queued_events
設置inotify實例事件(event)隊列可容納的事件數量。
max_user_instances
設置每一個用戶能夠運行的inotifywait或inotifywatch命令的進程數。
max_user_watches
設置inotifywait或inotifywatch命令能夠監視的文件數量(單進程)。
若是監控的文件數目巨大,須要根據狀況,適當增長這些參數的大小,能夠達到優化性能的目的:
[root@CentOS74-01 ~]# echo 50000000 > /proc/sys/fs/inotify/max_queued_events [root@CentOS74-01 ~]# echo 50000000 > /proc/sys/fs/inotify/max_user_watches [root@CentOS74-01 ~]# echo 65535 > /proc/sys/fs/inotify/max_user_instances
將上面的命令行加入/etc/rc.d/rc.local文件裏,實現每次重啓系統都自動生效。
2、安裝inotify-tools工具包
前面說的inotify是內核特性,而inotify-tools則是一套使用C語言開發的第三方接口庫函數,它提供了兩個個已經編譯好的二進制命令,能夠對內核特性進行調用,更加方便得監控文件系統。
使用源碼包安裝:
[root@CentOS74-01 src]# ls inotify-tools-3.13.tar.gz root@CentOS74-01 src]# tar -zxf inotify-tools-3.13.tar.gz [root@CentOS74-01 src]# ls inotify-tools-3.13 inotify-tools-3.13.tar.gz [root@CentOS74-01 src]# cd inotify-tools-3.13 [root@CentOS74-01 inotify-tools-3.13]# ls aclocal.m4 ChangeLog config.h.in configure COPYING INSTALL libinotifytools Makefile.am man NEWS src AUTHORS config.guess config.sub configure.ac depcomp install-sh ltmain.sh Makefile.in missing README [root@CentOS74-01 inotify-tools-3.13]# ./configure --prefix=/usr/local/inotify [root@CentOS74-01 inotify-tools-3.13]# make && make install
安裝成功後在bin目錄下會生成inotifywait和inotifywatch兩個命令:
[root@CentOS74-01 bin]# pwd /usr/local/inotify/bin [root@CentOS74-01 bin]# ls inotifywait inotifywatch
命令做用
inotifywait 用來等待文件上的一個特定事件,能夠監控整個目錄樹的變化。
inotifywatch 它是用來收集被監控的文件系通通計數據。
inotifywait有豐富的參數,提供各類各樣的文件監控需求。
參數:
inotifywait參數含義說明
-r,--recursive遞歸查詢目錄
-q,--quiet打印不多的信息,僅僅打印監控事件的信息
-m,--monitor始終保持事件監聽狀態
--exclude排除文件或目錄時,不區分大小寫。
--timefmt指定時間輸出的格式
--format打印使用指定的輸出相似格式字符串
-e,--event經過此參數能夠指定須要監控的事件,以下一個列表所示
能夠監控的文件系統事件:
Events 含義
access 文件被訪問
modify 文件內容被修改
attrib 文件屬性被修改
close_write可寫文件被關閉
close_nowrite不可寫文件被關閉
open 文件被打開
moved_fron文件被移走
move_to 文件被移入
create 建立新文件
delete 文件被刪除
delete_self自刪除,一個可執行文件在執行時刪除自身
move_self自移動,一個可執行文件在執行時移動自身
umount 文件系統被卸載
close 文件被關閉(write或nowrite)
move 文件被移動(from或to)
3、rsync服務端配置
配置文件/etc/rsyncd.conf以下:
[root@CentOS74-02 ~]# cat /etc/rsyncd.conf uid = rsync gid = rsync use chroot = no log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock hosts allow = 192.168.1.160 [apache] path = /data/apache/ read only = yes auth users = bob secrets file = /etc/rsyncd.secrets
[root@CentOS74-02 ~]# cat /etc/rsyncd.secrets bob:bob123 [root@CentOS74-02 ~]# chmod 600 /etc/rsyncd.secrets [root@CentOS74-02 ~]# chown root.root /etc/rsyncd.secrets [root@CentOS74-02 ~]# ll /etc/rsyncd.* -rw-r--r-- 1 root root 721 Jul 7 18:49 /etc/rsyncd.conf -rw------- 1 root root 11 Jul 7 18:49 /etc/rsyncd.secrets [root@CentOS74-02 ~]# firewall-cmd --state running [root@CentOS74-02 ~]# systemctl stop firewalld.service [root@CentOS74-02 ~]# systemctl disable firewalld.service Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. [root@CentOS74-02 ~]# systemctl start rsyncd.service [root@CentOS74-02 ~]# netstat -nltp | grep 873 tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 1987/rsync [root@CentOS74-02 ~]#
4、rsync客戶端配置
在rsync客戶端上面進行以下配置:
[root@CentOS74-01 bin]# cat /etc/rsyncd.secrets bob123 [root@CentOS74-01 bin]# ll /etc/rsyncd.secrets -rw------- 1 root root 7 Jul 7 18:55 /etc/rsyncd.secrets
5、測試
報錯一:
[root@CentOS74-01 apache]# rsync -avz --password-file=/etc/rsyncd.secrets /data/apache/ bob@192.168.1.161::apache sending incremental file list ERROR: module is read only rsync error: syntax or usage error (code 1) at main.c(879) [Receiver=3.0.9] rsync: read error: Connection reset by peer (104) rsync error: error in rsync protocol data stream (code 12) at io.c(764) [sender=3.0.9]
緣由以下:
在rsync服務端的/etc/rsyncd.conf裏面,read only = yes,修改成read only = no,再測試:
報錯二:
[root@CentOS74-01 apache]# rsync -avz --password-file=/etc/rsyncd.secrets /data/apache/ bob@192.168.1.161::apache sending incremental file list apache_3.log rsync: mkstemp ".apache_3.log.LyMzT6" (in apache) failed: Permission denied (13) sent 122 bytes received 27 bytes 27.09 bytes/sec total size is 21 speedup is 0.14 rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1052) [sender=3.0.9]
緣由以下:
rsync服務端的/data/apache目錄屬主屬組是root.root,others組沒有寫的權限,運行以下命令:
[root@CentOS74-02 apache]# chmod -R o+w /data
報錯三:
[root@CentOS74-01 apache]# rsync -avz --password-file=/etc/rsyncd.secrets /data/apache/ bob@192.168.1.161::apache sending incremental file list ./ rsync: failed to set times on "." (in apache): Operation not permitted (1) sent 80 bytes received 11 bytes 8.67 bytes/sec total size is 21 speedup is 0.23 rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1052) [sender=3.0.9] -rw-r--r-- 1 rsync rsync 6 Jul 7 15:25 apache_3.log [root@CentOS74-02 apache]# ll total 12 -rw-r--r-- 1 root root 7 Jul 7 14:40 apache_1.log -rw-r--r-- 1 root root 8 Jul 7 14:41 apache_2.log -rw-r--r-- 1 rsync rsync 6 Jul 7 15:25 apache_3.log
緣由以下:
因爲rsync服務端/etc/rsyncd.conf裏面指定的uid和gid是用戶rsync,而服務器上面的/data/apache/的屬主和屬組是root.root,因此報錯,運行
下面的命令修改屬主和屬組爲 rsync.rsync
[root@CentOS74-02 ~]# chown -R rsync.rsync /data/apache/ [root@CentOS74-02 ~]# ll /data/apache/ total 8 -rw-r--r-- 1 rsync rsync 7 Jul 7 14:40 apache_1.log -rw-r--r-- 1 rsync rsync 8 Jul 7 14:41 apache_2.log
再次運行下面的命令,沒有報錯了:
[root@CentOS74-01 apache]# rsync -avz --password-file=/etc/rsyncd.secrets /data/apache/ bob@192.168.1.161::apache sending incremental file list ./ apache_3.log sent 125 bytes received 30 bytes 310.00 bytes/sec total size is 21 speedup is 0.14 [root@CentOS74-01 apache]#
6、編寫實時同步腳本
具體腳本內容以下:
[root@CentOS74-01 ~]# cat inotify_rsync.sh #!/bin/bash inotify=/usr/local/inotify/bin/inotifywait $inotify -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' -e delete,create,modify,close_write /data/apache | while read file do rsync -avz --password-file=/etc/rsyncd.secrets /data/apache/ bob@192.168.1.161::apache done
可使用 nohup將腳本掛到系統後臺運行:
[root@CentOS74-01 ~]# nohup sh /root/inotify_rsync.sh & [1] 7808 [root@CentOS74-01 ~]# nohup: ignoring input and appending output to ‘nohup.out’ [root@CentOS74-01 ~]# cat nohup.out [root@CentOS74-01 ~]#
在rsync客戶端建立測試文件:
[root@CentOS74-01 apache]# touch apache_{4..10}.log [root@CentOS74-01 apache]# ll total 12 -rw-r--r-- 1 root root 0 Jul 7 19:32 apache_10.log -rw-r--r-- 1 root root 7 Jul 7 14:40 apache_1.log -rw-r--r-- 1 root root 8 Jul 7 14:41 apache_2.log -rw-r--r-- 1 root root 6 Jul 7 15:25 apache_3.log -rw-r--r-- 1 root root 0 Jul 7 19:32 apache_4.log -rw-r--r-- 1 root root 0 Jul 7 19:32 apache_5.log -rw-r--r-- 1 root root 0 Jul 7 19:32 apache_6.log -rw-r--r-- 1 root root 0 Jul 7 19:32 apache_7.log -rw-r--r-- 1 root root 0 Jul 7 19:32 apache_8.log -rw-r--r-- 1 root root 0 Jul 7 19:32 apache_9.log [root@CentOS74-01 apache]#
在rsync服務端查看結果:
[root@CentOS74-02 apache]# ll total 12 -rw-r--r-- 1 rsync rsync 0 Jul 7 2018 apache_10.log -rw-r--r-- 1 rsync rsync 7 Jul 7 14:40 apache_1.log -rw-r--r-- 1 rsync rsync 8 Jul 7 14:41 apache_2.log -rw-r--r-- 1 rsync rsync 6 Jul 7 15:25 apache_3.log -rw-r--r-- 1 rsync rsync 0 Jul 7 2018 apache_4.log -rw-r--r-- 1 rsync rsync 0 Jul 7 2018 apache_5.log -rw-r--r-- 1 rsync rsync 0 Jul 7 2018 apache_6.log -rw-r--r-- 1 rsync rsync 0 Jul 7 2018 apache_7.log -rw-r--r-- 1 rsync rsync 0 Jul 7 2018 apache_8.log -rw-r--r-- 1 rsync rsync 0 Jul 7 2018 apache_9.log