我在我的主服务器上运行了 lsyncd,以同步所有服务器上的文件。但是当我添加另一个要同步的文件夹时,该服务将无法重新启动。我似乎在日志中找不到任何错误。我不是 Lua 专家,所以可能很明显我错过了一些东西。
这是我的原始脚本,有效:
settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status",
statusInterval = 10
}
servers = {
"user@xx.xx.xx.xx",
"user@xx.xx.xx.xx"
}
for _, server in ipairs(servers) do
sync {
default.rsyncssh,
source="/path/to/source/folder/one",
host=server,
targetdir="/path/to/target/folder/one",
excludeFrom="/etc/lsyncd/lsyncd-excludes.txt",
rsync = {
compress = true,
archive = true,
verbose = true,
rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"
}
}
end
这是不起作用的脚本,我在其中添加了另一个文件夹:
settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status",
statusInterval = 10
}
servers = {
"user@xx.xx.xx.xx",
"user@xx.xx.xx.xx"
}
for _, server in ipairs(servers) do
sync {
default.rsyncssh,
source="/path/to/source/folder/one",
host=server,
targetdir="/path/to/target/folder/one",
excludeFrom="/etc/lsyncd/lsyncd-excludes.txt",
rsync = {
compress = true,
archive = true,
verbose = true,
rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"
}
}
sync {
default.rsyncssh,
source="/path/to/source/folder/two",
host=server,
targetdir="/path/to/target/folder/two",
excludeFrom="/etc/lsyncd/lsyncd-excludes.txt",
rsync = {
compress = true,
archive = true,
verbose = true,
rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"
}
}
end
我也尝试将它们放在两个不同的循环中,但仍然没有运气。花了几个小时在互联网上寻找答案,但我发现的一切都表明我做得正确。