Rsync简介php
Rsync是一款优秀的、快速的、多功能的本地或远程数据镜像同步备份工具。适用于unix/linux/windows等多种平台linux
从软件的名称Rsync(Remote Rynhronization)能够看出来,Rsync具备可以使本地主机不一样分区或目录之间及本地和远程两台主机之间的数据快速同步镜像,远程备份等功能c++
在同步备份时,默认状况下,Rsync经过其独特的“quick check”算法,仅同步大小或者最后修改时间发生变化的文件或目录(也能够根据权限,属主等变化同步,须要指定参数),甚至是只同步一个文件里有变化的内容部分,因此,能够实现快速的同步数据的功能算法
提示:传统的cp,scp工具拷贝每次均为完整拷贝,而rsync除了完整拷贝,还具有增量拷贝的功能,所以,从性能及效率上更胜一筹shell
Rsync的特性express
Rsync的工做方式windows
#本地数据传输 ##语法 rsync [OPTION...] SRC..[DEST] 语法说明 rsync为同步的命令 [OPTION...]为同步时的参数选项 SRC为源,即待拷贝的分区、文件或目录等 [DEST]为目的分区、文件、目录等 #经过远程shell进行传输 拉取:rsync [OPTION...] [USER@]HOST:SRC... [DEST] 推送:rsync [OPTION...] SRC.. [USER@]HOST:DEST 语法说明 rsync为同步的命令 [OPTION...]为同步时的参数选项 [USER@]HOST...为rsync同步的远程的链接用户和主机地址 SRC为源文件、分区、目录,和HOST之间用一个冒号链接 [DEST]为目的分区、文件、目录
Rsync参数选项说明bash
-v --详细模式输出,传输时的进度等信息 -z --compress传输室进行压缩以提升效率,--compress-level=NUM可按级别压缩 -r --recursive对子目录以递归模式,即目录下的全部目录都一样传输,注意是小写r -t --times保持文件时间信息 -o --owner保持文件属主信息 -p --poems保持文件权限 -g --group保持文件属组信息 -P --progress显示同步的过程及传输时的进度等信息 -a --archive归档模式,表示以递归方式传输文件,并保持全部文件属性,等于-rptopgD1 -e --rsh=COMMAND使用的信道协议,指定替代rsh的shell程序。例如:ssh --exclude=PATTERN指定排除不须要传输的文件模式 -D --devices保持设备文件信息 -l --links保留软链接
实例服务器
#三台虚拟机 1 IP:10.0.0.1 hostname:A-server 2 IP:10.0.0.2 hostname:B-server 3 IP:10.0.0.20 hostname:C-server #实例1 rsync -avz -P /etc /tmp/ #注意这里/etc,/etc/是有区别的,前者拷贝整个目录包括目录,后者拷贝目录里的全部东西 #实例2 [root@B-server ~]# mkdir -p /root/1/{2,3,4,5,6,} #建立目录 [root@A-server ~]# rsync -avzP -e 'ssh -p 22' root@10.0.0.2:/root/1 /tmp/ #拉取 [root@A-server ~]# rsync -avzP 'ssh -p 22' /tmp/etc/ root@10.0.0.2:/root/1/ #推送 #借助ssh key秘钥实现数据免秘钥验证加密传输 #就是说,若是实现设置了ssh key秘钥免登陆验证,既可用rsync经过ssh方式免登陆验证同步传输数据,这是生产场景最经常使用的方法之一 #配置免秘钥登陆,A>B [root@A-server ~]# ssh-keygen -t dsa #一路回车 [root@A-server ~]# ssh-copy-id -i ~/.ssh/id_dsa.pub root@10.0.0.2 #输入密码 [root@A-server ~]# rsync -avzP 'ssh -p 22' /tmp/etc root@10.0.0.2:/root/2 #再次推送,发现不须要密码 #实例3 #需求:要求在A-server上以rsync守护进程方式部署rsync服务,使得全部客户端主机,能够把本地数据经过rsync的方式到数据备份服务器A-server上。本例的客户端仅以B-server、C-server为例 ##配置rsync配置文件 [root@A-server ~]# cat /etc/rsyncd.conf ### #rsync_config #create by daniel 2018-02-01 #start uid = root gid = root use chroot = no max connections = 200 timeout = 300 pid file = /var/run/rsyncd.pid lock file = /var/run/rsyncd.lock log file = /var/log/rsyncd.log [daniel] path = /daniel/ ignore errors read only = false list = false hosts allow = 10.0.0.0/24 hosts deny = 10.0.0.0./32 auth users = rsync_backup secrets file = /etc/rsync.password #end ### #配置文件解读 uid:以什么用户读取本地目录 gid:同上 use chroot:是否使用chroot max connections:最大链接数 timeout:链接超时 pid file:pid文件 lock file:lock文件 log file:log文件 [daniel]:模块名,读取的时候须要使用这个 path:备份路径 ignore errors:忽略错误 read only:只读,true为是,false为否 hosts allow:容许主机 hosts deny:拒绝主机 auth users:验证用户 secrets file:认证文件 ##配置用户验证文件 [root@A-server ~]# cat /etc/rsync.password rsync_backup:123456 [root@A-server ~]# chmod 600 /etc/rsync.password #权限600 ##建立备份目录 [root@A-server ~]# mkdir /daniel [root@A-server ~]# chown -R root.root /daniel/ #由于uid,gid都是root全部要受权给root [root@A-server ~]# rsync --daemon ##启动rsync,以守护进程的方式启动 #--daemon 以守护进程的方式启动 #--address 绑定指定IP地址提供服务 #--config=FILE 更改配置文件路径,默认是/etc/rsyncd.conf #--port=PORT 更改服务端口,默认873 [root@A-server ~]# echo "/usr/bin/rsync --daemon" >>/etc/rc.local #开机自启动 #使用客户端测试rsync [root@B-server data]# mv /root/{1,2} /data/ [root@B-server data]# echo '123456' >/etc/rsync.password [root@B-server data]# chmod 600 /etc/rsync.password [root@B-server data]# rsync -avzP /data rsync_backup@10.0.0.1::daniel --password-file=/etc/rsync.password #查看A-server的/daniel [root@A-server ~]# ls /daniel/ data #--delete [root@B-server data]# mkdir /data/3 [root@B-server data]# rsync -avzP --delete /data/3/ rsync_backup@10.0.0.1::daniel --password-file=/etc/rsync.password #所有删掉了,由于delete的选项就是本地目录有什么远端就有什么,若是本地没有,远端会所有删掉 #扩展 #当你有多个模块(多个共享目录)时,就要写一大堆的配置,咱们在这种状况下能够简化配置文件 [root@A-server ~]# cat /etc/rsyncd.conf ### #rsync_config #create by daniel 2018-02-01 #start uid = root gid = root use chroot = no max connections = 200 timeout = 300 pid file = /var/run/rsyncd.pid lock file = /var/run/rsyncd.lock log file = /var/log/rsyncd.log ignore errors read only = false list = false hosts allow = 10.0.0.0/24 hosts deny = 10.0.0.0./32 auth users = rsync_backup secrets file = /etc/rsync.password [daniel] path = /daniel/ [daniel2] path = /daniel2/ 。。。 #end #以此类推
rsync+inotify实时数据同步框架
#rsync+inotify实时数据同步 #实验目的:B-server将本地数据实时同步推送到A-server [root@B-server /]# mkdir /server/scripts -p #检查是否支持inotify [root@B-server /]# ls -l /proc/sys/fs/inotify/ 总用量 0 -rw-r--r-- 1 root root 0 2月 5 16:53 max_queued_events -rw-r--r-- 1 root root 0 2月 5 16:53 max_user_instances -rw-r--r-- 1 root root 0 2月 5 16:53 max_user_watches #下载并安装inotify [root@B-server /]# mkdir /tmp/dowmloads [root@B-server /]# cd /tmp/dowmloads/ [root@B-server dowmloads]# wget https://sourceforge.net/projects/inotify-tools/files/inotify-tools/3.13/inotify-tools-3.13.tar.gz/download --no-check-certificate [root@B-server dowmloads]# tar zxf inotify-tools-3.13.tar.gz [root@B-server dowmloads]# cd inotify-tools-3.13 [root@B-server inotify-tools-3.13]# yum -y install gcc gcc-c++ [root@B-server inotify-tools-3.13]# ./configure --prefix=/usr/local/inotify [root@B-server inotify-tools-3.13]# make && make install #写事件监控脚本 [root@B-server inotify-tools-3.13]# mkdir -p /server/scripts [root@B-server inotify-tools-3.13]# vi /server/scripts/inotify.sh #### #!/bin/bash host01=10.0.0.1 src=/data/www/ dst=daniel user=rsync_backup rsync_passfile=/etc/rsync.password inotify_basedir=/usr/local/inotify/ # if [ ! -e "$src" ] \ || [ ! -e "${rsync_passfile}" ] \ || [ ! -e "${inotify_basedir}/bin/inotifywait" ] \ || [ ! -e "/usr/bin/rsync" ]; then echo "Check File and Folder" exit 9 fi # ${inotify_basedir}/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' -e close_write,\ delete,create,attrib $src | while read file #${inotify_basedir}/bin/inotifywait -mrq -e close_write,delete,create,attrib $src | while read file do #rsync -avzP --delete --timeout=100 --password-file=${rsync_passfile} $src $user@$host01::$dst >/dev/null 2>&1 cd $src && rsync -aruz -R --delete ./ --timeout=100 $user@$host01::$dst --password-file=${rsync_passfile} >/dev/null 2>&1 done exit 0 #### [root@B-server inotify-tools-3.13]# mkdir /data/www [root@B-server inotify-tools-3.13]# cd /server/scripts/ [root@B-server scripts]# chmod +x inotify.sh [root@B-server scripts]# sh inotify.sh & ##测试 #在/data/www下建立文件或写入文件试试,而后再查看10.0.0.1的daniel模块目录 [root@B-server www]# for n in `seq 100`; do mkdir /data/www/$n;done ##压力测试 #脚本测试 [root@B-server scripts]# vi inotify_Ceshi.sh #### #!/bin/sh count=150 while true do for ((i=1;i<=$count;i++)) do /bin/cp /server/scripts/10k.jpg /data/www/$i/10k_`echo $(date)$RANDOM|md5sum|cut -c 1-8`.jpg done sleep 1 for ((i=1;i<=$count;i++)) do /bin/cp /server/scripts/30k.jpg /data/www/$i/30k_`echo $(date)$RANDOM|md5sum|cut -c 1-8`.jpg done sleep 1 for ((i=1;i<=$count;i++)) do /bin/cp /server/scripts/50k.jpg /data/www/$i/50k_`echo $(date)$RANDOM|md5sum|cut -c 1-8`.jpg done sleep 1 done #### #首先A-sever,B-server要同步时间。ntpdate time.windwos.com [root@B-server scripts]# sh inotify.sh & #先启用同步脚本 [root@B-server scripts]# touch /tm/tmp.log #建立同步日志,用于查看,A-server也要 [root@B-server scripts]# sh inotify_Ceshi.sh & #开始测试脚本 [root@B-server www]# echo -en "`date +%H:%M`\t" >>/tmp/tmp.log && tree | wc -l >>/tmp/tmp.log #在A-server,B-server下使用这个命令来采集每秒建立的文件而后写入日志,每两秒一次,十次采集就够了,这个要在同步目录使用,或者tree命令后面,加一下同步目录路径 [root@B-server scripts]# kill -9 113580 #而后停掉inotify_Ceshi.sh,同时再次执行上面的命令两次,看看日志,是否是瞬间同步完成 #查看两边的日志,查看是否同步完成 [root@B-server www]# cp /tmp/tmp.log /tmp/`uname -n`.log [root@A-server daniel]# cp /tmp/tmp.log /tmp/`uname -n`.log [root@B-server tmp]# scp 10.0.0.1:/tmp/A-server.log #将两个日志拿到一块儿 [root@B-server tmp]# paste B-server.log A-server.log > inotify.log [root@B-server tmp]# awk '{if($1==$3) print $1" "$2" "$4" "(($2-$4));}' inotify.log 11:50 3632 3623 9 11:50 3943 3943 0 11:50 4183 4183 0 11:50 4503 4503 0 11:50 4823 4823 0 11:50 5063 5056 7 11:50 5383 5339 44 11:50 5783 5783 0 11:50 6183 6183 0 11:51 6423 6423 0 11:51 6983 6983 0 11:51 6983 6983 0 11:51 6983 6983 0 #作减法,看看同步的时候的两边差距 #而后能够增长脚本中的count数,增大压力,一直尝试
Sersync项目简介与框架设计
Sersync项目利用inotify与rsync技术实现对服务器数据实时同步的解决方案,其中inotify用于监控sersync所在服务器上文件系统的事件变化,rsync是目前普遍使用的本地及异地数据同步工具,其优势是只对变化的目录数据操做,甚至是一个文件不一样的部分进行同步,因此其优点大大超过使用挂接文件系统或scp等方式进行镜像同步
目前使用的比较多的同步程序版本是inotify-tools,另一个是google开源项目Openduckbill(依赖于inotify-tools),这两个都是基于脚本语言编写的,其设计思路一样是采用inotify与rsync命令
Sersync同步需求图
当前版本sersync依赖于rsync进行数据同步。以下图所示,在同步主服务器Sersync上开启sersync,sersync负责监控配置路径中的文件系统时间变化,而后调用rsync命令把更新的文件同步到目标服务器(Rsync-1,Rsync-2)
Sersync安装配置
环境准备
Sersync ip:10.0.0.1 hostname:Sersync Rsync-1 ip:10.0.0.2 hostname:Rsync-1 Rsync-2 ip:10.0.0.3 hostname:Rsync-2
安装并配置
#在Rsync-1,Rsync-2配置rsync [root@Rsync-1 ~]# vi /etc/rsyncd.conf # #### #rsync_config #create by daniel 2018-02-01 #start uid = root gid = root use chroot = no max connections = 200 timeout = 300 pid file = /var/run/rsyncd.pid lock file = /var/run/rsyncd.lock log file = /var/log/rsyncd.log ignore errors read only = false list = false hosts allow = 10.0.0.0/24 hosts deny = 10.0.0.0./32 auth users = rsync_backup secrets file = /etc/rsync.password [www] comment = daniel path = /data/www/www [bbs] comment = daniel path = /data/www/bbs/ [blog] comment = daniel path = /data/www/blog #### [root@Rsync-1 ~]# mkdir -p /data/www/{www,bbs,blog} #建立同步目录 [root@Rsync-1 ~]# echo rsync_backup:123456 >/etc/rsync.password #写入用户密码,用于同步 [root@Rsync-1 ~]# chmod 600 /etc/rsync.password #修改权限 [root@Rsync-1 ~]# echo "/usr/bin/rsync --daemon" >>/etc/rc.local #开机自启动 #配置和Sersync [root@Sersync ~]# echo '123456' >/etc/rsync.password #配置rsync权限认证 [root@Sersync ~]# mkdir -p /data/www/{www,bbs,blog} #建立同步目录 [root@Sersync ~]# for n in `seq 100`;do mkdir /data/www/www/$n;done #建立一百个目录 [root@Sersync ~]# chmod 600 /etc/rsync.password [root@Sersync ~]# rsync -avzP /data/www/www/ rsync_backup@10.0.0.2::www --password-file=/etc/rsync.password [root@Sersync ~]# rsync -avzP /data/www/www/ rsync_backup@10.0.0.3::www --password-file=/etc/rsync.password #同步到Rsync-1和Rsync-2中的www模块 [root@Rsync-1 ~]# ls /data/www/www/ 1 12 16 2 23 27 30 34 38 41 45 49 52 56 6 63 67 70 74 78 81 85 89 92 96 10 13 17 20 24 28 31 35 39 42 46 5 53 57 60 64 68 71 75 79 82 86 9 93 97 100 14 18 21 25 29 32 36 4 43 47 50 54 58 61 65 69 72 76 8 83 87 90 94 98 11 15 19 22 26 3 33 37 40 44 48 51 55 59 62 66 7 73 77 80 84 88 91 95 99 #查看 #安装Sersync [root@Sersync ~]# mkdir /tmp/downloads [root@Sersync ~]# cd /tmp/downloads/ [root@Sersync downloads]# tar zxf sersync_64bit_binary_stable_final.tar.gz [root@Sersync downloads]# mv GNU-Linux-x86/ sersync [root@Sersync downloads]# cd sersync [root@Sersync sersync]# mkdir bin conf logs #规范目录 [root@Sersync sersync]# mv confxml.xml conf [root@Sersync sersync]# mv sersync2 bin/sersync [root@Sersync sersync]# cd .. [root@Sersync downloads]# mv sersync /usr/local/ [root@Sersync downloads]# cd /usr/local/sersync/ [root@Sersync sersync]# cp conf/confxml.xml conf/confxml.xml.default #修改配置文件 [root@Sersync sersync]# vi conf/confxml.xml #### <sersync> <localpath watch="/data/www/www"> <remote ip="10.0.0.2" name="www"/> <remote ip="10.0.0.3" name="www"> </localpath> <!--##################################--> <localpath watch="/data/www/bbs/"> <remote ip="10.0.0.2" name="bbs"/> <remote ip="10.0.0.3 name="bbs""> </localpath> <!--##################################--> <localpath watch="/data/www/blog/"> <remote ip="10.0.0.2" name="blog"/> <remote ip="10.0.0.3 name="blog""> </localpath> <!--##################################--> <rsync> <commonParams params="-artuz"/> <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/> <userDefinedPort start="false" port="874"/><!-- port=874 --> <timeout start="false" time="100"/><!-- timeout=100 --> <ssh start="false"/> </rsync> <failLog path="/usr/local/sersync/logs/rsync_fail_log" timeToExecute="60"/><!--default every 60mins execute once--> ####这贴的是修改的位置,如下为全部配置文件 #### <?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/www/www"> <remote ip="10.0.0.2" name="www"/> <remote ip="10.0.0.3" name="www"/> </localpath> <!--##################################--> <localpath watch="/data/www/bbs/"> <remote ip="10.0.0.2" name="bbs"/> <remote ip="10.0.0.3 name="bbs"/> </localpath> <!--##################################--> <localpath watch="/data/www/blog/"> <remote ip="10.0.0.2" name="blog"/> <remote ip="10.0.0.3 name="blog"/> </localpath> <!--##################################--> <rsync> <commonParams params="-artuz"/> <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/> <userDefinedPort start="false" port="874"/><!-- port=874 --> <timeout start="false" time="100"/><!-- timeout=100 --> <ssh start="false"/> </rsync> <failLog path="/usr/local/sersync/logs/rsync_fail_log" 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> #### [root@Sersync sersync]# echo 'export PATH=$PATH:/usr/local/sersync/bin' >>/etc/profile #配置全局路径 [root@Sersync sersync]# source /etc/profile [root@Sersync sersync]# sersync -r -d -o /usr/local/sersync/conf/confxml.xml #启动 #-o --指定配置文件 #-d --后台运行 #-r --第一次运行使用,初始化数据,让两边同步 #而后建立个目录尝试一下 [root@Sersync sersync]# mkdir /data/www/{www,bbs,blog}/555 #这时候发现除了www模块同步,其余两个都没有 #如今咱们要配置多实例的 [root@Sersync sersync]# cp conf/confxml.xml conf/www_confxml.xml [root@Sersync sersync]# cp conf/confxml.xml conf/bbs_confxml.xml [root@Sersync sersync]# cp conf/confxml.xml conf/blog_confxml.xml #生成三份文件(到这里你应该就知道我要干什么了吧) #配置这三个文件 ####www <sersync> <localpath watch="/data/www/www"> <remote ip="10.0.0.2" name="www"/> <remote ip="10.0.0.3" name="www"/> </localpath> <!-- ################################## --> <rsync> <commonParams params="-artuz"/> <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/> <userDefinedPort start="false" port="874"/><!-- port=874 --> <timeout start="false" time="100"/><!-- timeout=100 --> <ssh start="false"/> </rsync> <failLog path="/usr/local/sersync/logs/rsync_www_log" timeToExecute="60"/><!--default every 60mins execute once--> ####这里只写修改的地方了 ####bbs <sersync> <localpath watch="/data/www/bbs/"> <remote ip="10.0.0.2" name="bbs"/> <remote ip="10.0.0.3" name="bbs"/> </localpath> <!-- ################################## --> <rsync> <commonParams params="-artuz"/> <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/> <userDefinedPort start="false" port="874"/><!-- port=874 --> <timeout start="false" time="100"/><!-- timeout=100 --> <ssh start="false"/> </rsync> <failLog path="/usr/local/sersync/logs/rsync_bbs_log" timeToExecute="60"/><!--default every 60mins execute once--> #### ####blog <sersync> <localpath watch="/data/www/blog/"> <remote ip="10.0.0.2" name="blog"/> <remote ip="10.0.0.3" name="blog"/> </localpath> <!-- ################################## --> <rsync> <commonParams params="-artuz"/> <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/> <userDefinedPort start="false" port="874"/><!-- port=874 --> <timeout start="false" time="100"/><!-- timeout=100 --> <ssh start="false"/> </rsync> <failLog path="/usr/local/sersync/logs/rsync_blog_log" timeToExecute="60"/><!--default every 60mins execute once--> ####blog #要先把前面那个进程删掉 #如今咱们启动三个sersync [root@Sersync sersync]# sersync -r -d -o /usr/local/sersync/conf/www_confxml.xml [root@Sersync sersync]# sersync -r -d -o /usr/local/sersync/conf/bbs_confxml.xml [root@Sersync sersync]# sersync -r -d -o /usr/local/sersync/conf/blog_confxml.xml [root@Sersync sersync]# for i in `seq 1000`;do mkdir /data/www/{www,bbs,blog}/$i;done #在每一个模块目录下建立一千个目录,查看同步 [root@Sersync sersync]# cat >>/etc/rc.local<<EOF > #sersync daniel > sersync -d -o /usr/local/sersync/conf/www_confxml.xml > sersync -d -o /usr/local/sersync/conf/bbs_confxml.xml > sersync -d -o /usr/local/sersync/conf/blog_confxml.xml > EOF #开机自动同步,最好不要加r,由于它会从0同步一遍
Sersync参数说明
-r 在开启实时监控的以前对主服务器目录与远处目标机目录进行一次总体同步
-o 指定配置文件,若是不加o,那么会自动使用跟serync在同一目录的confxml.xml文件
-n 指定默认的线程池的线程总数
-d 后台运行服务
-m 不进行同步,只容许插件
插件基本配置和使用
#插件内容在配置文件中的46-65行 #### <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> #### 其中plugin标签设置为true时,就会调用插件,经过name参数指定须要执行的插件。目前支持的有command refreshCDN socket http四种插件。其中,http插件目前因为兼容性缘由去除,之后会从新加入 #command插件 #### <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> #### 当文件同步玩抽,会调用command插件,如同文件是test.php,则test.php文件在改动以后,电泳rsync同步到远程服务器后,调用command插件,执行 /bin/sh test.php suffix >/dev/null 2>&1