Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Lsync installation configuration (directory synchronization)

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

List of hosts:

Server: 172.16.2.5/sense2 destination: 172.16.2.4/sense1

Service startup: / usr/bin/lsyncd / etc/lsyncd.conf

Service shutdown: ps-ef | grep lsyncd | grep-v grep | awk'{print $2}'| xargs kill

Lsyncd advantages: the official website and virbox distribution release two nodes each time, release the sense2 version, and manually execute the scp synchronization file to the sense1 corresponding directory. The use of lsyncd avoids scp, simplifies the publishing process, only needs to be published on sense2, and prevents scp files from being prone to errors.

1. Server side (sense2) installation:

Yum install epel-releaseyum install lsyncd

two。 Target side (sense1) installation:

Yum install rsync

3. Server configuration:

Vim / etc/lsyncd.confsettings {logfile = "/ var/log/lsyncd/lsyncd.log", # log file status File = "/ var/log/lsyncd/lsyncd.status", # status file inotifyMode = "CloseWrite or Modify", # specify inotify monitoring event} sync {default.rsyncssh, # synchronize to remote host directory, ssh mode of rsync, transfer using ssh The premise is that the trust relationship between the server and the target is established. Source = "/ usr/share/nginx/html/", # local directory synchronization host = "172.16.2.5", # remote host targetdir = "/ home/data/bakk/", # remote synchronization directory delay = 30, # waiting for rsync synchronization delay time, that is, 30s time to monitor changes under the directory, will accumulate a rsync synchronization. If 30s makes two changes to a file, the second modification will be synchronized. Delete = true, # keep target consistent with source. Default parameters. This parameter is used when lsyncd is started. After startup, add, delete and modify operations are made in the remote synchronization directory, and the corresponding files in the local directory will not be synchronized. Rsync = {binary = "/ usr/bin/rsync", owner = true, # retain server owner group = true, # retain server group perms = true, # retain server permissions}}

4. Start lsync:

/ usr/bin/lsyncd / etc/lsyncd.conf

5. Test:

Synchronize / usr/share/nginx/html on sense2 into sense1/home/data/bakk. Listen for directory changes in real time, and synchronize any changes. Compare the synchronization directory on sense1 with the / usr/share/nginx/html file of sense1, and the file is consistent. Comparison method: find. / bakk-type f | xargs openssl md5 | awk-F "='{print $2}'> a.txt find / usr/share/nginx/html-type f | xargs openssl md5 | awk-F" ='{print $2}'> b.txt diff a.txt b.txt

Reference document: https://axkibe.github.io/lsyncd/manual/invoking/

Https://www.cnblogs.com/zxci/p/6243574.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report