lsyncd服务器同步

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/millions_02/article/details/91418945

lsyncd


基本操作

启动
service  lsyncd start
重启
service  lsyncd restart
配置文件
/etc/lsyncd.conf

setting部分
--: 注释, 因为是lua 语言,所以 --是注释
logfile       : 指定lsyncd工具本身运行所产生的日志文件存放位置
statusFile    : 定义lsyncd监控目录状态文件的存放位置
statusInterval    : 隔多少秒记录一次被监控目录的状态
nodaemon=true     : 默认是不启用守护模式的
inotifyMode      : 指定要监控的事件,如,CloseWrite,Modify,CloseWrite or Modify, 默认是CloseWrite
maxProcesses     : 指定同步时进程的最大个数
maxDelays     : 当事件被命中累计多少次后才进行一次同步
sync部分
default.rsync  : 指定lsyncd运行模式,另外,还有>default.direct,default.rsyncssh模式
source      : 指定要监控的目录,务必全部用绝对路径
target      : 要同步到的目标目录,一般为rsync服务端模块下指定的目录,说明: '[email protected]::bak' , 'rsyncuser':同步的用户在备服务器上设置 ,'192.168.10.20':备服务器地址, '::backup':模块名称,同步路径在备服务器上设置
init        : 为false时表示只同步lsyncd进程启动以后发生改动事件的文件,否则,反之,默认为true
delay       : 当命中的事件累计到多少时再触发同步
exclude     : 通过此选项排除掉不需要同步的文件,可用它自己的正则进行匹配
delete 为了保持target与souce完全同步,Lsyncd默认会delete = true来允许同步删除。它除了false,还有startup、running值,请参考 Lsyncd 2.1.x ‖ Layer 4 Config ‖ Default Behavior。
delete = true  默认。 Lsyncd将在目标上删除不在源代码中的任何东西。在启动时以及在正常操作过程中被删除的内容
delete = false Lsyncd不会删除目标上的任何文件。不在启动或正常运行。 (虽然可以覆盖)
delete = 'startup' Lsyncd将在启动时删除目标上的文件,但不会进行正常操作。
delete = 'running' Lsyncd在启动时不会删除目标上的文件,但会删除那些在正常操作期间被删除的文件

作者:虚心的锄头
链接:https://www.jianshu.com/p/808d173786c4
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

配置举例

31机器
 targetdir="/tmp/htmlcopy/"}
settings {
        logfile = "/tmp/lsyncd.log",
        statusFile = "/tmp/lsyncd.status",
        statusInterval = 5,
        nodaemon = true
}
sync{default.rsyncssh, source="/mnt/html", host="172.16.0.30", targetdir="/mnt/html",exclude={"*.log","/api.kuaifa.tv/runtime/"},rsync = {owner = true, perms = true, group = true}}
sync{default.rsyncssh, source="/usr/local/openresty/nginx/conf/vhost", host="172.16.0.30", targetdir="/usr/local/openresty/nginx/conf/vhost",exclude={}}
30机器
settings {
        logfile = "/tmp/lsyncd.log",
        statusFile = "/tmp/lsyncd.status",
        statusInterval = 5,
        nodaemon = true,
        insist = true,
}
sync{default.rsyncssh, source="/mnt/html", host="172.16.0.31", targetdir="/mnt/html",exclude={"*.log","/mnt/html/premoadx/runtime/","/mnt/html/premossp/runtime/","/mnt/html/testmossp/public/jdsync/","/mnt/html/testmossp/public/jdsyncall/"},rsync = {owner = true, perms = true, group = true}}
sync{default.rsyncssh, source="/usr/local/openresty/nginx/conf/vhost", host="172.16.0.31", targetdir="/usr/local/openresty/nginx/conf/vhost",exclude={}}

猜你喜欢

转载自blog.csdn.net/millions_02/article/details/91418945
今日推荐