sersync+rsync同步
发布时间:2020-12-14 02:03:05 所属栏目:Linux 来源:网络整理
导读:Server B (备份服务器) #!/bin/bash#====================================================# Author: Mr.Song# Create Date: 2019-03-03# Description:install rsync server#====================================================#创建备份目录mkdir -p /a
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 & (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |