lsyncd —— 多机器实时同步文件神器

官网

https://axkibe.github.io/lsyncd/

参考文档

https://shockerli.net/post/linux-tool-lsyncd/

配置多机互信

ssh-keygen -t rsa
ssh-copy-id -i  .ssh/id_rsa.pub [email protected]

安装

yum -y install lsyncd

配置文件

ssh 认证同步多台主机文件 /etc/lsyncd.conf

settings {
    nodaemon = false,
    logfile = "/var/log/lsyncd.log",
    statusFile = "/var/log/lsyncd.status",
    inotifyMode = "CloseWrite",
    maxProcesses = 8
}

-- 可以有多个sync,各自的source,各自的target,各自的模式,互不影响。
sync {
    default.rsyncssh,
    source    = "/home/tomcat/logs/",
    host    = "[email protected]",
    targetdir   = "/home/www/logs/",
    delay = 0,
    rsync = {
        binary = "/usr/bin/rsync",
        archive = true,
        compress = true,
        verbose = true
    },
}

开机启动

centos6

/etc/init.d/lsyncd start
chkconfig lsyncd on

centos7

systemctl start lsyncd
systemctl enable lsyncd
systemctl status lsyncds

你可能感兴趣的:(lsyncd —— 多机器实时同步文件神器)