源码发布服务器同步到N台WEB服务器
2011-11-02 17:07
323 查看
环境:
web1:10.80.11.243
web2:10.80.11.244
code:10.80.11.245
更新code服务器的代码后,自动同步到web1和web2,删除code服务器文件,web1和web2也删除
服务器端的安装(N台WEB都这样配置)
1、首先要求Linux内核在2.6以上,才支持inotify
[root@web1 html]# uname -a
Linux web1 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686 i686 i386 GNU/Linux
2、检查是否安装rsync软件
[root@web1 html]# rpm -qa |grep rsync
rsync-2.6.8-3.1
如果没有的话,通过yum –y install rsync安装
3、新建rsync配置文件,该软件安装默认没有配置文件
#vim /etc/rsyncd.conf
motd file = /etc/rsyncd.motd
uid=root
gid=root
max connections=36000
use chroot=no
log file=/var/log/rsyncd.log
log format = %t %a %m %f %b
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
timeout = 300
[tongbu]
path=/var/www/html
list=yes
comment = this is comment
ignore errors = yes
read only = no
hosts allow = 10.80.11.245
hosts deny = *
auth users backup
secrets file = /etc/rsync.secrets
注:tongbu为发布模块,相当于路径的别名
hosts allow是只允许连接的IP
secrets file = /etc/rsync.secrets
这是密码文件,同步的用户为backup,下面创建同步用户
#useradd backup
#passwd backup
密码设置为123456
#vim /etc/rsync.secrets
backup:123456
格式为
用户名:密码
#chmod 600 /etc/rsyncd.secrets
设置只有root用户才能查看这个文件
4、启动服务
/usr/bin/rsync --daemon --config=/etc/rsyncd.conf
其他的WEB服务器配置和上面是一样的。如果需要开机启动,加入到/etc/rc.local
发布端的配置
1、发布端主要利用开源软件sersync,网站为:http://code.google.com/p/sersync/
#cd /usr/local/
#wget http://sersync.googlecode.com/files/sersync2.5RC1_32bit_binary.tar.gz
#tar –zxvf sersync2.5RC1_32bit_binary.tar.gz
#cd GNU-Linux-x86
2、修改配置文件
#vim confxml.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
<host hostip="localhost" port="8008"></host>
<filter start="false">
<exclude expression="(.*)\.gz"></exclude>
<exclude expression="^info/*"></exclude>
</filter>
<inotify>
<delete start="true"/>
<create start="true"/>
</inotify>
<debug start="false"/>
<sersync>
<localpath watch="/var/www/html">
<remote ip="10.80.11.243" name="tongbu"/>
<remote ip="10.80.11.244" name="tongbu"/>
</localpath>
<rsync>
<auth start="true" users="backup" 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 60min 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>
/var/www/html为发布服务器的源码发布目录
主要修改红色标记部分,密码文件为/etc/rsync.pas
#vim /etc/rsync.pas
123456#
解释:123456代表的是Rsync server端的密码,并且要以"#"做结尾。如果有多个密码,增加多行就行。
#chmod 600 /etc/rsync.pas
3、启动服务
#./sersync2 -d –r
这种方式常驻进程,如果需要开机启动,加入到/etc/rc.local
这样只要修改发布服务器/var/www/html的文件,web服务器就会自动同步。
转自:/article/4379879.html
经过测试可行;注意backup密码
web1:10.80.11.243
web2:10.80.11.244
code:10.80.11.245
更新code服务器的代码后,自动同步到web1和web2,删除code服务器文件,web1和web2也删除
服务器端的安装(N台WEB都这样配置)
1、首先要求Linux内核在2.6以上,才支持inotify
[root@web1 html]# uname -a
Linux web1 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686 i686 i386 GNU/Linux
2、检查是否安装rsync软件
[root@web1 html]# rpm -qa |grep rsync
rsync-2.6.8-3.1
如果没有的话,通过yum –y install rsync安装
3、新建rsync配置文件,该软件安装默认没有配置文件
#vim /etc/rsyncd.conf
motd file = /etc/rsyncd.motd
uid=root
gid=root
max connections=36000
use chroot=no
log file=/var/log/rsyncd.log
log format = %t %a %m %f %b
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
timeout = 300
[tongbu]
path=/var/www/html
list=yes
comment = this is comment
ignore errors = yes
read only = no
hosts allow = 10.80.11.245
hosts deny = *
auth users backup
secrets file = /etc/rsync.secrets
注:tongbu为发布模块,相当于路径的别名
hosts allow是只允许连接的IP
secrets file = /etc/rsync.secrets
这是密码文件,同步的用户为backup,下面创建同步用户
#useradd backup
#passwd backup
密码设置为123456
#vim /etc/rsync.secrets
backup:123456
格式为
用户名:密码
#chmod 600 /etc/rsyncd.secrets
设置只有root用户才能查看这个文件
4、启动服务
/usr/bin/rsync --daemon --config=/etc/rsyncd.conf
其他的WEB服务器配置和上面是一样的。如果需要开机启动,加入到/etc/rc.local
发布端的配置
1、发布端主要利用开源软件sersync,网站为:http://code.google.com/p/sersync/
#cd /usr/local/
#wget http://sersync.googlecode.com/files/sersync2.5RC1_32bit_binary.tar.gz
#tar –zxvf sersync2.5RC1_32bit_binary.tar.gz
#cd GNU-Linux-x86
2、修改配置文件
#vim confxml.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
<host hostip="localhost" port="8008"></host>
<filter start="false">
<exclude expression="(.*)\.gz"></exclude>
<exclude expression="^info/*"></exclude>
</filter>
<inotify>
<delete start="true"/>
<create start="true"/>
</inotify>
<debug start="false"/>
<sersync>
<localpath watch="/var/www/html">
<remote ip="10.80.11.243" name="tongbu"/>
<remote ip="10.80.11.244" name="tongbu"/>
</localpath>
<rsync>
<auth start="true" users="backup" 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 60min 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>
/var/www/html为发布服务器的源码发布目录
主要修改红色标记部分,密码文件为/etc/rsync.pas
#vim /etc/rsync.pas
123456#
解释:123456代表的是Rsync server端的密码,并且要以"#"做结尾。如果有多个密码,增加多行就行。
#chmod 600 /etc/rsync.pas
3、启动服务
#./sersync2 -d –r
这种方式常驻进程,如果需要开机启动,加入到/etc/rc.local
这样只要修改发布服务器/var/www/html的文件,web服务器就会自动同步。
转自:/article/4379879.html
经过测试可行;注意backup密码
相关文章推荐
- 源码发布服务器同步到N台WEB服务器(sersync&rsync)
- 第二部分:源码发布服务器同步到N台WEB服务器
- 源码发布服务器同步到N台WEB服务器
- 源码发布服务器同步到N台WEB服务器
- 使用Rsync+sersync架构(多实例),保持web服务器网页发布目录实时同步
- vue.js使用webpack发布,部署到服务器上之后在浏览器中可以查看到vue文件源码
- Unix高级编程:线程的同步之信号量、进程通信之信号量集、system函数、简单web服务器代码
- web服务器集群session同步
- 使用maven发布idea中web项目到远程tomcat服务器
- 在win8(win8.1)电脑上安装IIS,配置web服务器,发布网站
- 【下载源码】在线生成网页缩略图.超越Snap.com:WebSnap Beta 1.1 发布。感谢博客园的“萧寒”重写的底层。开源。
- DeltaRelease--Java Web增量发布工具(附源码)
- WEB服务器linux+apache+mysql+php LAMP源码环境搭建
- 基于OWin的Web服务器Katana发布版本3
- web服务器集群(多台web服务器)session同步、共享的3种解决方法
- 网络应用发布到linux上的web服务器上页面上显示麻将牌式字符的问题
- 笔试题14:用TCP通信模型创建一个Web服务器(源码)
- 高并发高性能的静态Web服务器 + 完成端口部分源码 (修正)
- [2016-09-09]IIS站点发布、同步和备份工具MSdeploy(WebDeploy)介绍
- iis 6发布webservice服务报错:HTTP 错误 403.14 - Forbidden Web 服务器被配置为不列出此目录的内容。