配置密钥:
ssh-keygen
Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:ELUEV7kCJjr5ZkY4UehAgheS7G8gDWJLA/x3n+eyXuU root@localhost.localdomain The key's randomart image is: +---[RSA 2048]----+ |Xo.+. oo+... | |BB+ . o+ .. | |=*+= o... . | |.+O... o. . | |. o=. . S.. . | | o= o .o | | .+ o. E | | ... | | .oo | +----[SHA256]-----+
将密钥拷贝到接收端
ssh-copy-id -i /root/.ssh/id_rsa.pub root@10.254.19.10
安装lsyncd依赖包
yum -y install asciidoc gcc lua lua-devel pkgconfig
安装lsyncd rpm资源,并安装lsyncd
rpm -iUvh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm yum -y install lsyncd
配置lsyncd
\cp -f /usr/share/doc/lsyncd-2.2.2/examples/lrsync.lua /etc/lsyncd.conf vim -b /etc/lsyncd.conf
----
-- User configuration file for lsyncd.
--
-- Simple example for default rsync.
--
settings {
logfile = "/var/log/lsyncd.log",
statusFile = "/tmp/lsyncd.stat",
statusInterval = 1
}
sync{
default.rsync,
source="/home/wwwroot",
target="root@10.254.19.10:/home/wwwroot",
init = false,
delete = false,
delay = 3,
rsync = {
binary = "/usr/bin/rsync",
compress = true,
archive = true,
verbose = true
}
}
启动lsyncd服务,并设置开机启动
systemctl start lsyncd systemctl enable lsyncd
参考:
https://www.cnblogs.com/betx/p/6524760.html
实战详细配置:
https://blog.csdn.net/rainsirius/article/details/80200538
参数详解:
https://blog.csdn.net/weiguang1017/article/details/52183237
没有帐号? 立即注册