rsync 服务器搭建
本方案采用客户端主动同步服务器端的方式
服务器端配置:
1.建好相应目录
mkdir /etc/rsyncd
touch /etc/rsyncd/rsyncd.conf
touch /etc/rsyncd/rsyncd.secrets
chmod 600 /etc/rsyncd/rsyncd.secrets
2.明确需要备份的目录
3.修改配置文件
pid file = /var/run/rsyncd.pid
log file = /var/log/rsyncd.log
read only = no
max connections = 50
use chroot = yes
[mysql]
hosts allow = 192.168.0.0/24 10.13.2.0/24 210.51.19.0/24 220.181.67.0/24
path = /data/mysql/ //需要备份的目录
uid = root
gid = root
secrets file = /etc/rsyncd/rsyncd.secrets
read only = no
[www]
hosts allow = 192.168.0.0/24 10.13.2.0/24 210.51.19.0/24 220.181.67.0/24
path = /data/www/
uid = root
gid = root
secrets file = /etc/rsyncd/rsyncd.secrets
read only = no
4.修改密码文件
vim /etc/rsyncd/rsyncd.secrets
mysql:123.com
www:123.com
5.启动rsync daemon模式
/usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf
6.打开防火墙873端口
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 873 -j ACCEPT
客户端设置
1.添加密码文件
cd /root/
vim rsyncd.secrets
只输入密码 123.com即可
2.同步数据
/usr/bin/rsync -vzrtopg --password-file=/root/rsyncd.secrets root@192.168.0.10::mysql /data/mysql/
3.验证数据
4.添加计划任务
crontab -e
本文出自 “ShareDream” 博客,请务必保留此出处http://yangtong.blog.51cto.com/981099/636310
|