源碼發佈服務器同步到N臺WEB服務器

環境:web1:10.80.11.243web2:10.80.11.244code:10.80.11.245更新code服務器的代碼後,自動同步到web1web2,刪除code服務器文件,web1web2也刪除服務器端的安裝NWEB都這樣配置)1、首先要求Linux內核在2.6以上,才支持<span verdana','sans-serif'"="" style="padding: 0px;font-size: 13px;color: black">inotify[root@web1 html]# uname -aLinux web1 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686 i686 i386 GNU/Linux2、檢查是否安裝rsync軟件[root@web1 html]# rpm -qa |grep rsyncrsync-2.6.8-3.1若是沒有的話,經過yum –y install rsync安裝3、新建rsync配置文件,該軟件安裝默認沒有配置文件#vim /etc/rsyncd.confmotd file = /etc/rsyncd.motduid=rootgid=rootmax connections=36000use chroot=nolog file=/var/log/rsyncd.loglog format =  %t %a %m %f %bpid file=/var/run/rsyncd.pidlock file=/var/run/rsyncd.locktimeout = 300  [tongbu]path=/var/www/htmllist=yescomment = this is commentignore errors = yesread only = nohosts allow = 10.80.11.245hosts deny = *auth users backupsecrets file = /etc/rsyncd.secretsphp


注:tongbu爲發佈模塊,至關於路徑的別名hosts allow是隻容許鏈接的IPsecrets file = /etc/rsyncd.secrets這是密碼文件,同步的用戶爲backup,下面建立同步用戶#useradd backup#passwd backup#vim /etc/rsyncd.secretsbackup: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-x862、修改配置文件#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/p_w_picpaths"/>         </localpath>    </plugin> </head>/var/www/html爲發佈服務器的源碼發佈目錄主要修改紅色標記部分,密碼文件爲/etc/rsync.pas#vim /etc/rsync.pashtml


123456#解釋:123456表明的是Rsync server端的密碼,而且要以"#"作結尾。若是有多個密碼,增長多行就行。#chmod 600 /etc/rsync.pas3、啓動服務#<span verdana','sans-serif'"="" style="padding: 0px;font-size: 13px;color: black">./sersync2 -d –r這種方式常駐進程,若是須要開機啓動,加入到<span verdana','sans-serif'"="" style="padding: 0px;font-size: 13px;color: black">/etc/rc.local這樣只要修改發佈服務器/var/www/html的文件,web服務器就會自動同步。web

相關文章
相關標籤/搜索