首页 文章 精选 留言 我的

精选列表

搜索[SSE增量渲染],共10000篇文章
优秀的个人博客,低调大师

第6章—渲染web视图—使用Apache Tiles视图定义布局

使用Apache Tiles视图定义布局 Tiles是一个免费的开源模板Java应用程序的框架。基于复合模式简化的用户界面的构建。对于复杂的网站仍是最简单、最优雅的方式与任何MVC技术一起工作。Struts2对Tiles提供了支持,如今Tiles发展已有13个年头,成为Apache的一个独立项目,我们可以单独使用Tiles来构建用户界面布局。 Tiles项目:http://tiles.apache.org/index.html Tiles的配置DTD定义:http://tiles.apache.org/framework/tiles-core/dtddoc/index.html 本文主要通过构建一个简单的页面布局来认识Apache Tiles3.x(由于Tiles2.x和Tiles3.x存在较大差异)。 本人的目录结构如下: image 1.准备工作 1.1安装Apache Tiles3.x依赖的Jar <dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-extras</artifactId> <version>3.0.5</version> </dependency> <dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-servlet</artifactId> <version>3.0.5</version> </dependency> <dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-jsp</artifactId> <version>3.0.5</version> </dependency> 注意:这里使用了Apache3.x完整包依赖。 1.3配置web.xml ​ 在web.xml中添加Tiles监听器 <listener> <listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class> </listener> 关于Tiles的监听器可以自定义实现,参见:http://tiles.apache.org/framework/config-reference.html 2.分析界面组成,构建布局文件 假设本案例中的页面构成如图: image 分析界面布局,找不通用部分,特殊部分。 在webapp下创建layout文件夹放在布局文件,snippet文件夹放置公共部分。 通过分析,将布局切割为header,body,footer,并且将HTML页面中的meta,script公共部分抽取出来。 /snippet/meta.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> /snippet/script.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <style> div { width: 480px; height: 80px; background: silver; } #body { background: lime; } </style> <script type="text/javascript"> document.writeln("这句话是由JavaScript写入页面的。"); </script> /snippet/header.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <h3> 这是头部 </h3> /snippet/footer.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <h3>这是页脚</h3> /snippet/index_body.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <pre> 这是页面的主体部分 </pre> 通过上面的公共部分和主体,构建一个布局文件如下: /layout/index_layout.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%> <!DOCTYPE html> <html> <head> <tiles:insertAttribute name="meta" /> <title><tiles:insertAttribute name="title" /></title> <tiles:insertAttribute name="script" /> </head> <body> <div id="header"> <tiles:insertAttribute name="header" /> </div> <div id="body"> <tiles:insertAttribute name="body" /> </div> <div id="footer"> <tiles:insertAttribute name="footer" /> </div> </body> </html> 3.Tiles的复合布局定义 Tiles是通过在xml文件中配置definition进行页面公共部分的重用,页面布局的组合。 /WEB-INF/tiles-defs.xml 定义好公共部分之后,通过配置definition来组合页面布局。 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN" "http://tiles.apache.org/dtds/tiles-config_3_0.dtd"> <!-- Definitions for Tiles documentation --> <tiles-definitions> <definition name="tiles.base.definition"> <put-attribute name="meta" value="/snippet/meta.jsp" /> <put-attribute name="script" value="/snippet/script.jsp" /> <put-attribute name="header" value="/snippet/header.jsp" /> <put-attribute name="footer" value="/snippet/footer.jsp" /> </definition> </tiles-definitions> 上面的definition可以说是抽象的,仅仅作为基本的定义抽取了界面中最通用的部分,而且并未指定具体的模版文件(布局文件)。下面通过继承tiles.base.definition来定一个tiles.index.definition其布局模版为/layout/index_layout.jsp。 <definition name="tiles.index.definition" extends="tiles.base.definition" template="/layout/index_layout.jsp"> <put-attribute name="body" value="/snippet/index_body.jsp" /> </definition> 上面定义tiles.index.definition,新增了body,其值为/snippet/index_body.jsp页面。 4.使用复合布局 ​ 到这里已经将页面的布局进行了分割,组合。现在应用definition来构建一个请求响应页面。 /example/index.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%> <tiles:insertDefinition name="tiles.index.definition"> <tiles:putAttribute name="title" value="这是一个有Apache Tiles构建的页面布局." /> </tiles:insertDefinition> 5.启动服务器,访问/example/index.jsp 页面展示效果: image 接下来看看页面的源代码: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>这是一个有Apache Tiles构建的页面布局.</title> <style> div { width: 480px; height: 80px; background: silver; } #body { background: lime; } </style> <script type="text/javascript"> document.writeln("这句话是由JavaScript写入页面的。"); </script> </head> <body> <div id="header"> <h3> 这是头部 </h3> </div> <div id="body"> <pre> 这是页面的主体部分 </pre> </div> <div id="footer"> <h3>这是页脚</h3> </div> </body> </html> 该例子中布局index_layout.jsp中body是可变的,title对一个不同的页面有不同的标题设置。在tiles-defx.xml的tiles.index.definition继承了tiles.base.definition,并且添加了其body页面,接着在插入tiles.index.definition的index.jsp页面添加了title。这样做达到的效果是整个站点的header,footer,meta,script抽取到了一个definition,然后通过继承的方式进行扩展,丰富不同的布局的页面组成元素,在具体的响应页面来定义专属该页面的内容。从而达到对页面的布局的控制,公共部分的复用的效果。 6.总结 本文仅仅是一个简单的示例,然而大部分内容被抽取公共部分占去,这样的结果并非意外,对于页面布局的划分,组合,重用才是使用Tiles之前最为繁重和复杂的工作,这些工作能够做的合理,优雅,配置definition自然就轻松多了。

