web服务器同步工具
来源:互联网 发布:幸运大转盘软件 编辑:程序博客网 时间:2024/05/05 06:42
sersync主要用于服务器同步,web镜像等功能。sersync是使用c++编写,在结合rsync同步的时候,节省了运行时耗和网络资源。因此更快。sersync配置起来很简单。另外本项目相比较其他脚本开源项目,使用多线程进行同步,尤其在同步较大文件时,能够保证多个服务器实时保持同步状态,同步及时快速。
- 安装环境
- 192.168.1.124 sersync服务器
- 192.168.1.127 客户端
- centos6 64bit
- 192.168.1.124 sersync服务器执行以下操作
- 下载地址http://code.google.com/p/sersync/downloads/list
- tar zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz -C /usr/bin
- [root@localhost ~]# cd /usr/bin/GNU-Linux-x86/
- [root@localhost GNU-Linux-x86]# ls
- confxml.xml sersync2
- 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="false"/>
- <closeWrite start="true"/>
- <moveFrom start="true"/>
- <moveTo start="true"/>
- <attrib start="false"/>
- <modify start="false"/>
- </inotify>
- #############################add 20120309###############################
- 对于大多数应用,可以尝试把createFile(监控文件事件选项)设置为false来提高性能,减少 rsync通讯。因为拷贝文件到监控目录会产生create事件与close_write事件,所以如果关闭create事件,只监控文件拷贝结束时的事 件close_write,同样可以实现文件完整同步。注意:强将createFolder保持为true,如果将createFolder设为false,则不会对产生的目录进行监控,该目录下的子文件与子目录也不会被监控。所以除非特殊需要,请开启。默认情况下对创建文件(目录)事件与删除文件(目录)事件都进行监控,如果项目中不需要删除远程目标服务器的文件(目录),则可以将delete 参数设置为false,则不对删除事件进行监控。
- 补充参考http://lihuipeng.blog.51cto.com/3064864/563291
- ###############################add 20120309##############################
- <sersync> #黑体部分是我做的改动,其余没变要和客户端对应
- <localpath watch="/opt/test">
- <remote ip="192.168.1.127" name="test"/>
- <!--<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="192.168.138.20" 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>
- 安装
- yum install rsync(sersync调用)
- 192.168.1.127客户端
- yum install rsync
- [root@localhost test]# rpm -qa | grep rsync
- rsync-3.0.6-5.el6_0.1.x86_64
- vi /etc/rsyncd.conf
- uid=root
- gid=root
- max connections=100
- use chroot=no
- log file=/var/log/rsyncd.log
- pid file=/var/run/rsyncd.pid
- lock file=/var/run/rsyncd.lock
- [test] #和sersync相关内容对应
- path=/opt/test
- #uid = root
- comment = test
- ignore errors = yes
- read only = no
- hosts allow = 192.168.1.124 192.168.1.127
- 启动服务
- rsync --daemon
- [root@localhost test]# ps -ef | grep rsync
- root 1873 1 0 Dec06 ? 00:00:00 rsync --daemon
- root 2818 1855 0 00:07 pts/0 00:00:00 grep rsync
- [root@localhost test]# lsof -i:873
- COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
- rsync 1873 root 4u IPv4 11195 0t0 TCP *:rsync (LISTEN)
- rsync 1873 root 5u IPv6 11196 0t0 TCP *:rsync (LISTEN)
- 然后
- 192.168.1.124 sersync服务器执行以下操作启动服务
- /usr/bin/GNU-Linux-x86/sersync2 -d -o /usr/bin/GNU-Linux-x86/confxml.xml
- rsync --daemon
- [root@localhost GNU-Linux-x86]# ps -ef | grep rsync
- root 1878 1 0 Dec06 ? 00:00:00 /usr/bin/GNU-Linux-x86/sersync2 -d -o /usr/bin/GNU-Linux-x86/confxml.xml
- root 2543 1860 0 00:09 pts/0 00:00:00 grep rsync
- 然后说说我这两边的其他操作 我把selinux关了 iptables也关了
- 好了 现在可以测试去试试了
- ###################################################################
- 如果多台服务器到图片要同步到一台服务器,也就是rsync 同步一台服务器的多个目录
- 只需要在客户端多配置一个模块就行,以下为具体写法,test1,和test2分别为两个模块,test2为新加的,将另一台服务器的文件同步到另一个目录
- uid=root
- gid=root
- max connections=100
- use chroot=no
- log file=/var/log/rsyncd.log
- pid file=/var/run/rsyncd.pid
- lock file=/var/run/rsyncd.lock
- [test1] #和sersync相关内容对应
- path=/opt/test
- #uid = root
- comment = test1
- ignore errors = yes
- read only = no
- hosts allow = 192.168.1.124
- [test2] #和sersync相关内容对应
- path=/opt/test2
- #uid = root
- comment = test2
- ignore errors = yes
- read only = no
- hosts allow = 192.168.1.125
- web服务器同步工具
- 服务器同步工具 sersync
- 服务器同步工具 sersync
- web服务器监控工具
- SVN服务器 与 web服务器 文件同步
- Web 服务器日志工具点评
- web服务器压力测试工具
- Web 服务器日志工具点评
- Web服务器指纹识别工具httprint
- WEB 服务器负载平衡&文件同步
- SVN服务器搭建和web目录同步
- 前端web服务器数据同步方案
- 多个WEB服务器,图片同步方法
- 源码发布服务器同步到N台WEB服务器
- Ubuntu 14.04 下安装svn服务器,同步更新web服务器
- Web服务器的一些紧急救援工具
- Python编写WEB服务器压力测试工具
- http_load web服务器压力测试工具
- 分享:如何开发出成功的iOS小游戏?
- 遍历树形json
- Wince6.0字体问题
- 学习Emacs系列教程(一):基本使用
- scp远程无密码复制
- web服务器同步工具
- Android下实现wap和net自适应
- Table 备忘
- 学习Emacs系列教程(二):导航
- 海淘转运公司PK
- Asp.Net大型项目实践系列导航
- 学习Emacs系列教程(三):编辑(1)
- 两个好用的eclipse js编辑器插件
- 推荐给 iOS 设计师的工具和资源