RenwoleServer: 10.28.204.65 server
RenwoleClient: 10.28.204.66 client
OS:CentOS Linux release 7.4.1708 (Core) x64
See:《 CentOS 7 Configure Rsync Data File Synchronization Server 》。
$ yum install -y gcc gcc-c++ lua lua-devel cmake libxml2 libxml2-devel
$ wget //github.com/axkibe/lsyncd/archive/release-2.2.2.tar.gz $ tar xvf release-2.2.2.tar.gz $ cd lsyncd-release-2.2.2 $ cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lsyncd $ make && make install $ ln -s /usr/local/lsyncd/bin/lsyncd /usr/bin/lsyncd
$ vim /etc/lsyncd.conf
settings { Logfile="/var/log/lsyncd. log", -- log path StatusFile="/var/log/lsyncd. status", -- status file Pidfile="/var/run/lsyncd. pid", -- pid file path StatusInterval=1, -- the shortest time to write the status file Nodaemon=false, -- daemon running MaxProcesses=1, -- Maximum Processes MaxDelays=1, -- maximum delay } sync { Default.rsyncssh, -- default rsync+ssh, rsync version needs to be upgraded to more than 3 versions Source="/apps/www/renwoleblog/", -- source directory Delete=true, -- keep full synchronization host = " root@10.28.204.66 ", Targetdir="/apps/www/renwoleblog/bak/", -- target directory exclude={ ". txt" -- files to be excluded }, rsync = { Binary="/usr/bin/rsync", -- install rsync first Archive=true, -- archive Compress=false, -- compression Owner=true, -- owner Perms=true, -- permission whole_file = false }, ssh = { port = 22 } }
sync { default.rsync, source = "/apps/www/renwoleblog/", target = "/apps/www/renwoleblog/bak/", }
sync { default.rsync, source = "/apps/www/renwoleblog/", target = " renwole@10.28.204.65 ::renwolecom", delete="true", exclude = { ".bak*" }, delay = 30, init = false, rsync = { binary = "/usr/bin/rsync", archive = true, compress = true, verbose = true, perms = true, password_file = "/etc/rsync.password", _extra = {"--bwlimit=200"} } }
--# Comment Settings # is global configuration Sync # Define synchronization parameters Rsync # Define synchronization file parameters Ssh # Define the server remote port
$ vim /etc/sysconfig/lsyncd
LSYNCD_OPTIONS="/etc/lsyncd.conf"
$ vim /usr/lib/systemd/system/lsyncd.service
[Unit] Description=Live Syncing (Mirror) Daemon After=network.target [Service] Type=simple EnvironmentFile=-/etc/sysconfig/lsyncd ExecStart=/usr/local/lsyncd/bin/lsyncd -nodaemon $LSYNCD_OPTIONS [Install] WantedBy=multi-user.target
$ systemctl start lsyncd $ systemctl enable lsyncd
[ root@RenwoleServer ~] $ cat /var/log/lsyncd.log
... Fri Dec 22 01:19:22 2017 Normal: Calling rsync with filter-list of new/modified files/dirs / PCHunter_renwole.com.tar.gz / Fri Dec 22 01:19:24 2017 Normal: Finished (list): 0 Fri Dec 22 01:19:32 2017 Normal: Calling rsync with filter-list of new/modified files/dirs / PCHunter_renwole.com.tar.gz / Fri Dec 22 01:19:34 2017 Normal: Finished (list): 0 Fri Dec 22 01:19:34 2017 Normal: Calling rsync with filter-list of new/modified files/dirs / PCHunter_renwole.com.tar.gz / Fri Dec 22 01:19:36 2017 Normal: Finished (list): 0