安装
rsync-3.1.0.tar.gz
#tar zxvf rsync-3.1.0.tar.gz
#cd rsync-3.1.0
#./configure --prefix=/home/work/rsync
#make
#make install
rsync服务端的配置;
环境:192.168.11.11为生产机;192.168.11.12为备份机;
那么需要192.168.11.11需要作为rsync的clIEnt;
192.168.11.12作为rsync的service端;
1、192.168.11.12_service端的配置;
1)[root@cmmailapp2 data]# touch /etc/rsyncd.conf //此文件为rsync的主配置问题,默认不存在需要手动创建;
2)定义同步的配置;
[root@cmmailapp2 data]# cat /etc/rsyncd.conf
[data]
path = /data/
auth users = coremail
uid = root
gid = root
secrets file = /etc/rsyncd.secrets
read only = no
[mysql]
Path = /home/coremail/var/mysql
auth users = coremail
uid = root
gid = root
secrets file = /etc/rsyncd.secrets
read only = no
[cmxt]
Path = /home/coremail/
auth users = coremail
uid = root
gid = root
secrets file = /etc/rsyncd.secrets
read only = no
3)定义密码文件/etc/rsyncd.secrets
[root@cmmailapp2 data]# cat /etc/rsyncd.secrets
coremail:coremail
4)启动rsync启动服务
[root@cmmailapp2 data]# cat /etc/xinetd.d/rsync
# default: off
# description: The rsync server is a good addition to an ftp server, as it
# allows crc checksumming etc.
service rsync
{
disable = yes //需要修改为no;
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
[root@cmmailapp2 data]# chkconfig --level 2345 rsync on
[root@cmmailapp2 data]# chkconfig rsync on
[root@cmmailapp2 data]# chkconfig --level 2345 xinetd on
[root@cmmailapp2 data]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
2、192.168.11.11_clIEnt端的配置;
[root@cmmailapp1 /]# cat /etc/rsyncd.secrets
coremail
[root@cmmailapp1 /]# rsync -aSvH --passWord-file=/etc/rsyncd.secrets /home/coremail/coremail@192.168.11.12::data
[root@cmmailapp1 /]# rsync -aSvH --passWord-file=/etc/rsyncd.secrets /home/coremail/coremail@192.168.11.12::mysql
[root@cmmailapp1 /]# rsync -aSvH --passWord-file=/etc/rsyncd.secrets /home/coremail/coremail@192.168.11.12::cmxt
五、定义定时自行rsync同步,指定同步的日志所在的路径/var/log/rsync/下;
[root@cmmailapp1 log]# cat /root/rsync.sh
DATE=`date +%Y%m%d%H%M`
rsync -aSvH --passWord-file=/etc/rsyncd.secrets /home/coremail/ coremail@192.168.11.12::data >/var/log/rsync.date.$DATE
rsync -aSvH --passWord-file=/etc/rsyncd.secrets /home/coremail/ coremail@192.168.11.12::mysql >/var/log/rsync.mysql.$DATE
rsync -aSvH --passWord-file=/etc/rsyncd.secrets /home/coremail/ coremail@192.168.11.12::cmxt >/var/log/rsync.cmxt.$DATE
chmod u+x /root/rsync.sh
[root@cmmailapp1 log]# crontab -l
0 3 * * * /root/rsync.sh
执行时候的日子记录文件:
[root@cmmailapp1 log]# ls |grep 'rsync'
rsync.cmxt.201110180915
rsync.date.201110180915
rsync.mysql.201110180915
启动
rsync --daemon --port 3334 --config=/home/work/rsync/conf/rsyncd.conf
错误1
@ERROR: setgroupsfailed
rsync error: error starting clIEnt-server protocol (code 5) at main.c(1503) [sender=3.0.6]
这个错我是由于 起服务的 rsync 和 传输的rsync的版本不用。后来换成一个版本后就好了。
ps大家要注意一点的时rsync软件是分服务器端与客户端两种,也就是主从服务器了,所以安装版本是不一样的哦.