快速搭建sersync服务

一、sersync简单介绍

Sersync服务主要用于服务器同步,它依赖于rsync进行同步

二、配置sersync

1.准备环境:      

虚拟机两台        

服务端ip:192.168.100.130        

客户端ip:192.168.100.3

rsync服务器上配置如下

[root@mode etc]# cat /etc/rsyncd.conf         

#created by yijiu 15:01 2007-6-5

##rsyncd.conf start##

uid = root        

gid = root        

use chroot = no   

max connections = 200

timeout = 600     

pid file = /var/run/rsyncd.pid  

lock file = /var/run/rsync.lock 

log file = /var/log/rsyncd.log  

[yijiu]

path = /yijiu/    

ignore errors     

read only = false 

list = false      

hosts allow = 10.0.0.0/24       

hosts deny = 0.0.0.0/32

auth users = rsync_backup       

secrets file = /etc/rsync.password

 

[tongbu]

path=/opt/tongbu  

uid = root        

comment = test    

ignore errors = yes

read only = no    

hosts allow = 192.168.100.0/24  

hosts deny = *    

secrets file = /etc/rsync.password

 

配置密码文件:

[root@mode etc]# cat /etc/rsync.password      

rsync_backup:yijiu

重启服务

[root@yijiu /]# /etc/init.d/xinetd restart    

 

配置sersync

下载***sync

Wget http://sersync.googlecode.com/files/sersync2.4_32bit_binary.tar.gz   

解压缩:

[root@yijiu /]# tar zxvf sersync2\[1\].4_32bit_binary.tar.gz -C /usr/local/

GNU-Linux-x86/    

GNU-Linux-x86/sersync2.4        

GNU-Linux-x86/confxml.xml       

GNU-Linux-x86/rsync_fail_log.sh 

[root@yijiu /]# cd /usr/local/GNU-Linux-x86/

[root@yijiu GNU-Linux-x86]# ls

confxml.xml  rsync_fail_log.sh  sersync2.4    

编辑配置文件

[root@yijiu GNU-Linux-x86]# vim confxml.xml

修改如下部分

将:

    <sersync>

        <localpath watch="/opt/tongbu" debug="false">

            <remote ip="127.0.0.1" name="tongbu1"/>

            <!--<remote ip="192.168.8.39" name="tongbu"/>-->

        </localpath>

修改为:

    <sersync>

        <localpath watch="/opt/tongbu" debug="false">

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

        </localpath>

 

 

说明:将主服务器上本地的/opt/tongbu 路径下的文件,同步到远程服务器 192.168.100.3上的tongbu模块

三、启动sersync

切换到服务端

[root@yijiu GNU-Linux-x86]# ./sersync2.4 -d  #开启守护进程

查看进程

[root@mode test]# ps -aux | grep sersync      

Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ 

root      4613  0.0  0.3 114392   700 ?        Ssl  10:41   0:00 ./sersync2 -d     

root      4720  0.0  0.3   3920   676 pts/1    R+   10:47   0:00 grep sersync      

[root@yijiu GNU-Linux-x86]# ./sersync2.4 -r    #开始同步数据

然后在rsync端查看同步的目录下的文件

[root@yijiu ~]# ls /opt/tongbu           

1  2  3  5  6  7

rsync端上查看日志:

可以看到已经同步成功

2011/12/02 15:17:42 [12868] connect from UNKNOWN (192.168.100.3)     

2011/12/02 15:17:42 [12868] rsync to tongbu from unknown (192.168.100.3)  

2011/12/02 15:17:42 [12868] sent 28 bytes  received 161 bytes  total size 0   

 

四、sersync常用参数         

-h       查看帮助文件

-r       在同步程序开启前,将整个路径跟远程服务器同步一遍

-d       开启守护进程模式在后台运行

-o       指定配置文件,如果不是默认的confxml.xml的情况下

-n       指定同步守护线程数量,默认为10个,适用于现在的4核服务器。如果需增加或        减少使用 '-n 数量'

 

通常最常用的启动方法:

-m       值调用插件程序,不调用同步数据机制

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值