sersync2 完全安装配置说明(一) —-基本功能使用
sersync主要用于服务器同步,web镜像等功能。基于boost1.43.0,inotify api,rsync command.开发。
如图所示,需要在同步主服务器上配置sersync,在同步目标服务器配置rsync,并在目标服务器开启rsync守候进程,这样在主服务器产生的文件,就会被sersync实时同步到多个目标服务器。在centos系统下默认已经安装了rsync,只需进行配置,并开启rsync守候进程即可。
配置同步目标服务器rsync
在多台目标服务器上配置如下:
vi /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 [tongbu1] path=/opt/tongbu1 comment = xoyo video files ignore errors = yes read only = no hosts allow = 192.168.0.100/24 hosts deny = *
上面配置文件,表明允许主服务器(假设ip为 192.168.0.100)访问,rsync同步模块名为[tongbu1],将同步过来的文件放入path指定的目录/opt/tongbu1。如果有多台从服务器,则每一台都需要进行类似的配置。
配置好之后,使用如下命令,开启rsync守护进程:
rsync –daemon
在主服务器上安装配置sresync
下载地址:http://code.google.com/p/sersync/,建议下载最新版
tar -zxvf sersyncXxxx_xxbit_binary.tar.gz
cd GNU-Linux-x86/
vi confxml.xml #修改如下部分: <localpath watch="/opt/tongbu"> <remote ip="192.168.0.104" name="tongbu1"/> <remote ip="192.168.0.105" name="tongbu1"/> </localpath>
表明要将主服务器上本地的/opt/tongbu 路径下的文件,同步到远程服务器 192.168.0.104 与 192.168.0.105上的tongbu1 模块。
运行Sersync与Sersync启动参数
sersync会对目录进行监控,将变化的目录或文件同步到远程服务器。sersync是递归监控的,如果有多级目录,都会同步到远程服务器。常用启动方式如下:
1.在主服务器上开启sersync守护进程,使sersync在后台运行,开启实时同步。
./sersync -d
可以在本地监控路径下建立文件,查看远程是否同步成功。
2.在开启实时监控的之前对主服务器目录与远程目标机目录进行一次整体同步
./sersync -r
如果需要将sersync运行前,已经存在的所有文件或目录全部同步到远程,要以-r参数运行sersync,将本地与远程整体同步一次。
如果设置了过滤器,即在xml文件中,filter为true,则暂时不能使用-r参数进行整体同步。-r参数将会无效
3.查看启动参数帮助
./sersync –help
4.指定配置文件
./sersync -o XXXX.xml
对于sersync使用可执行文件目录下的默认配置文件confxml.xml,如果需要使用另一个配置文件,可以使用-o参数指定其它配置文件。
5.指定默认的线程池的线程总数
./sersync -n num
例如 ./sersync -n 5 则指定线程总数为5,如果不指定,默认启动线程池数量是10,如果cpu使用过高,可以通过这个参数调低,如果机器配置较高,可以用-n跳高线程总数。
6.不进行同步,只运行插件
./sersync -m pluginName
例如./sersync -m command,则在监控到文件事件后,不对远程目标服务器进行同步,而是直接运行command插件。
7.多个参数可以配合使用
./sersync -n 8 -o abc.xml -r -d
表示,设置线程池工作线程为8个,指定abc.xml作为配置文件,在实时监控前作一次整体同步,以守护进程方式在后台运行。
8.通常情况下,对本地到远程整体同步一遍后,在后台运行实时同步。
./sersync2 -r -d
完成!
原文:http://hi.baidu.com/johntech/blog/item/be8559d2ebc99282a1ec9c18.html
六月 24th, 2011 at 03:51
Sites we Like……
[...] Every once in a while we choose blogs that we read. Listed below are the latest sites that we choose [...]……
七月 10th, 2011 at 22:39
Great website…
[...]we like to honor many other internet sites on the web, even if they aren’t linked to us, by linking to them. Under are some webpages worth checking out[...]……
十一月 27th, 2011 at 06:11
Check this out……
[...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]………
十一月 27th, 2011 at 10:42
Visitor recommendations trackback……
[...]one of our visitors recently recommended the following website[...]………