一、架构说明
为了防止企业MySQL坏掉导致数据丢失,衍生出此结构
二、环境准备
两台centos7
192.168.59.143(需要备份的服务器)
192.168.59.144(备份存储服务器)
三、两台安装rsync服务
yum -y install rsync
四、修改需要备份的服务器rsync的配置文件(192.168.59.143)
vim /etc/rsyncd.conf
添加如下配置
uid = root
gid = root
use chroot = no
max connections = 2
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[app] #模块
path = /data/ #备份路径
ignore errors
read only = false
list = false
auth users = backup
secrets file = /etc/rsync.passwd
编辑密码文件并赋予权限(两台都要做)
echo "rsync_user:rsync_user_pwd" > /etc/rsync.password
chmod -R 600 /etc/rsync.password
五、启动rsync
1.解决报错不启动
yum -y install xinetd
vim /etc/xinetd.d/rsync
service rsync
{
disable = no
flags = IPv6
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
systemctl restart xinetd
六、编写任务计划
crontab -e
将以下命令写入脚本
/usr/bin/rsync -vzrtopg --progress --password-file=/etc/rsync.passwd backup@192.168.59.143::app /data/
七、写增量脚本