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 root@192.168.31.x

安装

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    = "www@192.168.x.x",
    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
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。