https://github.com/axkibe/lsyncd

Lsyncd watches a local directory trees event monitor interface (inotify or fsevents). It aggregates and combines events for a few seconds and then spawns one (or more) process(es) to synchronize the changes. By default this is rsync. Lsyncd is thus a light-weight live mirror solution that is comparatively easy to install not requiring new filesystems or block devices and does not hamper local filesystem performance.

Lsyncd 监视本地目录树事件监视器接口(inotify或fsevents)。它聚合并组合事件几秒钟,然后生成一个(或多个)进程来同步更改。默认情况下,这是rsync。因此,Lsyncd是一种轻量的实时镜像解决方案,相对容易安装,不需要新的文件系统或块设备,也不会影响本地文件系统的性能。

rsync服务端(wallet01)
[root@wallet01 ~]# yum install -y xinetd
[root@wallet01 ~]# yum install -y rsync

[root@wallet01 ~]# vi /etc/xinetd.d/rsync
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
#       allows crc checksumming etc.
service rsync
{
        disable = no
        flags           = IPv6
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID
}

[root@wallet01 ~]# vi /etc/rsyncd.conf 
uid = root
gid = root
use chroot = no
max connections = 1000
transfer logging = true
log format = "%o %h [%a] %m (%u) %f %l"
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
secrets file = /etc/rsyncd.pwd
fake super = yes

[oracle]
path = /home/oracle/backup
auth users = oracle
uid = oracle
gid = oinstall
read only = no

[root@wallet01 ~]# vi /etc/rsyncd.pwd
oracle:abcd.1234
[root@wallet01 ~]# chmod 600 /etc/rsyncd.pwd

[root@wallet01 ~]# service xinetd start
Starting xinetd:                                           [  OK  ]

rsync客户端(wallet02)
[root@wallet02 ~]# yum install -y lua lua-devel
[root@wallet02 ~]# yum install -y rsync
[root@wallet02 ~]# yum install -y lsyncd

[root@wallet02 ~]# vi /etc/lsyncd.conf
settings {
    logfile      ="/var/log/lsyncd/lsyncd.log",
    statusFile   ="/var/log/lsyncd/lsyncd.status",
    inotifyMode  = "CloseWrite",
    maxProcesses = 8,
    -- nodaemon =true,
    }
sync {
    default.rsync,
    source    = " /home/oracle/backup",
    target    = "[email protected]::oracle",
    delete    = "false",
    -- excludeFrom = "/etc/rsyncd.d/rsync_exclude.lst",
    rsync     = {
        binary    = "/usr/bin/rsync",
        archive   = true,
        compress  = true,
        verbose   = true,
        password_file = "/etc/rsyncd.pwd"
        _extra    = {"--bwlimit=200"}
        }
    }
    
[root@wallet02 ~]# vi /etc/rsyncd.pwd
abcd.1234
[root@wallet02 ~]# chmod 600 /etc/rsyncd.pwd  

[root@wallet02 ~]# /etc/init.d/lsyncd start
Starting lsyncd:                                           [  OK  ]
[root@wallet02 ~]# /etc/init.d/lsyncd status
lsyncd (pid  3282) is running...