原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://nolinux.blog.51cto.com/4824967/1433623
在博文企业实时同步方案—-Sersync介绍中我们详细介绍了Sersync的原理,设计架构以及和Inotify 等等的优势区别。这里我就带大家一起来做一下 Rsync +Sersync 这个同步分发架构案例。
实验环境介绍:
内核版本:2.6.32-431.el6.x86_64 系统采用最小化安装,系统经过了基本优化,selinux为关闭状态,iptables为无限制模式 源码包存放位置:/root Rsync客户端+Sersync服务器(SERSYNC),承担角色MASTER,IP:172.16.100.3,主机名:rsync-client-sersync SERSYNC_SLAVE,作为SERSYNC的从机,如果SERSYNC宕机,SERSYNC_SLAVE来接管服务,保证业务不中断,本实验不包括它! Web服务器A(即Rsync服务端)(SWEB1),承担角色S1,IP:172.16.100.1,主机名:rsync-server-1 Web服务器B(即Rsync服务端)(SWEB2),承担角色S2,IP:172.16.100.2,主机名:rsync-server-
[root@SWEB1 ~]# yum install rsync -y
[root@SWEB1 ~]# cat > /etc/rsyncd.conf << EOF #Rsync server #created by sunsky 00:17 2013-06-28 ##rsyncd.conf start## uid = root # rsync对后面模块中的path路径拥有什么权限 gid = root # rsync对后面模块中的path路径拥有什么权限 use chroot = no # 安全操作 max connections = 2000 # 定义连接数2000 timeout = 600 # 600秒超时 pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log ignore errors # 忽略错误 read only = false # false才能上传文件,true不能上传文件 list = false # 文件列表 hosts allow = 172.16.100.0/24 hosts deny = * auth users = rsync_bak # 虚拟用户,同步时需要用这个用户 secrets file = /etc/rsync.password # 密码文件 ##################################### [web] # 模块名称 comment = redhat.sx site files by sunsky 00:17 2013-06-28 # 注释 path = /data/web # 模块的路径 #################################### [download] comment = redhat.sx site sit data files by sunsky 00:17 2013-06-28 path = /data/download ##################################### EOF
[root@SWEB1 ~]# mkdir /data/{web,download} -p [root@SWEB1 ~]# tree /data /data ├── download └── web 2 directories, 0 files
[root@SWEB1 /]# echo 'rsync_bak:redhat' > /etc/rsync.password [root@SWEB1 /]# chmod 600 /etc/rsync.password [root@SWEB1 /]# cat /etc/rsync.password rsync_bak:redhat [root@SWEB1 /]# ll /etc/rsync.password -rw-------. 1 root root 7 Jun 4 00:20 /etc/rsync.password
[root@SWEB1 ~]# rsync --daemon
[root@SWEB1 /]# lsof -i tcp:873 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME rsync 20982 root 3u IPv4 88170 0t0 TCP *:rsync (LISTEN) rsync 20982 root 5u IPv6 88171 0t0 TCP *:rsync (LISTEN)
[root@SWEB1 /]# echo "# rsyncd service daemon by sun 20140702" >>/etc/rc.local [root@SWEB1 /]# echo "/usr/bin/rsync --daemon" >> /etc/rc.local [root@SWEB1 /]# grep daemon /etc/rc.local # rsyncd service daemon by sun 20140702 /usr/bin/rsync --daemon
[root@SWEB1 /]# pkill rsync [root@SWEB1 /]# rsync --daemon
[root@SERSYNC /]# yum install rsync -y [root@SERSYNC /]# echo "redhat" > /etc/rsync.password [root@SERSYNC /]# chmod 600 /etc/rsync.password [root@SERSYNC /]# cat /etc/rsync.password Redhat [root@SERSYNC ~]# ll /etc/rsync.password -rw-------. 1 root root 7 Jun 4 00:20 /etc/rsync.password
[root@SERSYNC ~]# mkdir /data/{web,download} -p [root@SERSYNC ~]# touch /data/{web/index.html,download/a.jpg} [root@SERSYNC ~]# tree /data /data ├── download │ └── a.jpg └── web └── index.html 2 directories, 2 files
[root@SERSYNC ~]# rsync -avzP /data/web rsync_bak@172.16.100.1::web/ --password-file=/etc/rsync.password sending incremental file list web/ web/index.html 0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=0/2) sent 92 bytes received 31 bytes 246.00 bytes/sec total size is 0 speedup is 0.00 [root@SERSYNC ~]# rsync -avzP /data/download/ rsync_bak@172.16.100.1::download/ --password-file=/etc/rsync.password sending incremental file list ./ a.jpg 0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=0/2) sent 75 bytes received 30 bytes 210.00 bytes/sec total size is 0 speedup is 0.00
[root@SERSYNC ~]# rsync -avzP /data/web rsync_bak@172.16.100.2::web/ --password-file=/etc/rsync.password sending incremental file list web/ web/index.html 0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=0/2) sent 92 bytes received 31 bytes 246.00 bytes/sec total size is 0 speedup is 0.00 [root@SERSYNC ~]# rsync -avzP /data/download/ rsync_bak@172.16.100.2::download/ --password-file=/etc/rsync.password sending incremental file list ./ a.jpg 0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=0/2) sent 75 bytes received 30 bytes 70.00 bytes/sec total size is 0 speedup is 0.00
[root@SWEB1 ~]# tree /data/ /data/ ├── download │ └── a.jpg └── web └── web └── index.html 3 directories, 2 files
[root@SERSYNC ~]# mkdir /source/ [root@SERSYNC ~]# cd /source/ [root@SERSYNC ~]# wget https://sersync.googlecode.com/files/sersync2.5.4_64bit_binary_stable_final.tar.gz [root@SERSYNC source]# tar zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz GNU-Linux-x86/ GNU-Linux-x86/sersync2 GNU-Linux-x86/confxml.xml
[root@SERSYNC source]# cp -r GNU-Linux-x86 /usr/local/sersync [root@SERSYNC source]# tree /usr/local/sersync /usr/local/sersync ├── confxml.xml └── sersync2 0 directories, 2 files
[root@SERSYNC source]# cd /usr/local/sersync [root@SERSYNC sersync]# mkdir conf bin logs [root@SERSYNC sersync]# mv confxml.xml conf [root@SERSYNC sersync]# mv sersync2 bin/sersync [root@SERSYNC sersync]# tree . ├── bin │ └── sersync ├── conf │ └── confxml.xml └── logs 3 directories, 2 files
[root@SERSYNC sersync]# cat conf/confxml.xml -n
<?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> <sersync> <localpath watch="/opt/tongbu"> <remote ip="127.0.0.1" name="tongbu1"/> <!--<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 ecute 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 ffix--> <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>
<localpathwatch="/opt/tongbu"> #定义本地要同步的目录 <remoteip="127.0.0.1" name="tongbu1"/> # <!--<remoteip="192.168.8.39" name="tongbu"/>--> #同步到哪个机器,,同步到机器的哪个模块 <!--<remoteip="192.168.8.40" name="tongbu"/>--> </localpath>
<localpathwatch="/data/web"> <remoteip="172.16.100.1" name="web"/> #这里取掉了两旁的注释 <remoteip="172.16.100.2" name="web"/> #这里取掉了两旁的注释 </localpath> 该文件中分隔符形式为:<!--###########################-->
<commonParamsparams="-artuz"/> <auth start="false"users="root" passwordfile="/etc/rsync.pas"/> <userDefinedPortstart="false" port="874"/><!-- port=874 --> <timeoutstart="false" time="100"/><!-- timeout=100 --> <sshstart="false"/>
<commonParamsparams="-aruz"/> <auth start="true"users="rsync_bak"passwordfile="/etc/rsync.password"/> <userDefinedPortstart="false" port="874"/><!-- port=874 --> <timeoutstart="true" time="100"/><!-- timeout=100 --> <sshstart="false"/>
rsync -aruz --timeout=100 /data/web rsync_bak@172.16.100.1::www/ --password-file=/etc/rsync.password
<failLogpath="/tmp/rsync_fail_log.sh"timeToExecute="60"/><!--default every 60mins execute once-->
[root@SERSYNC sersync]# cat -n /usr/local/sersync/conf/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> <sersync> <localpath watch="/data/web"> <remote ip="172.16.100.1" name="web"/> <remote ip="172.16.100.2" name="web"/> </localpath> <rsync> <commonParams params="-aruz"/> <auth start="true" users="rsync_bak" passwordfile="/etc/rsync.password"/> <userDefinedPort start="false" port="874"/><!-- port=874 --> <timeout start="true" time="100"/><!-- timeout=100 --> <ssh start="false"/> </rsync> <failLog path="/usr/local/logs/rsync_fail_log.sh" timeToExecute="60"/><!--default every mins 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 ffix--> <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>
[root@SERSYNC sersync]# cp /usr/local/sersync/conf/confxml.xml /usr/local/sersync/conf/download_confxml.xml
23 <sersync> 24<localpath watch="/data/download"> 25 <remote ip="172.16.100.1" name="download"/> 26 <remote ip="172.16.100.2" name="download"/> 27</localpath> 28<rsync>
[root@SERSYNC sersync]# echo 'export PATH=$PATH:/usr/local/sersync/bin'>>/etc/profile [root@SERSYNC sersync]# tail -1 /etc/profile export PATH=$PATH:/usr/local/sersync/bin [root@SERSYNC sersync]# . /etc/profile [root@SERSYNC sersync]# which sersync /usr/local/sersync/bin/sersync
[root@SERSYNC ~]# ls /usr/local/sersync/conf/* /usr/local/sersync/conf/confxml.xml /usr/local/sersync/conf/confxml.xml.bak.2014-06-04 /usr/local/sersync/conf/download_confxml.xml [root@SERSYNC ~]# sersync -r -d -o /usr/local/sersync/conf/confxml.xml set the system param execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events parse the command param option: -r rsync all the local files to the remote servers before the sersync work option: -d run as a daemon option: -o config xml name: /usr/local/sersync/conf/confxml.xml daemon thread num: 10 parse xml config file host ip : localhosthost port: 8008 daemon start,sersync run behind the console use rsync password-file : user isrsync_bak passwordfile is /etc/rsync.password config xml parse success please set /etc/rsyncd.conf max connections=0 Manually sersync working thread 12 = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads) Max threads numbers is: 32 = 12(Thread pool nums) + 20(Sub threads) please according your cpu ,use -n param to adjust the cpu rate chmod: cannot access `/usr/local/logs/rsync_fail_log.sh': No such file or directory ------------------------------------------ rsync the directory recursivly to the remote servers once working please wait... execute command: cd /data/web && rsync -aruz -R --delete ./ --timeout=100 rsync_bak@172.16.100.1::web --password-file=/etc/rsync.password >/dev/null 2>&1 run the sersync: watch path is: /data/web [root@SERSYNC ~]# sersync -r -d -o /usr/local/sersync/conf/download_confxml.xml set the system param execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events parse the command param option: -r rsync all the local files to the remote servers before the sersync work option: -d run as a daemon option: -o config xml name: /usr/local/sersync/conf/download_confxml.xml daemon thread num: 10 parse xml config file host ip : localhosthost port: 8008 daemon start,sersync run behind the console use rsync password-file : user isrsync_bak passwordfile is /etc/rsync.password config xml parse success please set /etc/rsyncd.conf max connections=0 Manually sersync working thread 12 = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads) Max threads numbers is: 32 = 12(Thread pool nums) + 20(Sub threads) please according your cpu ,use -n param to adjust the cpu rate chmod: cannot access `/usr/local/logs/rsync_fail_log.sh': No such file or directory ------------------------------------------ rsync the directory recursivly to the remote servers once working please wait... execute command: cd /data/download && rsync -aruz -R --delete ./ --timeout=100 rsync_bak@172.16.100.1::download --password-file=/etc/rsync.password >/dev/null 2>&1 run the sersync: watch path is: /data/download
[root@SERSYNC ~]# ps -ef |grep sersync root 2114 1 0 01:56 ? 00:00:00 sersync -r -d -o /usr/local/sersync/conf/confxml.xml root 2223 1 0 02:03 ? 00:00:00 sersync -r -d -o /usr/local/sersync/conf/download_confxml.xml root 2295 2244 0 02:08 pts/2 00:00:00 grep sersync
[root@SERSYNC ~]# cat >>/etc/rc.local<< 'EOF' > # sync data to 172.16.100.1,172.16.100.2 > sersync -d -o /usr/local/sersync/conf/confxml.xml > sersync -d -o /usr/local/sersync/conf/download_confxml.xml > EOF
[root@SERSYNC web]# for i in {1..10000};do echo 123456 > /data/web/$i &>/dev/null;done [root@SERSYNC web]# for i in {1..10000};do echo 123456 > /data/download/$i &>/dev/null;done [root@SERSYNC web]# tree /data/ /data/ ├── download │ ├── 1 ...... #中间信息省略 ...... #中间信息省略 ├── 9997 ├── 9998 ├── 9999 └── index.html 2 directories, 20001 files
[root@SERSYNC ~]# ps -ef |grep rsync|wc -l 52 [root@SERSYNC ~]# ps -ef |grep rsync|wc -l 63 [root@SERSYNC ~]# ps -ef |grep rsync|wc -l 20 [root@SERSYNC ~]# ps -ef |grep rsync|wc -l 83 [root@SERSYNC ~]# ps -ef |grep rsync|wc -l 83
[root@SERSYNC sersync]# cat conf/confxml.xml -n <?xml version="1.0" encoding="ISO-8859-1"?> <head version="2.5"> <host hostip="localhost" port="8008"></host> hostip与port是针对插件的保留字段,对于同步功能没有任何作用,保留默认即可。 <debug start="false"/> 该行为Debug开启开关。true为开启debug模式,会在sersync正在运行的控制台,打印 inotify 事件与 rsync 同步命令,生产环境一般不开启。 <fileSystemfs="false"/>#对于XFS文件系统的用户,需要将这个选项开启,才能使sersync正常工作 对于sersync监控的文件,会默认过滤系统的临时文件(以“开头,以“~”结尾),除了这些文件外,在6-11行中,我们还可以自定义其它需要过滤的文件。 通过将 start 设置为 true 后可开启过滤功能,在exclude标签中可使用正则表达式。默认给出的两个例子分别是过滤以“z”结尾的文件与过滤监控目录下的info路径(监控路径/info/*),可以根据需求自己添加。但在开启的时候,自己一定要测试下,如果正则表达式出现错误,控制台会有相应提示。相比较使用 Rsync 的xclude 功能,被过滤的路径,不会加入监控,大大减少 Rsync 同步的通讯量 <filter start="false"> <exclude expression="(.*)\.svn"></exclude> <exclude expression="(.*)\.gz"></exclude> <exclude expression="^info/*"></exclude> <exclude expression="^static/*"></exclude> </filter> 第123行用来定义 inotify 监控参数,我们可以根据项目的特点来优化 Sersync。 对多数应用,可以尝试把 createFile(监控文件事件选项)设置为false来提高性能,进一步减少 Rsync通讯。因为拷贝文件到监控目录会产生 create 事件与 close_write 事件,所以如果关闭create 事只监控文件拷贝结束时的事件 close_write,同样可以实现文件完整同步。 注要使得 createFolder 保持为true,如果将createFolder设为false,则不会对产生的目录进行监控,该下的子文件与子目录也不会被监控,所以除非特殊需要,请开启。默认情况下对创建文件(目录)事件与文件(目录)事件都进行监控,如果项目中不需要删除远程目标服务器的文件(目录),则可以将 dele 参数设置为 false,则不对删除事件进行监控。 <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> <sersync> 第248行用来定义所要同步和监控的目录文件。 /optongbu目录为sersync主服务器本地待同步的目录,ip=“192.168.8.39”为从服务器的ip地址,如果有多个器,依次列出来即可。name=“tongbu”,这里的tongbu为rsyncd.con的模块名字,即中括号中的名称。 <localpath watch="/opt/tongbu"> <remote ip="127.0.0.1" name="tongbu1"/> <!--<remote ip="192.168.8.39" name="tongbu"/>--> <!--<remote ip="192.168.8.40" name="tongbu"/>--> </localpath> 第295行用来定义rsync的命令参数 在 cmonParams 项,我们可以自定义rsync的同步参数,默认是-artuz,auth star“false”设置为true的时候,使用rsync的认证模式传送,需要配置user与passwordfile(-password-fileetc/rsync.pas)来使用。userDefinedPort 当同步目标服务器的rsync端口不是默认端口的时候使用(-port74)。timeout设置rsync的timeout事件(-timeout=100)。<ssh start=”false”/>如启表示ssh使用rsync -e ssh的方式进行传输。 <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> 第3用来定义失败日志脚本配置 如件同步传输失败,会重新传送,再次失败就会写入 rsync_fail_log.sh,然后每隔一段时间(timeToExecute进行设置)执行该脚本再次重新传送,然后清空该脚本。可以通过path来设置日志路径 <failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins ecute once--> 第372行用来定义Crontab定期整体同步功能 Cronb可以对监控路径与远程目标主机每隔一段时间进行一次整体同步,可能由于一些原因两次失败重传都失,这个时候如果开启了 crontab 功能,还可以进行一次保证各个服务器文件一致,如果文件量比较大,crtab的时间间隔要设的大一些,否则可能增加通讯开销,schedule这个参数是设置crontab的时间间隔,默600分钟。 如启了 filter 文滤功能,那么crontab整体同步也需要设置过滤,否则虽然实时同步的时候文件被过滤了,但 crontab 整步的时候,如果不单独设置crontabfilter,还会将需过滤的文件同步到远程从服务器,crontab的过滤正filter过滤的不同,也给出了两个实例分别对应与过滤文件与目录,总之如果同时开启了filter与crontab,则要开启crontab的crontabfilter,并按示例设置使其与filter的过滤一一对应。 <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> 从4到行尾,都是插件的相关信息。当plugin标签设置为true时候,在同步文件或路径到远程服务器之后,会插件。通过name参数指定需要执行的插件。目前支持的有command、refreshCDN、socket、http四种插件中,http插件目前由于兼容性原因已经去除,以后会重新加入。 <plugin name="command"> <param prefix="/bin/sh" suffix="" ignoreError="true"/><!--prefix /opt/tongbu/mmm.sh ffix--> <filter start="false"> <include expression="(.*)\.php"/> <include expression="(.*)\.sh"/> </filter> </plugin> 第548行为插件socket的相关配置 sock插件,开启该模块,则向指定ip与端口发送inotify所产生的文件路径信息 <plugin name="socket"> <localpath watch="/opt/tongbu"> <deshost ip="192.168.138.20" port="8009"/> </localpath> </plugin> 第595行为插件refreshCDN的相关配置 refrhCDN 用来在同步过程中将文件发送到目地服务器后,刷新cdn接口。如果不想使用,则将start属性设为fae即可。该模块根据chinaCDN的协议,进行设计,当有文件产生的时候,就向cdn解耦发送需要刷新的路径。其中localpath watch=“/data0/htdocs/cms.xoyo.com/site/”是需要监控的目录。cdinfo标签指定了cdn接口的域名,端口号,以及用户名与密码。sendurl 标需要刷新的url的前缀。regexurl 标签中,regex属性为true时候,使用match属性的正则语句匹配inotify返回的路径信息,并将正则匹配到的部分作为url一部分 下置文件自带的意思为,如果产生文件事件为:/data0/htdoc/cms.xoyo.com/site/jx3.xoyo.com/image/a/12txt 经面的match正则匹配后,最后刷新的路径是:http://pic.xoyo.com/cms/a/123.txt 如果gex属性为false,最后刷新的路径就是:http://pic.xoyo.com/cms/jx3.xoyo.com/images/a/123.txt <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
[root@SERSYNC ~]# sersync -d -m command
[root@SERSYNC ~]# sersync -d -m refreshCDN
[root@SERSYNC ~]# sersync -d -m socket
[root@SERSYNC ~]# sersync -d -m http
转自:http://nolinux.blog.51cto.com/4824967/1433623
原创文章,作者:s19930811,如若转载,请注明出处:http://www.178linux.com/1968
评论列表(1条)
不错的文章,内容惊涛骇浪.禁止此消息:nolinkok@163.com