首页 文章 精选 留言 我的

精选列表

搜索[抓包过滤],共10000篇文章
优秀的个人博客,低调大师

ELK菜鸟手记 (二) - 高级配置之多应用索引过滤

我们在实际的场景中,经常是多个网站或者服务端在一台服务器上,但是如果这些应用全部 记录到一台logstash服务器,大家日志都混在一起不好区分。 有人说,我可以在日志中打项目名,但是这样并不方便。 其实,我们可以在索引上做文章。 配置如下: input { file { path => ["/Users/KG/Documents/logs/app-a/*.log"] type => "app-a" } file { path => ["/Users/KG/Documents/logs/app-b/*.log"] type => "app-b" } } output { stdout { codec => rubydebug } if [type] == "app-a" { elasticsearch { hosts => "你的elastic服务器地址:9200" index => "app-a-%{+YYYY.MM.dd}" document_type => "log4j_type" } } else if [type] == "app-b" { elasticsearch { hosts => "你的elastic服务器地址:9200" index => "app-b-%{+YYYY.MM.dd}" document_type => "log4j_type" } } } 从上面的代码可以看出,我们配置了2个索引app-a表示应用A, 而app-b表示应用B。 我们利用了type和path属性,然后对不同路径的日志进行监控,将输入定向到不同的索引。

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

MapReduce实现协同过滤中每个用户看过的项目集合

一、知识准备 hadoop自带的例子在 D:\HADOOP_HOME\hadoop-2.6.4\share\hadoop\mapreduce\sources\hadoop-mapreduce-examples 2.6.0-source.jar 我记得当年面试的时候就问中位数的问题不过是数据流下的中位数,一问便知是否搞过hadoop。 二、代码实现 2.1 Mapper package cf; import java.io.IOException; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Mapper; public class MovieMapper1 extends Mapper<LongWritable, Text, Text, Text> { public void map(LongWritable ikey, Text ivalue, Context context) throws IOException, InterruptedException { String[] values = ivalue.toString().split(","); if (values.length!=2) { return ; } String userID = values[0]; String itemID = values[1]; context.write(new Text(userID), new Text(itemID)); } } 2.2 Reducer package cf; import java.io.IOException; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Reducer; public class MovieReduce1 extends Reducer<Text, Text, Text, Text> { public void reduce(Text _key, Iterable<Text> values, Context context) throws IOException, InterruptedException { // process values StringBuffer sb = new StringBuffer(); for (Text val : values) { sb.append(val.toString()); sb.append(","); } //value不能直接用StringBuffer 必须转换为String context.write(_key,new Text(sb.toString())); } } 2.3 Main package cf; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; public class UserItemSetMapReduce { public static void main(String[] args) throws Exception{ Configuration conf = new Configuration(); Job job = new Job(conf, "CFItemSet"); job.setJarByClass(UserItemSetMapReduce.class); job.setMapperClass(MovieMapper1.class); //job.setCombinerClass(cls); // job.setCombinerClass(MovieReduce1.class); job.setReducerClass(MovieReduce1.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(Text.class); FileInputFormat.addInputPath(job,new Path("hdfs://192.168.58.180:8020/cf/userItem.txt")); //InputPath(job, new Path(otherArgs[0])); //直接写到cf会提示已存在cf,我写成uIO.ttx,以为内容会写入到txt,然没有,默认他是文件夹 FileOutputFormat.setOutputPath(job,new Path("hdfs://192.168.58.180:8020/cf/userItemOut.txt")); System.exit(job.waitForCompletion(true) ? 0 : 1); } } 三、结果分析 3.1 输入 3.2 输出 查看结果发现输出文件的分隔符默认是tab,‘\t’,同时相对于输入文件来说输出结果是逆着的,类似沾,莫非context就是这样的先进后出、 3.3日志分析 只列出了主要部分的日志 DEBUG - PrivilegedAction as:hxsyl (auth:SIMPLE) from:org.apache.hadoop.mapreduce.Job.getCounters(Job.java:765) INFO - Counters: 38 File System Counters FILE: Number of bytes read=538 FILE: Number of bytes written=509366 FILE: Number of read operations=0 FILE: Number of large read operations=0 FILE: Number of write operations=0 HDFS: Number of bytes read=106 HDFS: Number of bytes written=37 HDFS: Number of read operations=13 HDFS: Number of large read operations=0 HDFS: Number of write operations=4 Map-Reduce Framework Map input records=11 Map output records=11 Map output bytes=44 Map output materialized bytes=72 Input split bytes=107 Combine input records=0 Combine output records=0 Reduce input groups=5 Reduce shuffle bytes=72 Reduce input records=11 Reduce output records=5 Spilled Records=22 Shuffled Maps =1 Failed Shuffles=0 Merged Map outputs=1 GC time elapsed (ms)=3 CPU time spent (ms)=0 Physical memory (bytes) snapshot=0 Virtual memory (bytes) snapshot=0 Total committed heap usage (bytes)=462422016 Shuffle Errors BAD_ID=0 CONNECTION=0 IO_ERROR=0 WRONG_LENGTH=0 WRONG_MAP=0 WRONG_REDUCE=0 File Input Format Counters Bytes Read=53 File Output Format Counters Bytes Written=37 DEBUG - PrivilegedAction as:hxsyl (auth:SIMPLE) from:org.apache.hadoop.mapreduce.Job.updateStatus(Job.java:323) DEBUG - stopping client from cache: org.apache.hadoop.ipc.Client@37afeb11 DEBUG - removing client from cache: org.apache.hadoop.ipc.Client@37afeb11 DEBUG - stopping actual client because no more references remain: org.apache.hadoop.ipc.Client@37afeb11 DEBUG - Stopping client DEBUG - IPC Client (521081105) connection to /192.168.58.180:8020 from hxsyl: closed DEBUG - IPC Client (521081105) connection to /192.168.58.180:8020 from hxsyl: stopped, remaining connections 0 大神分析一下如何执行的,看着日志....Map如何输入的,执行几次等。

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

build: SraAdmin 依赖包升级

更新的框架版本有如下,后续依赖基本上没有太大变动了,依赖项基本保持稳定: Spring Boot:从 3.5.3 升级至 3.5.8 Solon:从 3.4.0 升级至 3.5.9 Sqltoy:从 5.6.50 升级至 5.6.52 Sa-Token:从 1.43.0 升级至 1.44.0 Fastjson2:从 2.0.57 升级至 2.0.59 Hutool:从 5.8.39 升级至 5.8.41 相关项目链接: 基于Spring Boot:https://github.com/CoCoTeaNet/sra-admin 基于Solon:https://github.com/CoCoTeaNet/sra-admin-solon 前端工程:https://github.com/CoCoTeaNet/sra-admin-vue

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

springboot打包成war包

pom.xml中 war <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.4.2</version> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> 添加依赖,打包时检查这两个依赖是否存在,不存在的话添加一下 <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> 启动类 @EnableTransactionManagement@ServletComponentScan@SpringBootApplicationpublic class SyscloudApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(SyscloudApplication.class); } public static void main(String[] args) { SpringApplication.run(SyscloudApplication.class, args); } }然后开始打包,修改后由于没有去掉自带的tomcat,所以项目可以正常通过springboot启动 要去掉tomcat时,将pom.xml文件中的web依赖改为: <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <!-- 移除嵌入式tomcat插件 --> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions>

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

Android 日志工具包

1). 实现效果图 效果图.png 2). 实现思路 绘制边框 打印线程名称 打印堆栈信息 打印消息体 3). 边框绘制 边框实际上也是以字符串的形式打印 4). 打印线程信息 Log.println(priority, mTag, HORIZONTAL_LINE + "Thread: " + Thread.currentThread().getName()); 5). 打印堆栈信息 builder.append(HORIZONTAL_LINE).append("").append(level).append(element.getClassName().substring(element.getClassName().lastIndexOf(".") + 1)) .append(".").append(element.getMethodName()).append(" ").append(" (").append(element.getFileName()) .append(":").append(element.getLineNumber()).append(")"); 6). 打印消息体 // 获取消息总长度 int tLen = msg.length(); // 获取消息长度打印长度的倍数 int multiple = tLen / LENGTH + 1; // 创建临时变量 String tmp; // 遍历倍数 for (int i = 0; i < multiple; i++) { // 获取字符内容 if (i != multiple - 1) { // 获取指定范围的数据 tmp = msg.substring(i * LENGTH, (i + 1) * LENGTH); } else { // 最后一段数据 tmp = msg.substring(i * LENGTH); } // 打印消息 Log.println(priority, mTag, HORIZONTAL_LINE + tmp); } 7). 代码下载 8). Gradle依赖 compile 'com.mazaiting:log:1.0.0'

资源下载

更多资源
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等操作系统。

用户登录
用户注册