Reference Document: https://vastxiao.github.io/article/2017/09/02/Linux/lsyncd_usage/
Prevent connection loss, saved to Baidu network-Zhengzhou-xxxxx
It is recommended to first view the reference document connection, the written comparison is complete
1. Introduction
Lsync official website: https: // axkibe.github.io/lsyncd/ LYSNCD is actually the LUA language that encapsulates the inotify and rsync tools, using the Linux kernel ( 2.6 . 13 and later) in the INotify trigger mechanism, and then through the rsync to the difference synchronization, to achieve real-time results. The brightest feature: the perfect solutionto the INotify +rsync Massive file synchronization brings file frequently sent file list problem-through the time delay or cumulative number of triggering events implemented. Its configuration is simple, and LUA itself is a configuration language that is very readable. LSYNCD also has a variety of operating modes to choose from, local directory CP, local directory rsync, remote directory rsyncssh. Enable simple and efficient local directory synchronous backups (NAS mounts are also treated as local directories), and a command is done.
2. Installation
# Yum installation requires Epel Source # Ali Epel Source Address: http: // mirrors.aliyun.com/help/epelYum Install LSYNCD
-y lua cmake rsyncversion=2.1. 5 -o lsyncd-release-${version?err}.tar.gz https://github.com/axkibe/lsyncd/archive/release-$ {version?err}.tar.gztar-zxvf lsyncd-release-${version? ERR}.TAR.GZCD lsyncd-release-${version? Err}cmake. Makesudo make install
3. Yum installation file structure
Path description /etc/lsyncd.conf Master profile /etc/sysconfig/LSYNCD init environment variable and startup options profile /etc/logrotate.d/LSYNCD Log Scroll configuration file /usr/share/doc/lsyncd-*/examples/ directory with lsyncd.conf configuration example /etc/init.d/lsyncd LSYNCD init startup script /usr/bin/lsyncd lsyncd command path /var /run/lsyncd/ lsyncd.pid directory /var/log/lsyncd/ default log directory
4. File configuration
one profile for LSYNCD overall classification: settings (global432 12) Use the custom event function. Comment: – Start with a comment
[Email protected] ~]# cat/etc/lsync.conf------User Configuration file forLSYNCD.----Simple Example for defaultrsync, but executing moves through on the target.----For more examples, see/usr/share/doc/lsyncd*/examples/--Settings {--pidfile ="/var/run/lsyncd/lsyncd.pid"--nodaemon =false, Inotifymode="Closewrite", Maxprocesses=8, Statusfile="/tmp/lsyncd.status", Statusinterval=Ten, logfile="/var/log/lsyncd/lsyncd.log"}--# Monitor local directory changes and update mtime time with touch. Flushmodifytime={delay=Ten, Maxprocesses=Ten, OnCreate="Touch ^sourcepathname", OnModify="Touch ^sourcepathname",}sync {default. Rsync,source="/opt/share", Target="[Email Protected]::beian", delete="Running",--exclude = {"logs"},delay=Ten, Init=false, rsync={binary="/usr/bin/rsync", archive=true, Compress=true, verbose=true, Password_file="/etc/rsyncd.d/rsync.pwd", _extra= {"--bwlimit=200" }}}-----------------------------------------------------------------------Start: Lsyncd-pidfile/var/run/lsyncd.pid/etc/lsyncd.conf
A real-world example: local directory Backup
[Email protected] ~]# cat/etc/lsyncd.confSettings {--pidfile ="/var/run/lsyncd/lsyncd.pid", --nodaemon =false, Inotifymode="Closewrite", Maxprocesses=8, Statusfile="/tmp/lsyncd.status", Statusinterval=Ten, logfile="/var/log/lsyncd/lsyncd.log"}sync {default. rsync, Source="/opt/webapplication", Target="/back_up/webapplication", delete="false", --exclude = {"logs"}, Delay=5, Init=false, rsync={binary="/usr/bin/rsync", archive=true, Compress=true, verbose=true, Bwlimit= -}}sync {default. rsync, Source="/data", Target="/back_up/data", delete="false", --exclude = {"logs"}, Delay=5, Init=false, rsync={binary="/usr/bin/rsync", archive=true, Compress=true, verbose=true, Bwlimit= -}}[[email protected]~]#
Lsync directory file Real-time Sync tool