rsync安装及部署
一。服务器端
1.yum -y install rsync xinetd
2.vi /etc/xinetd.d/rsync
将yes 修改为no IPV6修改为IPV4
3.vi /etc/rsyncd.conf 新建文件
uid = root
gid = root
use chroot = no
max connections = 4
strict modes = yes
port = 873
#module名字和路径
[svnbackup]
path = /usr/local/svndata/
commet = This is SVN Data
ignore errors
read only = yes
list = no
#auth users = test
secrets file = /etc/rsync.pas
hosts allow = 192.168.206.20,192.168.201.11,192.168.201.13
hosts deny =0.0.0.0/0
pid file = /var/run/rsyncd.pid
lock file =/var/run/rsync.lock
log file = /var/log/rsyncd.log
4.vi /etc/rsync.pas创建密码文件
svntrasfer:123456
5.权限修改
#chown root.root rsync.pas
#chmod 600 rsync.pas
6.vi /etc/rsyncd.motd配置欢迎信息 ,可不设置
Welcome to use the rsync services!
7.配置生效service xinetd restart
8.启动服务,两种办法
(1)独立启动 /usr/bin/rsync –-daemon
(2)用xinetd超级进程启动/etc/rc.d/init.d/xinetd reload
9.加入rc.local ,开机启动
vi /etc/rc.local最后加入
/usr/bin/rsync --daemon
或者使用命令:chkconfig rsync on
10.加入防火墙
vi /etc/sysconfig/iptables 在reject前
-A INPUT -m state --state NEW -m tcp -p tcp --dport 873 -j ACCEPT
11.检查服务873端口是否启动
netstat -anp|grep 873
或者lsof -i:873
12.设置目录写权限
给/usr/local/svndata目录写权限
# chown -R nobody.nobody /usr/local/svndata
# chmod -R 770 /usr/local/svndata
二、客户端
1.yum -y install rsync
2.vi /etc/rsyncd.conf 创建空文件
3.创建密码并设置权限
vi /etc/rsync.pas
123456
chown root.root rsync.pas
chmod 600 rsync.pas
三、传输文件
rsync -vzrtopg --progress svntransfer@192.168.206.20::svnbackup /test/svndata/ --password-file=/etc/rsyncd.pas
注意密码文件在最后,这样将206.20上的svnbackup的module文件传输到本机的/test/svndata/下
四。自动调度
1.创建shell
vi /usr/local/rsync/time.sh
#!/bin/bash
rsync -vzrtopg --progress svntransfer@192.168.206.20::svnbackup /test/svndata/ --password-file=/etc/rsyncd.pas
2.crontab -e
加入30 * * * * /usr/local/rsync/time.sh //每30分运行一次time.sh脚本文件