码迷,mamicode.com
首页 > 其他好文 > 详细

配置Rsync和Rsync + inotify

时间:2018-07-07 23:56:42      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:attrs   配置文件   开机启动   cloc   linux   命令行   无密码   --   部分   

第一部分:配置Rsync


一、介绍Rsync工具

    rsync是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件。它使用所谓的“Rsync演算法”来使本地和远程两个主机之间的文件达到同步,这个算法只传送两个文件的不同部分,而不是每次都整份传送,因此速度相当快。所以通常可以作为备份工具来使用。

Rsync的特性如下:

1)支持拷贝特殊文件如链接,设备等

2)可以有排除指定文件或目录同步的功能,相当于打包命令tar

3)可以保持原来文件或目录的权限,时间,软硬链接等所有属性均不改变。

4)可实现增量同步,即只同步发生变化的数据,因此数据传输效率更高

5)可以使用rcp,rsh,ssh等方式来配合传输文件,也可以通过直接的socker链接

6)支持匿名的或认证的进程模式传输,方便进行数据备份及镜像。


二、测试环境

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) 


三、配置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 ~]#

四、rsync的不足

    与传统的cp、tar备份方式相比,rsync具有安全性高、备份迅速、支持增量备份等优点,通过rsync可以解决对实时性要求不高的数据备份需求,例如定期的备份文件

服务器数据到远端服务器,对本地磁盘定期做数据镜像等。

    随着应用系统规模的不断扩大,对数据的安全性和可靠性也提出的更好的要求,rsync在高端业务系统中也逐渐暴露出了很多不足,首先,rsync同步数据时,需要扫描

所有文件后进行比对,进行差量传输。如果文件数量达到了百万甚至千万量级,扫描所有文件将是非常耗时的。而且正在发生变化的往往是其中很少的一部分,这是非常

低效的方式。其次,rsync不能实时的去监测、同步数据,虽然它可以通过crontab方式进行触发同步,但是两次触发动作一定会有时间差,这样就导致了服务端和客户端

数据可能出现不一致,无法在应用故障时完全的恢复数据。基于以上原因,rsync+inotify组合出现了!



第二部分:配置Rsync + inotify


一、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文件里,实现每次重启系统都自动生效。


二、安装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)


三、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 ~]#

四、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

五、测试

报错一:

[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]#

六、编写实时同步脚本

具体脚本内容如下:

[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


配置Rsync和Rsync + inotify

标签:attrs   配置文件   开机启动   cloc   linux   命令行   无密码   --   部分   

原文地址:http://blog.51cto.com/2612012/2138653

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!