您的位置:首页 > 运维架构 > Linux

linux文件实时同步

2015-10-13 10:35 495 查看
服务器:A:ip--192.168.1.110,linux版本--Redhat6.4

              B:ip--192.168.1.111,linux版本--Redhat6.4

-------------------------------------------------

所需文件:linux-sersync2.tar.gz

                  rsync-3.1.2pre1.tar.gz

资源csdn免积分地址:http://download.csdn.net/detail/duan847/9176125

-------------------------------------------------

实现效果:

 有A、B两台服务器,A服务器/opt/tongbu目录下

 文件有增、删、改将自动同步至B服务器/opt/tongbu目录下

-------------------------------------------------

操作步骤:

 1、配置B服务器:

  ①、将rsync-3.1.2pre1.tar.gz复制到B服务器上,安装rsync;

      # tar -zxvf rsync-3.1.2pre1.tar.gz

      # cd rsync-3.1.2pre1

      # ./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]

path = /opt/tongbu

ignore errors = yes

list = yes

read only = no

hosts allow =  192.168.1.110 #允许B服务器同步

#hosts deny = * 

     # rsync --daemon

  ③、# netstat -tunlp |grep 873 (查看是否有873端口)

  ④、B服务器配置完成

 2、配置A服务器:

  ①、将linux-sersync2.tar.gz复制到A服务器上,安装sersync;

      # tar -zxvf linux-sersync2.tar.gz

      # cd linux-sersync2

      # vi config.xml   (修改localpath标签,内容如下:)

<localpath watch="/opt/tongbu">

 <remote ip="192.168.1.111" name="tongbu"/>

</localpath>

      # ./sersync -d

          ②、A服务器配置完成

   ③、测试:# cd /opt/tongbu

      # echo test >> test.txt

       查看B服务器 /opt/tongbu 目录下是否有test.txt

   ④、完成
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息