In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Download address of required software:
Http://pan.baidu.com/s/1ikubG
Http://pan.baidu.com/s/1d0C1L
This experiment realizes one-way synchronization and non-two-way synchronization.
Experimental environment: two virtual machines, I have two CentOS5.5
Software deployment:
Server side (IP:192.168.1.104): rsync-3.0.9.tar.gz and inotify-tools-3.14.tar.gz
Client (IP:192.168.1.108): rsync-3.0.9.tar.gz
Steps:
[root@CentOS5smb] # ls
Inotify-tools-3.14.tar.gz rsync-3.0.9.tar.gz
[root@CentOS5smb] # tar zxvf rsync-3.0.9.tar.gz-C / gwq/20130616/
[root@CentOS5smb] # cd / gwq/20130616/rsync-3.0.9
[root@CentOS5rsync-3.0.9] #. / configure-prefix=/usr/local/rsync
[root@CentOS5rsync-3.0.9] # make
[root@CentOS5rsync-3.0.9] # make install
[root@CentOS5rsync-3.0.9] # cd / usr/local/rsync/
[root@CentOS5rsync] # echo "rsync-pwd" > / usr/local/rsync/rsync.passwd
/ rsync-pwd is a password and can be customized
[root@CentOS5rsync] # chmod 600 rsync.passwd
/ / to avoid unnecessary errors, please change the permission to 600
Rsync on this server has been installed, but it hasn't been configured yet. Let's install inotify first, and then configure rsync later.
[root@CentOS5smb] # ls
Inotify-tools-3.14.tar.gz rsync-3.0.9.tar.gz
[root@CentOS5smb] # tar zxvf inotify-tools-3.14.tar.gz-C / gwq/20130616/
[root@CentOS5smb] # cd / gwq/20130616/inotify/
[root@CentOS5inotify-tools-3.14] #. / configure-prefix=/usr/local/inotify
[root@CentOS5inotify-tools-3.14] # make
[root@CentOS5inotify-tools-3.14] # make install
Now configure rsync
Create a new rsync.sh file, and here I create a new rsync.sh under / tmp
[root@CentOS5tmp] # vi rsync.sh
# / bin/bash
Host=192.168.1.108 / / client IP address
Src=/tmp / directories to be monitored by the server in real time
Des=web / certified module name, which needs to be consistent with the client
User=webuser / / establish the authenticated user in the password file
/ usr/local/inotify/bin/inotifywait-mrq--timefmt'%d/%m/%y%H:%M'--format'%T%w%f%e'-emodify,delete,create,attrib$src\
| | whilereadfiles |
Do
/ usr/bin/rsync-vzrtopg--delete--progress--password-file=/usr/local/rsync/rsync.passwd$src$user@$host::$des
Echo "${files} wasrsynced" > > / tmp/rsync.log2 > & 1
Done
[root@CentOS5tmp] # chmod 764 rsync.sh
[root@CentOS5tmp] # sh rsync.sh& / run the script in the background
[root@CentOS5tmp] # echo "/ tmp/rsync.sh" > > / etc/rc.local/rsync.sh / the script is added to the boot entry
[root@CentOS5tmp] # touch / etc/rsyncd.conf / create an empty rsyncd.conf file under etc
Now that the server has been configured, let's configure the client
Client configuration, download and install rsync
[root@CentOS5gwq] # ls
Rsync-3.0.9.tar.gz
[root@CentOS5gwq] # tar zxvf rsync-3.0.9.tar.gz
[root@CentOS5gwq] # ls
Rsync-3.0.9 rsync-3.0.9.tar.gz
[root@CentOS5gwq] # cd rsync-3.0.9
[root@CentOS5rsync-3.0.9] #. / configure-prefix=/usr/local/rsync
[root@CentOS5rsync-3.0.9] # make
[root@CentOS5rsync-3.0.9] # make install
[root@CentOS5rsync-3.0.9] # echo "webuser:rsync-pwd" > / usr/local/rsync/rsync.passwd
/ / the password file established by the server contains only the password and no user name, while the password file established in the client has both user name and password
[root@CentOS5rsync-3.0.9] # cd / usr/local/rsync
[root@CentOS5rsync] # chmod 600 rsync.passwd
Create a new rsync profile
[root@CentOS5rsync] # pwd
/ usr/local/rsync
[root@CentOS5rsync] # vi rsync.conf
Uid=root
Gid=root
Usechroot=no
Maxconnections=10
Strictmodes=yes
Pidfile=/var/run/rsyncd.pid
Lockfile=/var/run/rsync.lock
Logfile=/var/log/rsyncd.log
[web] / / name of authentication module in server rsync.sh
Path=/tmp/
Comment=webfile
Ignoreerrors
Readonly=no
Writeonly=no
Hostsallow=192.168.1.104
Hostsdeny=*
List=false
Uid=root
Gid=root
Authusers=webuser
Secretsfile=/usr/local/rsync/rsync.passwd
[root@CentOS5rsync] # / usr/local/rsync/bin/rsync-daemon
/ / start the rsync service of the server and client
Create new files and directories under the server tmp directory, and the client will automatically synchronize
Manual synchronization command format:
[root@CentOS5rsync] # / usr/bin/rsync-vzrtopg--delete-progress-- password-file=/usr/local/rsy
Nc/rsync.passwd/tmp/webuser@192.168.1.108::web
Automatic synchronization command format:
Sh rsync.sh&
You can schedule tasks to synchronize rsync for a period of time in the following format:
* / 1****/usr/bin/rsync-Rav-- delete--password-file=/usr/local/rsync/rsync.passwdwebuser@192.168.2.173::web/tmp
In this way, it will be synchronized every minute. The effect of my task plan in this format is to synchronize the files and directories specified by the client, not the server, which means that you create a new file on the server, which will disappear automatically after a minute, because there is no such file in the client, but if you create a new file in the client, it will be synchronized to the server one minute later (cron plan needs to be operated on the server. The operation on the client is unresponsive)
Using sh rsync.sh& synchronizes the server's
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.