server1:192.168.1.10
server1:192.168.1.11
下面以在192.168.1.10 安裝爲例(紅色部分爲需要修改的地方,具體IP在192.168.1.11對調就可以)
#安裝rsync
yum -y install rsync
#設置本機用戶名與密碼
vi /etc/rsync.pas
peter:111111
#設置遠程服務的密碼
vi /etc/rsync_server.pas
111111
chmod 600 /etc/rsync.pas
chmod 600 /etc/rsync_server.pas
vi /etc/rsyncd.conf
uid=root
gid=root
max connections=36000
use chroot=no
log file=/var/log/rsyncd.log
lock file=/var/run/rsyncd.lock
[tongbu]
path=/opt/tongbu
comment = server1
ignore errors = yes
read only = no
auth users=peter
secrets file=/etc/rsync.pas
hosts allow = 192.168.1.11
hosts deny = *
#獨立啓動
rsync --daemon
#配置開機啓動,配置xinetd
vi /etc/xinetd.d/rsync
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
#reboot
netstat -tnlp | grep 873
grep 'rsync' /etc/services #可以看到873端口
#安裝sersync2
tar -zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz
cd GNU-Linux-x86
vi confxml.xml
<sersync>
<localpath watch="/opt/tongbu">
<remote ip="192.168.56.103" name="tongbu"/>
<!--<remote ip="192.168.8.39" name="tongbu"/>-->
<!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath>
<rsync>
<commonParams params="-artuz"/>
<auth start="true" users="peter" passwordfile="/etc/rsync_server.pas"/>
<userDefinedPort start="false" port="874"/><!-- port=874 -->
<timeout start="false" time="100"/><!-- timeout=100 -->
<ssh start="false"/>
</rsync>
<failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
<crontab start="false" schedule="600"><!--600mins-->
<crontabfilter start="false">
<exclude expression="*.php"></exclude>
<exclude expression="info/*"></exclude>
</crontabfilter>
</crontab>
<plugin start="false" name="command"/>
</sersync>
#獨立啓動
/home/GNU-Linux-x86/sersync2 -d -r -o /home/GNU-Linux-x86/confxml.xml
#配置開機啓動,修改rc.local
vi /etc/rc.d/rc.local
#增加
/home/GNU-Linux-x86/sersync2 -d -r -o /home/GNU-Linux-x86/confxml.xml