本文作者: 五行哥

QQ: 1226032602

E-mail: 1226032602@qq.com

官方文档

https://axkibe.github.io/lsyncd/

https://github.com/axkibe/lsyncd

简介

Lsyncd使用文件系统事件接口(inotify或fsevents)来监视对本地文件和目录的更改。Lsyncd将这些事件整理几秒钟,然后生成一个或多个进程以将更改同步到远程文件系统。默认同步方法是rsync

Lsyncd是一种轻量级的实时镜像解决方案。Lsyncd相对容易安装,不需要新的文件系统或块设备。Lysncd不会妨碍本地文件系统性能

可以通过配置文件实现细粒度的自定义。自定义操作配置甚至可以从头开始编写,从shell脚本到用Lua语言编写的代码

版本要求

Lsyncd 2.2.1要求所有源和目标计算机上的rsync> = 3.1

安装

lsyncd 在 epel源中

yum install lsyncd

配置

配置文件说明 /etc/lsyncd.conf

lsyncd配置文件使用lua语法编写

settings
settings {
logfile 日志文件
pidfile pid文件
nodaemon 表示不启用守护模式,默认
statusFile 运行状态文件
statusInterval 将lsyncd的状态写入上面的statusFile的间隔,默认10秒
inotifyMode 指定inotify监控的事件,默认是CloseWrite,还可以是Modify或CloseWrite or Modify
maxProcesses 最大进程数
maxDelays 累计多少监控事件同步一次,即使delay时间未到也同步
}

sync 三种模式

default.rsync

sync {
default.rsync,
source = "/tmp/src",
target = "172.29.88.223:/tmp/dest",
maxDelays = 5,
delay = 30,
-- init = true,
rsync = {
binary = "/usr/bin/rsync",
archive = true,
compress = true,
bwlimit = 2000
rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"
}
}

rsync daemon

sync {
default.rsync,
source = "/tmp/src",
target = "rsync_backup@172.16.1.41::backup",
delete="running",
exclude = { ".*", ".tmp" },
delay = 3,
init = false,
rsync = {
binary = "/usr/bin/rsync",
archive = true,
compress = true,
verbose = true,
password_file = "/etc/rsync.pwd",
_extra = {"--bwlimit=200"}
}
}

default.rsyncssh

sync {
default.rsyncssh,
source="/srcdir",
host="remotehost",
excludeFrom="/etc/lsyncd.exclude",
targetdir="/dstdir",
rsync = {
archive = true,
compress = false,
whole_file = false
},
ssh = {
port = 1234
}
}

default.direct

sync {
default.direct,
source = "/home/user/src/",
target = "/home/user/trg/"
}

/etc/lsyncd.conf

settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status",
inotifyMode = "CloseWrite",
maxProcesses = 8,
}
sync {
default.rsync,
source = "/tmp/src",
target = "rsync_backup@172.16.1.41::backup",
delete="running",
exclude = { ".*", ".tmp" },
delay = 3,
init = false,
rsync = {
binary = "/usr/bin/rsync",
archive = true,
compress = true,
verbose = true,
password_file = "/etc/rsync.pwd",
_extra = {"--bwlimit=200"}
}
}
sync {
default.rsync,
source = "/tmp/src",
target = "rsync_backup@172.16.1.41::wuxing",
delete="running",
exclude = { ".*", ".tmp" },
delay = 3,
init = false,
rsync = {
binary = "/usr/bin/rsync",
archive = true,
compress = true,
verbose = true,
password_file = "/etc/rsync.pwd",
_extra = {"--bwlimit=200"}
}
}

delete

delete	=	true       #在目标上删除源中没有的内容。在启动时以及在正常操作期间删除的内容
delete = false #不会删除目标上的任何文件。不在启动时也不在正常操作上
delete = 'startup' # Lsyncd将在启动时删除目标上的文件,但不会在正常操作时删除
delete = 'running' # Lsyncd在启动时不会删除目标上的文件,但会删除正常操作期间删除的文件
settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status",
inotifyMode = "CloseWrite",
maxProcesses = 8,
}
sync {
default.rsync,
source = "/data",
target = "rsync_backup@backup::backup",
delete= true,
exclude = { ".*" },
delay = 1,
rsync = {
binary = "/usr/bin/rsync",
archive = true,
compress = true,
verbose = true,
password_file = "/etc/rsync.pwd",
_extra = {"--bwlimit=200"}
}
}

最新文章

  1. iOS 10 新特性 大汇总 及iOS 10 的一些小问题和 xcode 8 的新版本小问题
  2. 动态主机配置协议(DHCP)如何启动和关闭
  3. 第 19 章 CSS 其他样式
  4. 自问自答-hadoop自带哪些案例(0.20.2)
  5. 1072. Gas Station (30)
  6. WCF 采用net.tcp协议
  7. Docker - 虚拟网桥
  8. 过度拟合(overfilting)
  9. 使用BurpSuite进行双文件上传拿Webshell
  10. Django学习之二:Django 项目创建 和 应用创建
  11. Vue原理--虚拟DOM
  12. mongod.service: control process exited, code=exited status=1
  13. CodeForces - 1051D Bicolorings(DP)
  14. 实例详析ImageView的adjustViewBonds和scaleType
  15. #505 1&2 A-C 后面未完成
  16. composer 安装yii2 The package is not available in a stable-enough version解决办法
  17. 网络io模式(服务器请求应答模式)
  18. Spring4.2 集成ActiveMQ5.14
  19. redis学习之一 - linux下安装配置
  20. scrapy 采集网页出现丢失url的问题

热门文章

  1. VMwareSDN环境配置之git安装
  2. WPF 实现文件、图标拖放功能(支持UAC的那种)
  3. 看图王 10.9.1.9791 With X64 去广告绿色版
  4. Mysql去重获取最新的一条数据
  5. Maven项目中配置文件资源导出问题
  6. linux命令行大量零碎练习习题集-打包未整理
  7. MYSQL --存储引擎的对比
  8. vue封装全局确认弹窗
  9. QT部署安装以及后续更新(一)
  10. NLog日志 富文本编辑器