In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Rsync introduction
Rsync, English full name is remote synchronize, is a remote synchronization function of free software, it can synchronize files at the same time, can maintain the permissions of the original files, time, soft and hard links and other additional information. Rsync provides a quick way to synchronize files between the client and the remote file server, and files can be transferred through ssh. It is even possible to synchronize only the changed parts of a file, so it is possible to synchronize data quickly. At the same time, rsync can also synchronize local data and delete files and directories.
Inotify introduction
Inotify is a Linux kernel feature that monitors the file system and issues timely event warnings to specialized applications, such as delete, read, write, and unmount operations. You can also track details such as the source and target of the activity.
Automatic synchronization based on rsync+notify
If you want to achieve timing synchronization data, you can add rsync to the timing task on the client side, but the synchronization time granularity of the timing task can not meet the requirements of real-time synchronization. The inotify file system monitoring mechanism is provided after Linux kernel 2.6.13. Real-time synchronization can be achieved through rsync+inotify combination.
Experimental requirements:
Source server: 192.168.177.132 (rsync,httpd)
Originator: 192.168.177.132 (rsync,httpd,inotify-tools)
Source server # rpm-Q rsync / / check if rsync has the configuration file # vim / etc/rsyncd.conf / / rsync installed uid = nobody gid = nobody use chroot = yes address = 192.168.177.132 port 873 log file = / var/log/rsyncd.log pid file = / var/run/rsyncd.pid hosts allow = 192.168.177.0) path = / var/www/html comment = www.kgc.cn read only = yes dont compress = *. Gz * .tgz * .zip * .z * .Z * .rpm * .deb * .bz2 auth users = backuper secrets file = / etc/rsyncd_users.db# vim / etc/rsyncd_users.db backuper:abc123 / / format of account and password # chmod 600 / etc/rsyncd_users.db# yum install httpd-y / / install web service # rsync-daemon / / start rsync service # systemctl stop firewalld.service / / turn off firewall # setenforce 0 / / add Strong security features # chmod 777 / var/www/html/# cd / var/www/html# echo "this is test" > 123.txt
The initiator # systemctl stop firewalld.service# setenforce 0 / / must first turn off firewall interaction. Enter the address of the source server # rsync-avz backuper@192.168.177.132::wwwroot / opt/ without entering the password # vim / etc/server.pass# chmod 600 / etc/server.pass# rsync-az-- delete-- password-file=/etc/server.pass backuper@192.168.177.132::wwwroot / opt
Rsync+inotify automatic synchronization
The inotify is installed at the initiator.
Rsync is on the source server
Source server: # vim / etc/rsyncd.conf read only = no# pkill-9 rsync# cd / var/run/# rm-rf rsyncd.pid / / delete pid process # rsync-daemon / / restart service initiator: # chmod 777 / var/www/html/# tar zxvf inotify-tools-3.14.tar.gz-C / opt / / decompress # cd inotify-tools-3.14/. / configure# yum install gcc gcc-c++-y / / install Compilation environment # make & & make install# vim / etc/sysctl.conf / / for optimization fs.inotify.max_queued_events = 16384fs.inotify.max_user_instances = 1024fs.inotify.max_user_watches = 104857 effective sysctl-p / / effective immediately # inotifywait-mrq-e modify Create,move,delete / var/www/html/ A site monitoring # vim / opt/inotify.sh / / write a script that can be synchronized #! / bin/bashINOTIFY_CMD= "inotifywait-mrq-e modify,create,attrib,move Delete / var/www/html/ "RSYNC_CMD=" rsync-azH-- delete-- password-file=/etc/server.pass / var/www/html/ backuper@192.168.177.132::wwwroot/ "$INOTIFY_CMD | while read DIRECTORY EVENT FILEdo if [$(pgrep rsync | wc-l)-le 0] Then $RSYNC_CMD fidone# chmod + x inotify.sh#. / inotify.sh
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: 203
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.