简体   繁体   English

Lsync 未在主-主/双向设置中以正确的顺序处理文件

[英]Lsync not processing files in the correct order in a master-master/bi-directional setup

I'm using LSync to synchronize the web root for two separate CentOS 7 servers running Apache.我正在使用 LSync 来同步两个运行 Apache 的独立 CentOS 7 服务器的 Web 根目录。 So far, it seems to be running decently, but every so often, I notice that lsync doesn't process the files properly.到目前为止,它似乎运行良好,但每隔一段时间,我就会注意到 lsync 无法正确处理文件。

An example of the issue I'm having - If I have a file called hello-world.txt on server01 and server02 , and I delete it from server01 , when lsync runs, instead of deleting it from server02 , it actually re-creates it on server01 .我有这个问题的一个例子-如果我有一个名为Server01上和Server02上HELLO-world.txt文件,我从SERVER01删除它,当LSYNC运行,而不是从Server02上删除它,它实际上重新创建它在server01 上

I haven't found anything online about this, and I'm new to using lsync, so I'm not quite sure how to go about fixing this.我还没有在网上找到任何关于此的信息,而且我是使用 lsync 的新手,所以我不太确定如何解决这个问题。

Not sure it's needed, but here's the lsync configuration file ( /etc/lsyncd.conf ):不确定是否需要,但这里是 lsync 配置文件( /etc/lsyncd.conf ):

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

sync {
    default.rsync,
    source="/var/www/",
    target="192.168.1.36:/var/www/",
    rsync={
        rsh = "/usr/bin/ssh -l lsync -i /etc/lsync/.ssh/id_rsa", 
    }
}

Any help would be appreciate!任何帮助将不胜感激! thanks!谢谢!

lsyncd does not do bidirectional synchronization; lsyncd不做双向同步; its purpose is to make that directory look like this directory, continuously.它的目的是使目录看起来像这个目录,持续不断。

You could achieve the same effect by running rsync as a cron job.您可以通过将 rsync 作为 cron 作业运行来实现相同的效果。 The only difference is that lsyncd is more responsive when files are changed, and more efficient when files are idle.唯一的区别是 lsyncd 在更改文件时响应更快,在文件空闲时更高效。

With extreme care, you could set up lsyncd on both servers, syncing in both directions, and then you might get what you want, but that relies on updates being not too rapid (when server01 sends an update to server02, server02 will detect that change and attempt to send it right back to server01, which is harmless as long as that file has not changed again ).非常小心,你可以在两台服务器上设置 lsyncd,双向同步,然后你可能会得到你想要的,但这依赖于更新不是太快(当 server01 向 server02 发送更新时,server02 将检测到该更改并尝试将其直接发送回 server01,只要该文件没有再次更改,这是无害的)。 I'd not recommend this setup;我不推荐这种设置; use SyncThing, or only make edits to the "master" server.使用 SyncThing,或者只对“主”服务器进行编辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM