实时同步lsyncd
Lsyncd使用文件系统事件接口(inotify或fsevents)来监视对本地文件和目录的更改。Lsyncd将这些事件整理几秒钟,然后生成一个或多个进程以将更改同步到远程文件系统。默认同步方法是rsync Lsyncd是一种轻量级的实时镜像解决方案。Lsyncd相对容易安装,不需要新的文件系统或块设备。Lysncd不会妨碍本地文件系统性能,可以通过配置文件实现细粒度的自定义。自定义操作配置甚至可以从头开始编写,从shell脚本到用Lua语言编写的代码。
rsync服务端:默认就有rsync无需安装lsyncd客户端:安装lsyncd软件
在这里,备份服务器为服务端,存储服务器为客户端
[root@nfs ~]#yum install -y lsyncdbackup配置文件
[root@backup ~]#cat /etc/rsyncd.conf uid = rsync gid = rsync port = 873 fake super = yes use chroot = no max connections = 200 timeout = 300 pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log ignore errors read only = false list = false hosts allow = 172.16.1.0/24 auth users = rsync_backup secrets file = /etc/rsync.password [backup] comment = "backup dir by oldboy" path = /backuplsyncd配置文件
root@nfs ~]#cat /etc/lsyncd.conf 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@172.16.1.41::backup", delete= true, exclude = { ".*" }, delay = 1, rsync = { binary = "/usr/bin/rsync", archive = true, compress = true, verbose = true, password_file = "/etc/rsync.password", _extra = {"--bwlimit=200"} } }执行上述命令出现下图,则证明部署服务成功
转载于:https://www.cnblogs.com/basa/p/11297415.html