优秀的个人博客,低调大师

模拟使用Flume监听日志变化,并且把增量的日志文件写入到hdfs中

1.采集日志文件时一个很常见的现象 采集需求:比如业务系统使用log4j生成日志,日志内容不断增加,需要把追加到日志文件中的数据实时采集到hdfs中。 1.1.根据需求,首先定义一下3大要素: 采集源,即source—监控日志文件内容更新:exec ‘tail -F file’ 下沉目标,即sink—HDFS文件系统:hdfs sink Source和sink之间的传递通道—-channel,可用file channel也可以用 内存channel。 1.2.进入/home/tuzq/software/apache-flume-1.6.0-bin/agentconf,编写配置文件tail-hdfs.conf,文件内容如下: # Name the components on this agent a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source ## exec表示flume回去调用给的命令,然后从给的命令的结果中去拿数据 a1.sources.r1.type = exec ## 使用tail这个命令来读数据 a1.sources.r1.command = tail -F /home/tuzq/software/flumedata/test.log a1.sources.r1.channels = c1 # Describe the sink ## 表示下沉到hdfs,类型决定了下面的参数 a1.sinks.k1.type = hdfs ## sinks.k1只能连接一个channel,source可以配置多个 a1.sinks.k1.channel = c1 ## 下面的配置告诉用hdfs去写文件的时候写到什么位置,下面的表示不是写死的,而是可以动态的变化的。表示输出的目录名称是可变的 a1.sinks.k1.hdfs.path = /flume/tailout/%y-%m-%d/%H%M/ ##表示最后的文件的前缀 a1.sinks.k1.hdfs.filePrefix = events- ## 表示到了需要触发的时间时,是否要更新文件夹,true:表示要 a1.sinks.k1.hdfs.round = true ## 表示每隔1分钟改变一次 a1.sinks.k1.hdfs.roundValue = 1 ## 切换文件的时候的时间单位是分钟 a1.sinks.k1.hdfs.roundUnit = minute ## 表示只要过了3秒钟,就切换生成一个新的文件 a1.sinks.k1.hdfs.rollInterval = 3 ## 如果记录的文件大于20字节时切换一次 a1.sinks.k1.hdfs.rollSize = 20 ## 当写了5个事件时触发 a1.sinks.k1.hdfs.rollCount = 5 ## 收到了多少条消息往dfs中追加内容 a1.sinks.k1.hdfs.batchSize = 10 ## 使用本地时间戳 a1.sinks.k1.hdfs.useLocalTimeStamp = true #生成的文件类型,默认是Sequencefile,可用DataStream:为普通文本 a1.sinks.k1.hdfs.fileType = DataStream # Use a channel which buffers events in memory ##使用内存的方式 a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100 # Bind the source and sink to the channel a1.sources.r1.channels = c1 a1.sinks.k1.channel = c1 1.3.编写完成之后,启动flume,执行的命令是: [root@hadoop1 flumedata]#cd /home/tuzq/software/apache-flume-1.6.0-bin/agentconf [root@hadoop1 flumedata]#bin/flume-ng agent -c conf -f agentconf/tail-hdfs.conf -n a1 1.4.通过写一个死循环往test.log中写数据的方式模式日志文件增长 编写shell脚本,模拟日志增长变化。 [root@hadoop1 flumedata]# cd /home/tuzq/software/flumedata [root@hadoop1 flumedata]# while true >do > date >> test.log > sleep 2 > done 查看日志变化 [root@hadoop1 ~]# cd /home/tuzq/software/flumedata/ [root@hadoop1 flumedata]# ls access.log error.log test.log [root@hadoop1 flumedata]# tail -f test.log 2017年 06月 13日 星期二 22:02:22 CST 2017年 06月 13日 星期二 22:02:24 CST 2017年 06月 13日 星期二 22:02:26 CST 2017年 06月 13日 星期二 22:02:28 CST 2017年 06月 13日 星期二 22:02:30 CST 2017年 06月 13日 星期二 22:02:32 CST 通过上面的文件,可以看到test.log在不停的追加数据。 到hdfs中进行查看,效果如下: [root@hadoop1 ~]# hdfs dfs -ls / Found 5 items drwxr-xr-x - root supergroup 0 2017-06-13 12:01 /40000 drwxr-xr-x - root supergroup 0 2017-06-13 22:01 /flume -rw-r--r-- 3 root supergroup 3719 2017-06-10 12:11 /kms.sh drwxrwxrwx - root supergroup 0 2017-06-10 22:06 /tmp drwxr-xr-x - root supergroup 0 2017-06-10 22:27 /user [root@hadoop1 ~]# hdfs dfs -ls /flume Found 1 items drwxr-xr-x - root supergroup 0 2017-06-13 22:01 /flume/tailout [root@hadoop1 ~]# hdfs dfs -ls /flume/tailout Found 1 items drwxr-xr-x - root supergroup 0 2017-06-13 22:03 /flume/tailout/17-06-13 [root@hadoop1 ~]# hdfs dfs -ls /flume/tailout/17-06-13 Found 4 items drwxr-xr-x - root supergroup 0 2017-06-13 22:01 /flume/tailout/17-06-13/2201 drwxr-xr-x - root supergroup 0 2017-06-13 22:03 /flume/tailout/17-06-13/2202 drwxr-xr-x - root supergroup 0 2017-06-13 22:04 /flume/tailout/17-06-13/2203 drwxr-xr-x - root supergroup 0 2017-06-13 22:04 /flume/tailout/17-06-13/2204 [root@hadoop1 ~]# hdfs dfs -ls /flume/tailout/17-06-13 Found 5 items drwxr-xr-x - root supergroup 0 2017-06-13 22:01 /flume/tailout/17-06-13/2201 drwxr-xr-x - root supergroup 0 2017-06-13 22:03 /flume/tailout/17-06-13/2202 drwxr-xr-x - root supergroup 0 2017-06-13 22:04 /flume/tailout/17-06-13/2203 drwxr-xr-x - root supergroup 0 2017-06-13 22:05 /flume/tailout/17-06-13/2204 drwxr-xr-x - root supergroup 0 2017-06-13 22:05 /flume/tailout/17-06-13/2205 [root@hadoop1 /]# hdfs dfs -ls /flume/tailout/17-06-13 Found 6 items drwxr-xr-x - root supergroup 0 2017-06-13 22:01 /flume/tailout/17-06-13/2201 drwxr-xr-x - root supergroup 0 2017-06-13 22:03 /flume/tailout/17-06-13/2202 drwxr-xr-x - root supergroup 0 2017-06-13 22:04 /flume/tailout/17-06-13/2203 drwxr-xr-x - root supergroup 0 2017-06-13 22:05 /flume/tailout/17-06-13/2204 drwxr-xr-x - root supergroup 0 2017-06-13 22:06 /flume/tailout/17-06-13/2205 drwxr-xr-x - root supergroup 0 2017-06-13 22:06 /flume/tailout/17-06-13/2206 [root@hadoop1 /] 通过上面的案例可以知道,增加的日志文件已经被写入到HDFS中。 可供参考的文件:http://blog.csdn.net/tototuzuoquan/article/details/73194903

优秀的个人博客,低调大师

双11数据大屏背后:大规模流式增量计算及应用(附资料)

首先从理解什么是数据流开始今天的分享,其实在真实的世界中,大部分的数据都是连续产生的数据流,比如手机上产生的GPS信号、用户在互联网上的行为、在线搜索、用户的点击、社交网络分享、即时通信以及一些传感器和物联网设备采集的日志信息等,这些数据都是连续产生的,自然就形成了数据流,在这些数据流产生以后,在很多场景下对于数据流的实时分析就会产生很大的价值。 接下来从大家比较熟悉的数据场景切入,比如大家经常会关注的股市情况,股价的波动其实就是实时数据的分析和聚合,除此之外大家在日常生活中还可能比较关心天气预报,可能会根据实时的信息来看比如当前的台风的情况,这些都是大家习以为常的,也已经深入大家生活的实时数据分析。 而随着实时数据源的越来越多,实时数据的规模也越来越大,可以应用的场景也越来越多,实时数据的应用也正在往更多的领域深入。比如像每年的天猫

优秀的个人博客,低调大师

Centos7.0系统下Rsync+sersync实现多文件数据实时增量同步

前言: 一、为什么要用Rsync+sersync架构? 1、sersync是基于Inotify开发的,类似于Inotify-tools的工具 2、sersync可以记录下被监听目录中发生变化的(包括增加、删除、修改)具体某一个文件或某一个目录的名字,然后使用rsync同步的时候,只同步发生变化的这个文件或者这个目录。 二、Rsync+Inotify-tools与Rsync+sersync这两种架构有什么区别? 1、Rsync+Inotify-tools (1):Inotify-tools只能记录下被监听的目录发生了变化(包括增加、删除、修改),并没有把具体是哪个文件或者哪个目录发生了变化记录下来; (2):rsync在同步的时候,并不知道具体是哪个文件或者哪个目录发生了变化,每次都是对整个目录进行同步,当数据量很大时,整个目录同步非常耗时(rsync要对整个目录遍历查找对比文件),因此,效率很低。 2、Rsync+sersync (1):sersync可以记录下被监听目录中发生变化的(包括增加、删除、修改)具体某一个文件或某一个目录的名字; (2):rsync在同步的时候,只同步发生变化的这个文件或者这个目录(每次发生变化的数据相对整个同步目录数据来说是很小的,rsync在遍历查找比对文件时,速度很快),因此,效率很高。 小结:当同步的目录数据量不大时,建议使用Rsync+Inotify-tools;当数据量很大(几百G甚至1T以上)、文件很多时,建议使用Rsync+sersync。 环境说明: 操作系统:CentOS 7.0 源服务器:192.168.1.51 目标服务器:192.168.1.52 目的: 把源服务器上/data/p_w_picpath /data/pic两个目录 实时同步到目标服务器的data/p_w_picpath /data/pic下 具体操作: 一、目标服务器安装Rsync服务端 1、关闭SELINUX vi /etc/selinux/config SELINUX=disabled setenforce 0#立即生效 2. 配置防火墙IPTABLES [root@master2 ~]# vim /etc/sysconfig/iptables 增加规则:-A INPUT -p tcp -m state --state NEW -m tcp --dport 873 -j ACCEPT iptables -L -v -n 查看防火墙状态,873端口是否开放 3、检查是否安装rsync [root@master2 ~]# rpm -qa|grep rsyncrsync-3.0.9-15.el7.x86_64 4、配置rsync的配置文件 vim /etc/rsyncd.conf #Rsync configuration:uid = root gid = root use chroot = no port = 873 max connections = 2000 timeout = 200 log file = /var/run/rsyncd.log pid file = /var/run/rsyncd.pid lock file = /var/run/rsyncd.lock read only = false auth users = lyc secrets file = /etc/rsyncd.secret hosts allow = 192.168.1.0/255 hosts deny = 0.0.0.0/32 list = yesignore errors = yes[p_w_picpath] path = /data/p_w_picpath[pic]pate = /data/pic 注解#Rsync configuration:uid = root #设置rsync运行权限为rootgid = root #设置rsync运行权限为rootuse chroot = no # 安全相关,默认为true,修改为no,增加对目录文件软连接的备份port = 873 # 指定rsync服务的默认端口号max connections = 2000 # 并发连接数timeout = 200 # 超时时间(秒)log file = /var/run/rsyncd.log # 指定日志文件位置,启动rsync后自动产生这个文件,无需提前创建pid file = /var/run/rsyncd.pid # 指定rsync的pid目录lock file = /var/run/rsyncd.lock # 指定rsync的锁文件【重要】,支持max connections参数的锁文件read only = false # no客户端可上传文件,yes只读auth users = lyc #执行数据同步的用户名,可以设置多个,用英文状态下逗号隔开secrets file = /etc/rsyncd.secret #用户认证配置文件,里面保存用户名称和密码,后面会创建这个文件hosts allow = 192.168.1.0/255 #允许进行数据同步的客户端IP地址段,可以设置多个,用英文状态下逗>号隔开hosts deny = 0.0.0.0/32 #禁止数据同步的客户端IP地址,这里设置了不禁止list = yesignore errors = yes#################################################[p_w_picpath] # 模块path = /home/ces/ #rsync服务端数据目录路径 5、创建rsync同步密码文件,并设置权限为600 [root@master2 ~]# echo "lyc:test123" > /etc/rsyncd.secret[root@master2 ~]# chmod 600 /etc/rsyncd.secret[root@master2 ~]# ll //etc/rsyncd.secret-rw------- 1 root root 14 4月 18 09:25 //etc/rsyncd.secret[root@master2 ~]# cat /etc/rsyncd.secretlyc:test123 6.启动rsync守护进程,并写入开机自启动 [root@master2 ~]# rsync --daemon[root@master2 ~]# ps -ef | grep rsyncroot 1662 1 0 09:34 ? 00:00:00 rsync --daemonroot 6310 6068 0 17:02 pts/0 00:00:00 grep --color=auto rsync[root@master2 ~]# netstat -nulpt| grep rsynctcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 1662/rsync tcp6 0 0 :::873 :::* LISTEN 1662/rsync 设置开机自启动,写入到/etc/rc.local里面 vim /etc/rc.local # rsync server progress/usr/bin/rsync --daemon --config=/etc/rsyncd.conf 7.创建相关待同步的目录/home/ces/并授予权限 [root@master2 ~]# mkdir -p /data/p_w_picpath/data/pic[root@master2 ~]# chown -R root.root /data/p_w_picpath/data/pic 二、在源服务器安装配置Rsync服务端+配置sersync 1、按照上面步骤配置按照Rsync服务端,需要注意的是创建rsync同步密码文件,内容只需要填写密码:test123 [root@master1 ~]# echo "test123" > /etc/rsyncd.secret[root@master1 ~]# chmod 600 /etc/rsyncd.secret[root@master1 ~]# ll /etc/rsyncd.secret-rw------- 1 root root 14 4月 18 09:25 /etc/rsync.password[root@master1 ~]# cat /etc/rsyncd.secrettest123 2、手动测试rsync同步情况,此步非常关键,如果测试不成功,后面的sersync配好了也不会同步数据。 [root@master1 lyc]# rm -rf /test/[root@master1 lyc]# mkdir -p /test/[root@master1 lyc]# touch /test/lyc{1,2,3}{a,b,c}[root@master1 lyc]# ls /test/lyc1a lyc1b lyc1c lyc2a lyc2b lyc2c lyc3a lyc3b lyc3c[root@master1 lyc]# rsync -avzP /lyc/ lyc@192.168.1.52::rsync --password-file=/etc/rsyncd.secretsending incremental file list./lyca 0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=11/13)lycb 0 100% 0.00kB/s 0:00:00 (xfer#2, to-check=10/13)lycc 0 100% 0.00kB/s 0:00:00 (xfer#3, to-check=9/13)lycca 0 100% 0.00kB/s 0:00:00 (xfer#4, to-check=8/13)lyccb 0 100% 0.00kB/s 0:00:00 (xfer#5, to-check=7/13)lyccc 0 100% 0.00kB/s 0:00:00 (xfer#6, to-check=6/13)lycla 0 100% 0.00kB/s 0:00:00 (xfer#7, to-check=5/13)lyclb 0 100% 0.00kB/s 0:00:00 (xfer#8, to-check=4/13)lyclc 0 100% 0.00kB/s 0:00:00 (xfer#9, to-check=3/13)lycya 0 100% 0.00kB/s 0:00:00 (xfer#10, to-check=2/13)lycyb 0 100% 0.00kB/s 0:00:00 (xfer#11, to-check=1/13)lycyc 0 100% 0.00kB/s 0:00:00 (xfer#12, to-check=0/13)sent 550 bytes received 239 bytes 1578.00 bytes/sectotal size is 0 speedup is 0.00 3、在源服务器上执行推送命令后,在目的服务器上查看同步目录/home/ces中的内容,如果内容同步完成,进行sersync的配置;未完成,检查rsync配置及认证用户密码信息。 三、源服务器上开始部署sersync服务 1、下载sersync [root@master1 lyc]#wget -chttps://sersync.googlecode.com/files/sersync2.5.4_64bit_binary_stable_final.tar.gz[root@master1 lyc]#tar -zxf sersync2.5.4_64bit_binary_stable_final.tar.gz-C/usr/local/[root@master1 lyc]#mvGNU-Linux-x86/usr/local/sersync 由于谷歌的原因,不能成功下载的话,请手动下载上传到源服务器端 2、配置sersync [root@master1 local]#mkdir -p sersync/bin sersync/p_w_picpath sersync/pic[root@master1 local]#cp sersync/confxml.xmlsersync/p_w_picpath/[root@master1 local]#cp sersync/confxml.xmlsersync/pic[root@master1 local]#mv sersync/serynce2sersync/bin/ 3、修改配置文件p_w_picpath/confxml.xml、pic/confxml.xml [root@master1 local]#vimsersync/p_w_picpath/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/p_w_picpath"> <remote ip="192.168.1.52" name="p_w_picpath"/> <!--<remote ip="192.168.8.39" name="tongbu"/>--> <!--<remote ip="192.168.8.40" name="tongbu"/>--> </localpath> <rsync> <commonParams params="-artuz"/> <auth start="true" users="lyc" passwordfile="/etc/rsyncd.secret"/> <userDefinedPort start="true" port="873"/><!-- port=874 --> <timeout start="true" time="200"/><!-- 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/p_w_picpaths"/> </localpath> </plugin></head> [root@master1 local]#vimsersync/pic/confxml.xml <?xml version="1.0"encoding="ISO-8859-1"?><headversion="2.5"> <hosthostip="localhost"port="8008"></host> <debugstart="false"/> <fileSystemxfs="false"/> <filterstart="false"> <excludeexpression="(.*)\.svn"></exclude> <excludeexpression="(.*)\.gz"></exclude> <excludeexpression="^info/*"></exclude> <excludeexpression="^static/*"></exclude> </filter> <inotify> <deletestart="true"/> <createFolderstart="true"/> <createFilestart="false"/> <closeWritestart="true"/> <moveFromstart="true"/> <moveTostart="true"/> <attribstart="false"/> <modifystart="false"/> </inotify> <sersync> <localpathwatch="/data/pic"> <remoteip="192.168.1.52"name="pic"/> <!--<remote ip="192.168.8.39" name="tongbu"/>--> <!--<remote ip="192.168.8.40" name="tongbu"/>--> </localpath> <rsync> <commonParamsparams="-artuz"/> <authstart="true"users="lyc"passwordfile="/etc/rsyncd.secret"/> <userDefinedPortstart="true"port="873"/><!-- port=874 --> <timeoutstart="true"time="200"/><!-- timeout=100 --> <sshstart="false"/> </rsync> <failLogpath="/tmp/rsync_fail_log.sh"timeToExecute="60"/><!--default every 60mins execute once--> <crontabstart="false"schedule="600"><!--600mins--> <crontabfilterstart="false"> <excludeexpression="*.php"></exclude> <excludeexpression="info/*"></exclude> </crontabfilter> </crontab> <pluginstart="false"name="command"/> </sersync> <pluginname="command"> <paramprefix="/bin/sh"suffix=""ignoreError="true"/><!--prefix /opt/tongbu/mmm.sh suffix--> <filterstart="false"> <includeexpression="(.*)\.php"/> <includeexpression="(.*)\.sh"/> </filter> </plugin> <pluginname="socket"> <localpathwatch="/opt/tongbu"> <deshostip="192.168.138.20"port="8009"/> </localpath> </plugin> <pluginname="refreshCDN"> <localpathwatch="/data0/htdocs/cms.xoyo.com/site/"> <cdninfodomainname="ccms.chinacache.com"port="80"username="xxxx"passwd="xxxx"/> <sendurlbase="http://pic.xoyo.com/cms"/> <regexurlregex="false"match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/p_w_picpaths"/> </localpath> </plugin></head> 只需要修改以下配置:24行:<localpathwatch="/data/p_w_picpath"> #源服务器本地同步目录25行:<remoteip="192.168.1.52"name="p_w_picpath"/> #目的服务器同步目录31行:<authstart="true"users="lyc"passwordfile="/etc/rsyncd.secret"/> #指定rsync的用户和密码文件32行:<userDefinedPortstart="true"port="873"/><!-- port=874 --> #指定rsync的端口33行:<timeoutstart="true"time="200"/><!-- timeout=100 --> #超时时间(秒) 4、创建源服务器端同步目录 [root@master2 ~]# mkdir -p /data/p_w_picpath/data/pic[root@master2 ~]# chown -R root.root/data/p_w_picpath/data/pic 5、把sersync的执行脚本加入到PATH并启动sersync [root@master1 ces]#echo "export PATH=$PATH:/usr/local/sersync/bin/" >>/etc/profile[root@master1 ces]#source/etc/profile[root@master1 ces]#sersync2 -d -r -o /usr/local/sersync/p_w_picpath/confxml.xml[root@master1 ces]#sersync2 -d -r -o /usr/local/sersync/pic/confxml.xml 6、启动命令后返回结果如下为正常: set the system paramexecute:echo 50000000 > /proc/sys/fs/inotify/max_user_watchesexecute:echo 327679 > /proc/sys/fs/inotify/max_queued_eventsparse the command paramoption: -d run as a daemonoption: -r rsync all the local files to the remote servers before the sersync workoption: -o config xml name: /usr/local/sersync/confxml.xmldaemon thread num: 10parse xml config filehost ip : localhosthost port: 8008daemon start,sersync run behind the consoleuse rsync password-file :user islycpasswordfile is /etc/rsyncd.secretconfig xml parse successplease set /etc/rsyncd.conf max connections=0 Manuallysersync working thread 12 = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads)Max threads numbers is: 22 = 12(Thread pool nums) + 10(Sub threads)please according your cpu ,use -n param to adjust the cpu rate------------------------------------------rsync the directory recursivly to the remote servers onceworking please wait...execute command: cd /ces && rsync -artuz -R --delete ./ --port=873 --timeout=200 lyc@192.168.1.52::rsync --password-file=/etc/rsyncd.secret >/dev/null 2>&1run the sersync:watch path is: /data/p_w_picpath 7、设置开机启动sersync [root@master1]echo "sersync2 -r -d -o /usr/local/sersync/p_w_picpath/confxml.xml" >> /etc/rc.d/rc.local[root@master1]echo "sersync2 -r -d -o /usr/local/sersync/pic/confxml.xml" >> /etc/rc.d/rc.local 四、测试 1、源服务器端创建文件 [root@master1]# touch lyc.txt /data/p_w_picpath /data/pic[root@master1 /]# cd/data/p_w_picpath[root@master1 p_w_picpath]# lslyc.txt[root@master1 /]# cd/data/pic[root@master1 pic]# lslyc.txt 2、目的服务器端查看 [root@master2 /]# cd /data/p_w_picpath[root@master2 p_w_picpath]# lslyc.txt[root@master2 /]# cd/data/pic[root@master2 pic]# lslyc.txt 3、同步失败解决办法 目的服务器端执行命令 rsync --daemon 源服务器端执行命令 /usr/local/sersync/bin/sersync2 -d -r -o /usr/local/sersync/image/confxml.xml/usr/local/sersync/bin/sersync2 -d -r -o /usr/local/sersync/pic/confxml.xml

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册