Linux文件同步

需要的文件下载地址点击打开链接

从A同步到B

B配置

  ①、将rsync-3.1.2.tar.gz复制到B服务器上,安装rsync;
      # tar -zxvf rsync-3.1.2.tar.gz
      # cd rsync-3.1.2
      # ./configure --prefix=/usr/local/rsync
      # make
      # make install
  ②、建立配置文件:
      # mkdir -p /etc/rsyncd/
      # vim /etc/rsyncd.conf
uid=root
gid=root
max connections=36000
use chroot=no
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock

[tongbu]#这个名字很重要,需要跟A服务器一致
path = /opt/tongbu
ignore errors = yes
list = yes
read only = no
hosts allow =  127.0.0.1 #允许B服务器同步
#hosts deny = * 
     # rsync --daemon
  ③、# netstat -tunlp |grep 873 (查看是否有873端口)
  ④、B服务器配置完成

A配置

sersync2.5_32bit_binary_stable_final.tar.gz复制到A服务器上,安装sersync

tar -xzf sersync2.5_32bit_binary_stable_final.tar.gz

cd GNU-Linux-x86

vim confxml.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
    <host hostip="localhost" port="8008"></host>
    <debug start="false"/>
    <fileSystem xfs="false"/>
    <filter start="false">
<exclude expression="(.*)\.svn"></exclude>
<exclude expression="(.*)\.gz"></exclude>
<exclude expression="^info/*"></exclude>
<exclude expression="^static/*"></exclude>
    </filter>
    <inotify>
<delete start="true"/>
<createFolder start="true"/>
<createFile start="true"/>
<closeWrite start="true"/>
<moveFrom start="true"/>
<moveTo start="true"/>
<attrib start="false"/>
<modify start="false"/>
    </inotify>


    <sersync>
<localpath watch="/opt/tongbu_from"><!--同步的文件夹-->
    <remote ip="127.0.0.1" name="tongbu"/>
    <!--<remote ip="192.168.8.39" name="tongbu"/>-->
    <!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath>
<rsync>
    <commonParams params="-artuz"/>
    <auth start="false" users="root" passwordfile="/etc/rsync.pas"/>
    <userDefinedPort start="false" port="874"/><!-- port=874 -->
    <timeout start="false" time="100"/><!-- timeout=100 -->
    <ssh start="false"/>
</rsync>
<failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
<crontab start="false" schedule="600"><!--600mins-->
    <crontabfilter start="false">
<exclude expression="*.php"></exclude>
<exclude expression="info/*"></exclude>
    </crontabfilter>
</crontab>
<plugin start="false" name="command"/>
    </sersync>


    <plugin name="command">
<param prefix="/bin/sh" suffix="" ignoreError="true"/><!--prefix /opt/tongbu/mmm.sh suffix-->
<filter start="false">
    <include expression="(.*)\.php"/>
    <include expression="(.*)\.sh"/>
</filter>
    </plugin>


    <plugin name="socket">
<localpath watch="/opt/tongbu">
    <deshost ip="127.0.0.1" port="8009"/>
</localpath>
    </plugin>
    <plugin name="refreshCDN">
<localpath watch="/data0/htdocs/cms.xoyo.com/site/">
    <cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>
    <sendurl base="http://pic.xoyo.com/cms"/>
    <regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
</localpath>
    </plugin>
</head>

保存退出

echo "123456" >rsyncd.secrets

mkdir /var/rsync

touch /var/rsync/rsync_error.log

/你的路径/GNU-Linux-x86/sersync2 -r -d -o /你的路径/GNU-Linux-x86/confxml.xml 

到这里就好了;去测试一下

如果不行可以留言

转载请注明原处;谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值