快速搭建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

下载ssrsync

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       值调用插件程序,不调用同步数据机制


本文转自zuzhou 51CTO博客,原文链接:http://blog.51cto.com/yijiu/1038105


相关文章
|
开发工具 数据安全/隐私保护 网络安全
CentOS7.X通过rsync+sersync实现文件实时同步
CentOS7.X通过rsync+sersync实现文件同步
4545 0
|
监控 Linux 数据安全/隐私保护
rsync+sersync实现服务器文件同步
集群件服务器或者是多台服务器之间有数据同步需求的时候,要使多台服务器之间的数据快速同步,使用手动拷贝或者scp这样的命令是不太明智的,rsync+sersync组合工具可以解决这一痛点,快速的同步更新数据文件,减轻运维人员的工作压力。
4447 0
|
测试技术 网络安全
|
Shell 应用服务中间件 开发工具
|
Web App开发 Linux 网络安全
|
网络协议 网络安全 数据安全/隐私保护
|
知识图谱 数据安全/隐私保护 Unix