lsyncd, 服务器数据同步工具

服务器数据同步工具,lsyncd
创建证书 ssh 信任
ssh-keygen
把证书复制到需要同步的客户机

ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.100.110

centos 6.x 运行

ssh-copy-id  -i /root/.ssh/id_rsa.pub "  root@192.168.100.110"

ssh 登录过去,看是否已经信任, 第一次可能需要确认,

安装依赖

yum install lua lua-devel pkgconfig gcc asciidoc

yum安装方式

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum install lsyncd

编辑配置文件
vim /etc/lsyncd.conf
启动进程

systemctl start lsyncd

查看任务状态

systemctl status lsyncd

centos 6 运行

service lsyncd start
service lsyncd status

配置文件参考

----
-- User configuration file for lsyncd.
--
-- Simple example for default rsync.
--

settings {
    logfile ="/var/log/lsyncd.log",
    statusFile = "/tmp/lsyncd.stat",
    statusInterval = 1,
}

sync {
    default.rsyncssh,
    source    = "/data/webroot/hahabao",
    host      = "192.168.100.110",
    targetdir = "/data/webroot/hahabao",
    excludeFrom = "/etc/rsyncd.d/rsync_exclude.lst",
    -- maxDelays = 5,
    delay = 0,
    -- init = false,
    rsync    = {
        binary = "/usr/bin/rsync",
        archive = true,
        compress = true,
        verbose   = true,
        _extra = {"--bwlimit=2000"},
        },
    ssh      = {
        port  =  22
        }
    }

Leave a Comment