服务器使用

目前使用两台服务器       

服务器地址 作用 安装软件
172.26.236.237 备份文件存储服务器 rsync
172.26.236.239 需要备份的服务器 rsync + sersync

237存储服务器配置

安装rsync

yum install -y rsync

修改配置文件

vim /etc/rsyncd.conf

rsync + sersync实现文件同步

创建密码文件和权限

vim /etc/rsync.passwd,         输入rsyncuser:huance2019     保存

添加权限:   chmod 600 /etc/rsync.passwd

指定配置文件,重新启动

rsync --daemon --config=/etc/rsyncd.conf

systemctl restart rsyncd

查看是否启动: netstat -antup | grep :873

测试连通

在172.26.236.239安装rsync之后,执行

rsync -avz  /backtest/ rsyncuser@172.26.236.237::huancelog

 输入密码之后,测试文件夹文件会同步到huanceLog指定的文件夹下

注: 服务器需要开放873端口

239 备份服务器配置

安装rsync

yum install -y rsync

下载sersync

解压tar -zvxf sersync2.5.4_64bit_binary_stable_final.tar.gz, 修改解压出来的文件夹名称sersync

修改配置文件

rsync + sersync实现文件同步

创建密码文件和权限

vim /etc/rsync.passwd,         输入huance2019         保存            

 添加权限:   chmod 600 /etc/rsync.passwd

启动同步软件

/usr/local/sersync/sersync2  -d -r -o  /usr/local/sersync/confxml.xml

rsync + sersync实现文件同步

设置sersync监控开机自动执行

vi /etc/rc.d/rc.local  #编辑,在最后添加一行

 /usr/local/sersync/sersync2 -d -r -o  /usr/local/sersync/confxml.xml  #设置开机自动运行脚本

添加脚本监控sersync是否正常运行(可选)

vi /usr/local/sersync/check_sersync.sh #编辑,添加以下代码

#!/bin/sh
sersync="/usr/local/sersync/sersync2"
confxml="/usr/local/sersync/confxml.xml"
status=$(ps aux |grep 'sersync2'|grep -v 'grep'|wc -l)
if [ $status -eq 0 ];
   then
$sersync -d -r -o $confxml &
   else
exit 0;
 fi

chmod +x /usr/local/sersync/check_sersync.sh  #添加脚本执行权限 把这个脚本加到任务计划,定期执行检测

多个同步任务

如果要配置多个同步任务,需要新建多个confxml.xml文件,启动多个同步进程。

可通过配置xml文件中的exclude和include修改过滤文件


Follow your heart ~!