Linux   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了sersync+rsync同步大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

Server B (备份服务器) #!/bin/bash #==================================================== # Author: Mr.Song # Create Date: 2019-03-03 # Description:install rsync server #=====================================
Server B (备份服务器)
#!/bin/bash
#====================================================
# Author: Mr.song
# Create Date: 2019-03-03
# Description:install rsync server
#====================================================
#创建备份目录
mkdir  -p /app/data/site/
#安装rsync
yum install -y rsync

#设置rsync的配置文件
mv  /etc/rsyncd.conf  /etc/rsyncd.conf.bak
cat > /etc/rsyncd.conf <<- EOF

#服务器B上的rsyncd.conf文件内容
uid=root
gid=root
#最大连接数
max connections=36000
#认为true,修改为no,增加对目录文件软连接的备份 
use chroot=no
#定义日志存放位置
log file=/var/log/rsyncd.log
#忽略无关错误
ignore errors = yes
#设置rsync服务端文件为读写权限
read only = no 
#认证的用户名与系统帐户无关在认证文件做配置,如果没有这行则表明是匿名
auth users = rsync
#密码认证文件,格式(虚拟用户名:密码)
secrets file = /etc/rsync.pass
#这里是认证的模块名,在client端需要指定,可以设置多个模块和路径
[rsync]
#自定义注释
comment  = rsync
#同步到B服务器的文件存放的路径
path=/app/data/site/
#[img]
#comment  = img
#path=/app/data/site/img
EOF

#创建rsync认证文件  可以设置多个,每行一个用户名:密码,注意中间以“:”分割
echo "rsync:rsync" > /etc/rsync.pass

#设置文件所有者读取、写入权限
chmod 600 /etc/rsyncd.conf /etc/rsync.pass 
#启动服务器B上的rsync服务
systemctl start rsyncd

#设置rsync为服务启动项
systemctl enable rsyncd

Server A (源服务器)

#!/bin/bash
#====================================================
# Author: Mr.song
# Create Date: 2019-03-03
# Description:install sersync+rsync server
#====================================================
APP_INSTall_DIR="/app/local"
BAK_DIR="/app/data"
BACK_SERVER="192.168.10.12"
SRC_BAK_DIR="/home"
yum install -y automake autoconf libtool git rsync

mkdir -p $APP_INSTall_DIR && cd $APP_INSTall_DIR

#下载软件包
git clone https://github.com/wsgzao/sersync.git && mv $APP_INSTall_DIR/sersync $APP_INSTall_DIR/sersync-git
#cd  $APP_INSTall_DIR/sersync-git

#安装inotify
#tar  zxf inotify-tools-3.14.tar.gz
#cd inotify-tools-3.14
#./configure --prefix=/app/local/inotify
#make && make install

#安装sersync
cd  $APP_INSTall_DIR
tar zxf $APP_INSTall_DIR/sersync-git/sersync2.5.4_64biT_Binary_stable_final.tar.gz -C $APP_INSTall_DIR

mv $APP_INSTall_DIR/GNU-Linux-x86/ $APP_INSTall_DIR/sersync
cd $APP_INSTall_DIR/sersync
#配置下密码文件,因为这个密码是要访问服务器B需要的密码和上面服务器B的密码必须一致
echo "rsync" > $APP_INSTall_DIR/sersync/user.pass
#修改权限
chmod 600 $APP_INSTall_DIR/sersync/user.pass
#修改confxml.conf
sed -i "24s#/opt/tongbu#$SRC_BAK_DIR#;s#127.0.0.1#$BACK_SERVER#;s#tongbu1#rsync#;s#/etc/rsync.pas#/app/local/sersync/user.pass#;s#root#rsync#;/auth/s#false#true#"  confxml.xml

#运行sersync:
nohup /app/local/sersync/sersync2 -r -d -o /app/local/sersync/confxml.xml >/app/local/sersync/rsync.log 2>&1 &

#nohup /app/local/sersync/sersync2 -r -d -o /app/local/sersync/img.xml >/app/local/sersync/img.log 2>&1 &

大佬总结

以上是大佬教程为你收集整理的sersync+rsync同步全部内容,希望文章能够帮你解决sersync+rsync同步所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。