In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
rsybc+inotify Description of enterprise case environment: synchronize data on a mongod to a remote host in real time Server address allocation: backup 172.16.1.88(rsync server) Backup source 172.16.1.89(rsync client inotify mongod) The synchronized directory is/var/lib/mongo/, the order of automatic synchronization is 172.16.1.89---172.16.1.88, we can configure the rsync server. First, configure the rsync server 172.16.1.881. First use the rpm -qa command to check whether the rsync package has been installed on the system. [root@liuran ~]# rpm -qa |grep rsyncrsync-3.0.6-5.el6_0.1.x86_642.rsync After installation, there is no configuration file for the host. So we need to manually create rsync configuration [root@liuran ~]# vim /etc/rsyncd.confuid = rootgid = rootuse chroot = nomax connections = 20timeout = 600pid file = /var/run/rsyncd.pidlock file = /var/run/rsyncd.locklog file = /var/log/rsyncd.log[web_log]path = /data/web_log/ignore errorsread only = falselist = falsehosts allow = 172.16.1.89auth users = backusersecrets file = /etc/rsync.password3. Create rsync username and password file [root@liuran ~]# echo "backuser:123" >/etc/rsync.password4. Authorization for/etc/rsync.password is 600(this file)[root@liuran ~]# chomo -R 600 /etc/rsync.password Here, server-side configuration is complete. Second, client configuration 1, set the rsync client password file, the client only needs to set the rsync synchronization password, Do not reset the user name 2. Set the password file permissions to 600 [root@asdasda ~]# chmod -R 600 /etc/rsync.password Configure Inotify(configured in mongod) http://github.com/downloads/rvocilas/inotify-tools/inotify-tools-3.14.tar.gz [root@asdasda ~]# tar zxf inotify-tools-3.14.tar.gz [root @ asdasda ~]# cd inotify-tools-3.14[root@asdasda inotify-tools-3.14]# ./ configure && make && make install2. In order to ensure that the/var/lib/mongod directory is automatically synchronized, after configuring the inotify of mongod, write an inotify script. [root@asdasda ~]# cat a.sh #!/ bin/bashsrc=/var/lib/mongo/des=web_logip=172.16.1.88/usr/local/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' -e modify,delete,create,attrib ${src} \| while read filedorsync -vzrtopg --delete --progress $src backuser@172.16.1.88::$des --password-file=/etc/rsync.password > /dev/null 2>&1 && echo "$src was rsynced"done
This script is used to monitor changes in file directories through Inotify, which triggers rsync to synchronize operations. Because this process is an active trigger operation, done through the system kernel, it is much more efficient than scanning through the entire directory.
Then we put this script in the background and type the following command:
sh /root/rsync.sh&
Next we test above mongod, insert data, see if the real-time synchronization data file to 172.16.1.88 above
Script insert data
[root@asdasda mongo]# cat /root/b.sh
#!/ bin/bash
for i in {1.. 2000}
do
mongo
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.
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.