我们已经设置了 lsyncd 来在两台主机之间同步数据。ssh 连接配置为使用用户 tomcat 和匹配的 id_rsa 身份文件。出于某种原因,遥控器上的追加/创建工作正常,但删除不起作用。当 rsync 尝试删除文件时,root 用户用于连接目标主机,而不是 tomcat 用户(用于创建/追加)。
在日志(/var/log/lsyncd/lsyncd.log)中,我们看到:
Wed Feb 15 13:48:24 2017 Normal: Rsyncing list
/test.txt
Wed Feb 15 13:48:26 2017 Normal: Finished (list): 0
Wed Feb 15 13:48:34 2017 Normal: Deleting list
/myfolder//test.txt
Received disconnect from 10.29.146.78: 2: Too many authentication failures for root
Wed Feb 15 13:48:41 2017 Normal: Retrying (list): 255
我们使用以下配置(/etc/lsyncd.conf):
settings{
pidfile = "/var/run/lsyncd.pid",
statusFile = "/var/tmp/lsyncd.status",
logfile = "/var/log/lsyncd/lsyncd.log",
statusInterval = 60,
logfacility = "user",
logident = "lsyncd",
inotifyMode = "CloseWrite",
maxProcesses = 10,
}
sync {
default.rsyncssh,
source = "/myfolder/",
delete = true,
host = "remote-host",
targetdir = "/myfolder/",
excludeFrom = "/etc/lsyncd/lsyncd.exclude",
delay = 5,
rsync = {
binary = "/usr/bin/rsync",
archive = true,
owner = true,
compress = true,
_extra = { "--bwlimit=50000", "--delete-after" },
rsh = "/usr/bin/ssh -l tomcat -i /usr/share/tomcat6/.ssh/id_rsa",
}
}
作为一种解决方法,我们可以使用/root/.ssh/config文件:
Host remote-host
Hostname remote-host
User tomcat
IdentityFile /usr/share/tomcat6/.ssh/id_rsa
当然,我们宁愿不必使用它,因为它应该与 lsyncd.conf 配置一起使用。
我们正在使用lsyncd 版本 2.1.4