2016-09-12 13:10:55 li740207611 阅读数 1088
  • 零基础Linux命令详细案例讲解课程(第1季)--重定向和...

    课程亮点: 笔记加案例详细讲解Linux知识!!!提供详细的笔记作为辅助工具,200多条笔记帮助学员快速掌握Linux150多个知识点 课程内容: * 第1章:Linux命令行概述:系统级别命令、文件和目录操作 * 第2章: 重定向:标准输入输出重定向到文件、管理、过滤器 * 第3章: echo命令:单个字符展开、特殊符号展开、集合展开、算术运算符展开、变量名展开、系统命令展开等 课程特色: * 笔记Linux命令:用200条笔记串连所有知识点,让学员从一点一滴积累,学习过程无压力 * 笔记标题采用关键字标识法,帮助学员更加容易记住知识点 * 笔记以超链接形式让知识点关联起来,形式知识体系 * 采用先概念后实例再应用方式,知识点深入浅出 * 提供授课内容笔记作为课后复习以及工作备查工具 部分图标(电脑PC端查看):

    148 人正在学习 去看看 翁老师

原文click here

过滤器是什么

过滤器就是从标准输入按行读取内容,并且把内容写到标准输出,这是最简单的过滤器
没有任何过滤功能的过滤器,当然了也有各种功能的过滤器在等着你哈。你想喝什么样
的水,就得用什么的源or过滤网,这个完全取决有你自己。

基本行过滤器

面向行的过滤器。

cat

cat [-nbs] file…
cat 可以把一个至多个文件连接在一起,然后输出到屏幕。
-n number 在每行输出添加行号
-b blank 和-n一起使用时,空白行不编号
-s squeeze 将多个空白行替换为一个

tac

tac 是 cat 的反向拼写,所以功能刚好是相反的,再把读到的内容写入到表准输出时
把行的顺序翻转过来,当然了也可以是多个文件,这个在看日志文件的时候很方便。
下面是t.txt 文件内容
hello word
you
are
me
cat t.txt
me
are
you
hello word

split

前面的tac cat 都可以把多个文件合并起来,同样的有程序可以把文件分割开来

根据行数,split 默认分割行数是1000 行
split [-d] [-a num] [-l lines] [file [prefix]]
-d 表示分割的文件名从0 开始编号 # 默认的文件名字是字母
-a 表示使用-d 数字的位数
-l 表示分割的行数
prefix 表示分割文件名字的前缀

rev

rev reverse 反转每一行字符的顺序,跟字符串反转是一样的,不过按行处理
head [-n lines ] 
head 从标准输入读取数据,输出数据的前 n 行默认显示前十行    

tail

tail [-n lines]
从标准输入读取数据,输出数据的后n 行,默认显示后十行

less

less files..
默认显示一个屏幕的数据。

列过滤器

colrm

colrm 速记 column remove 列删除
colrm [startcol [endcol]] startcol endcol 列的开始和结尾,列数从1开始
colrm 1 2 < t  # 删除第一列和第二列
llo word
u
e

cut

colrm 是从标准输入中删除选定的列,cut 是从标准输入中选择列作为标准输出
cut [-cd list] file…
-c (column 列)是跟colrm 一样按列选择 可以使用 “,” 组成list
-d (delimiter 分隔符) 根据特殊符号分割行,然后使用 -f (field 域)选择分割的列
cut -c 1-2,3-5 t
cut -f 1 -d “;” t

paste

colrm cut 都是对列进行选择,paste 刚好相反,paste是组合文件按照列
paste [-d delimiter] file...  #按照分隔符组合文件 

比较过滤器

cmp

cmp file1 file2
比较俩个文件按照字节,所以文件可以是二进制或者文本

comm

comm [-123] file1 file2
comm 比较俩个相似的文件,并且文件是有序的文件,输出分为三列,第一列显示只有第一个
文件所有的行,第二列显示第二个文件中有的行,第三列显示俩个文件中都有的行。
使用 -123 组合可以屏蔽,不想看到的列。
-1 不显示第一列

diff

diff [-iwbbc] file1 file2
不要求俩个文件是有序的还是无序的
-i 忽略大小写这个好像在很多地方都用到了
-w 忽略所有的空白符 ab, a b, 竟然是一样的太可怕了
-b 忽略空白符,不过是把多个空白符合并成一个
-b 忽略空白行,不过是把多个空白行合并成一个
-c 输出不同的时候,显示上下文比较容易理解
diff 的输出,刚开始真的很不熟悉不过因为按照行来的,其实如果你经常使用git 的话,你会
发现git 里面显示文件的差别用的应该就是diff因为我看输出的格式什么的都一样。

    diff t1 t2
    输出:
        1d0 #表示删除第一个文件第一行才和第二个文件一样 内容是 hello word
        < hello word
        4a4 # 表示第一个文件第四行需要append 追加一行 内容是li
        > li

统计

wc [-cllw] [ file…]
-c 统计字节
-l 统计行数
-w 统计单词
-l 显示文件中的最长行

排序

sort [-cu] [file]
-c check 检测数据是否是有序的
-u unique 只显示所有的行是唯一行,消除重复行

重复行

uniq 默认显示重复行中的一行,也可以只显示重复行,or 只显示唯一行,更可以统计重复次数
uniq [-cdu] [inffile [outfile]]
-c count 统计每行出现的次数,并且加上行的前面
-d repeated 输出重复的行
-u unique 只显示唯一行,不显示重复行

grep

http://blog.csdn.net/li740207611/article/details/50783367
可以看看这个

格式化文件

fold

fold 主要用来格式化文件,保证文档的长度不超过定义的长度,如果超过则在让超出部分换行
fold [-s] [-w width] file…
-s 不分割单词
-w width 行的长度按字符处理

fmt

fmt [-su] [-w width] [file..]
fmt 格式化段落,使每一行的长度跟规定的一样长,自动合并断行
-s 不合并短行
-u uniform spacing 统一空格,如果有多个空格只保留一个
-w 和fold 一样

2016-05-31 11:40:24 u011515165 阅读数 2380
  • 零基础Linux命令详细案例讲解课程(第1季)--重定向和...

    课程亮点: 笔记加案例详细讲解Linux知识!!!提供详细的笔记作为辅助工具,200多条笔记帮助学员快速掌握Linux150多个知识点 课程内容: * 第1章:Linux命令行概述:系统级别命令、文件和目录操作 * 第2章: 重定向:标准输入输出重定向到文件、管理、过滤器 * 第3章: echo命令:单个字符展开、特殊符号展开、集合展开、算术运算符展开、变量名展开、系统命令展开等 课程特色: * 笔记Linux命令:用200条笔记串连所有知识点,让学员从一点一滴积累,学习过程无压力 * 笔记标题采用关键字标识法,帮助学员更加容易记住知识点 * 笔记以超链接形式让知识点关联起来,形式知识体系 * 采用先概念后实例再应用方式,知识点深入浅出 * 提供授课内容笔记作为课后复习以及工作备查工具 部分图标(电脑PC端查看):

    148 人正在学习 去看看 翁老师

linux下过滤线上日志

我们在进行web开发的时候,经常要查找线上问题,查找线上问题,大多用日志来看,像log4j的日志,但日志太多,如果只输入错误日志,又不好查找问题,我们要用到linux下过滤日志,过滤我们用个人grep命令其中参数为 -E可以支持多条件检索,条件与条件之间用|分割,不多说,我们看命令和效果

grep -E 'at |Execption|exception|Caused by' test.log

查看部分效果

i.log.7:Caused by: org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
api.log.7:      at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:162)
api.log.7:      at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:251)
api.log.7:      at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:58)
api.log.7:      at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:128)
api.log.7:      at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:91)
api.log.7:      at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:78)
api.log.7:      at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:178)
api.log.7:      at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:153)
api.log.7:      at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:86)
api.log.7:      at org.springframework.data.redis.core.DefaultValueOperations.get(DefaultValueOperations.java:43)
api.log.7:      at com.wedo.server.api.cache.TokenCache.getUserId(TokenCache.java:38)
api.log.7:      at com.wedo.server.api.cache.TokenCache.isTokenExpired(TokenCache.java:29)
api.log.7:      at com.wedo.server.api.rest.filter.SecurityRequestFilter.filter(SecurityRequestFilter.java:58)
api.log.7:      at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:264)
api.log.7:      at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250)
api.log.7:      at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237)
api.log.7:      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356)
api.log.7:Caused by: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
api.log.7:      at redis.clients.util.Pool.getResource(Pool.java:50)
api.log.7:      at redis.clients.jedis.JedisPool.getResource(JedisPool.java:88)
api.log.7:      at redis.clients.jedis.JedisPool.getResource(JedisPool.java:12)
api.log.7:      at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:155)
api.log.7:Caused by: java.util.NoSuchElementException: Unable to validate object
api.log.7:      at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:502)
api.log.7:      at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:361)
api.log.7:      at redis.clients.util.Pool.getResource(Pool.java:48)
api.log.7:org.jboss.resteasy.spi.UnhandledException: org.springframework.orm.jpa.JpaSystemException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException
api.log.7:Query: ReportQuery(referenceClass=So2oAddressNavi sql="SELECT ID AS a1, ADDRESS AS a2, LATITUDE AS a3, LEVEL AS a4, LFT AS a5, LONGITUDE AS a6, NAME AS a7, parent_id AS a8, RGHT AS a9, tree_id AS a10, region_id AS a11, (((LONGITUDE - ?) * (LONGITUDE - ?)) + ((LATITUDE - ?) * (LATITUDE - ?))) FROM so2o_addressnavi WHERE (parent_id IS NULL) ORDER BY (((LONGITUDE - ?) * (LONGITUDE - ?)) + ((LATITUDE - ?) * (LATITUDE - ?))) LIMIT ?, ?"); nested exception is javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException
api.log.7:      at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76)
api.log.7:      at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212)
api.log.7:      at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149)
api.log.7:      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372)
api.log.7:      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)
api.log.7:      at org.jboss.resteasy.plugins.server.netty.RequestDispatcher.service(RequestDispatcher.java:83)
api.log.7:      at org.jboss.resteasy.plugins.server.netty.RequestHandler.messageReceived(RequestHandler.java:56)
api.log.7:      at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
api.log.7:      at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
api.log.7:      at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
api.log.7:      at org.jboss.netty.handler.execution.ChannelUpstreamEventRunnable.doRun(ChannelUpstreamEventRunnable.java:43)
api.log.7:      at org.jboss.netty.handler.execution.ChannelEventRunnable.run(ChannelEventRunnable.java:67)
api.log.7:      at org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor$ChildExecutor.run(OrderedMemoryAwareThreadPoolExecutor.java:314)
api.log.7:      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
api.log.7:      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
api.log.7:      at java.lang.Thread.run(Thread.java:745)
api.log.7:Caused by: org.springframework.orm.jpa.JpaSystemException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException
api.log.7:Query: ReportQuery(referenceClass=So2oAddressNavi sql="SELECT ID AS a1, ADDRESS AS a2, LATITUDE AS a3, LEVEL AS a4, LFT AS a5, LONGITUDE AS a6, NAME AS a7, parent_id AS a8, RGHT AS a9, tree_id AS a10, region_id AS a11, (((LONGITUDE - ?) * (LONGITUDE - ?)) + ((LATITUDE - ?) * (LATITUDE - ?))) FROM so2o_addressnavi WHERE (parent_id IS NULL) ORDER BY (((LONGITUDE - ?) * (LONGITUDE - ?)) + ((LATITUDE - ?) * (LATITUDE - ?))) LIMIT ?, ?"); nested exception is javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException
api.log.7:      at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:415)
api.log.7:      at org.springframework.orm.jpa.DefaultJpaDialect.translateExceptionIfPossible(DefaultJpaDialect.java:122)
api.log.7:      at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:417)
api.log.7:      at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
api.log.7:      at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
api.log.7:      at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
api.log.7:      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
api.log.7:      at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodIntercceptor.invoke(CrudMethodMetadataPostProcessor.java:122)
api.log.7:      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
api.log.7:      at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
api.log.7:      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
api.log.7:      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
api.log.7:      at com.sun.proxy.$Proxy70.findSo2oAddressNavi(Unknown Source)
api.log.7:      at com.wedo.server.api.service.CommonService.getAroundDistricts(CommonService.java:1074)
api.log.7:      at com.wedo.server.api.rest.Api.getAroundDistricts(Api.java:1639)
api.log.7:      at sun.reflect.GeneratedMethodAccessor524.invoke(Unknown Source)
api.log.7:      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
api.log.7:      at java.lang.reflect.Method.invoke(Method.java:497)
api.log.7:      at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137)
api.log.7:      at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296)
api.log.7:      at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250)
api.log.7:      at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237)
api.log.7:      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356)
api.log.7:Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException
api.log.7:      at org.eclipse.persistence.internal.jpa.QueryImpl.getDetailedException(QueryImpl.java:382)
api.log.7:      at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:260)
api.log.7:      at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:473)
api.log.7:      at sun.reflect.GeneratedMethodAccessor159.invoke(Unknown Source)
api.log.7:      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
api.log.7:      at java.lang.reflect.Method.invoke(Method.java:497)
api.log.7:      at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:362)
api.log.7:      at com.sun.proxy.$Proxy133.getResultList(Unknown Source)
api.log.7:      at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:113)
api.log.7:      at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:77)
api.log.7:      at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:100)
api.log.7:      at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:91)
api.log.7:      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:393)
api.log.7:      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:371)
api.log.7:      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
api.log.7:      at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
api.log.7:      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
api.log.7:      at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
api.log.7:      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
api.log.7:      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
api.log.7:      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
api.log.7:      at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
api.log.7:Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException
api.log.7:      at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
api.log.7:      at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:684)
api.log.7:      at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:560)
api.log.7:      at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2055)
api.log.7:      at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:570)
api.log.7:      at org.eclipse.persistence.sessions.server.ClientSession.executeCall(ClientSession.java:258)
api.log.7:      at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:242)
api.log.7:      at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
api.log.7:      at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:299)
api.log.7:      at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:694)
api.log.7:      at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2740)
api.log.7:      at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllReportQueryRows(ExpressionQueryMechanism.java:2677)
api.log.7:      at org.eclipse.persistence.queries.ReportQuery.executeDatabaseQuery(ReportQuery.java:852)
api.log.7:      at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:904)
api.log.7:      at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1132)
api.log.7:      at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:442)
api.log.7:      at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1220)
api.log.7:      at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
api.log.7:      at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1857)
api.log.7:      at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1839)
api.log.7:      at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1804)
api.log.7:      at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
api.log.7:Caused by: java.sql.SQLException: Error writing file '/var/tmp/MYwIfnD2' (Errcode: 28)
api.log.7:      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996)
api.log.7:      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3887)
api.log.7:      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3823)
api.log.7:      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2435)
api.log.7:      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582)
api.log.7:      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2530)
api.log.7:      at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1907)
api.log.7:      at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2030)
api.log.7:      at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:1009)
api.log.7:      at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:644)
api.log.7:      at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76)
api.log.7:      at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212)
api.log.7:      at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149)
api.log.7:      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372)
api.log.7:      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)
api.log.7:      at org.jboss.resteasy.plugins.server.netty.RequestDispatcher.service(RequestDispatcher.java:83)
api.log.7:      at org.jboss.resteasy.plugins.server.netty.RequestHandler.messageReceived(RequestHandler.java:56)
api.log.7:      at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
api.log.7:      at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
api.log.7:      at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
api.log.7:      at org.jboss.netty.handler.execution.ChannelUpstreamEventRunnable.doRun(ChannelUpstreamEventRunnable.java:43)
api.log.7:      at org.jboss.netty.handler.execution.ChannelEventRunnable.run(ChannelEventRunnable.java:67)
api.log.7:      at org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor$ChildExecutor.run(OrderedMemoryAwareThreadPoolExecutor.java:314)
api.log.7:      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
api.log.7:      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
api.log.7:      at java.lang.Thread.run(Thread.java:745)
api.log.7:Caused by: [orders_index] IndexNotFoundException[no such index]
api.log.7:      at org.elasticsearch.cluster.metadata.IndexNameExpressionResolver$WildcardExpressionResolver.resolve(IndexNameExpressionResolver.java:586)
api.log.7:      at org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.concreteIndices(IndexNameExpressionResolver.java:133)
api.log.7:      at org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.concreteIndices(IndexNameExpressionResolver.java:113)
api.log.7:      at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.<init>(TransportSearchTypeAction.java:121)
api.log.7:      at org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.<init>(TransportSearchDfsQueryThenFetchAction.java:78)
api.log.7:      at org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.<init>(TransportSearchDfsQueryThenFetchAction.java:71)
api.log.7:      at org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction.doExecute(TransportSearchDfsQueryThenFetchAction.java:68)
api.log.7:      at org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction.doExecute(TransportSearchDfsQueryThenFetchAction.java:57)
api.log.7:      at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:70)
api.log.7:      at org.elasticsearch.action.search.TransportSearchAction.doExecute(TransportSearchAction.java:97)
api.log.7:      at org.elasticsearch.action.search.TransportSearchAction.doExecute(TransportSearchAction.java:44)
api.log.7:      at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:70)
api.log.7:      at org.elasticsearch.action.support.HandledTransportAction$TransportHandler.messageReceived(HandledTransportAction.java:45)
api.log.7:      at org.elasticsearch.action.support.HandledTransportAction$TransportHandler.messageReceived(HandledTransportAction.java:41)
api.log.7:      at org.elasticsearch.transport.netty.MessageChannelHandler.handleRequest(MessageChannelHandler.java:244)
api.log.7:      at org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:114)
api.log.7:      at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
api.log.7:      at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
api.log.7:      at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
api.log.7:      at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
api.log.7:      at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462)
api.log.7:      at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443)
api.log.7:      at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)
api.log.7:      at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
api.log.7:      at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
api.log.7:      at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
api.log.7:      at org.elasticsearch.common.netty.OpenChannelsHandler.handleUpstream(OpenChannelsHandler.java:75)
api.log.7:      at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
api.log.7:      at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
api.log.7:      at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
api.log.7:      at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
api.log.7:      at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
api.log.7:      at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
api.log.7:      at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
api.log.7:      at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
api.log.7:      at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
api.log.7:      at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
api.log.7:      at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
api.log.7:      at org.jboss.resteasy.core.registry.ClassNode.match(ClassNode.java:73)
api.log.7:      at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
api.log.7:      at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:444)
api.log.7:      at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:234)
api.log.7:      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:171)
api.log.7:      at org.jboss.resteasy.plugins.server.netty.RequestDispatcher.service(RequestDispatcher.java:83)
api.log.7:      at org.jboss.resteasy.plugins.server.netty.RequestHandler.messageReceived(RequestHandler.java:56)
api.log.7:      at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
api.log.7:      at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
api.log.7:      at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
api.log.7:      at org.jboss.netty.handler.execution.ChannelUpstreamEventRunnable.doRun(ChannelUpstreamEventRunnable.java:43)
api.log.7:      at org.jboss.netty.handler.execution.ChannelEventRunnable.run(ChannelEventRunnable.java:67)
api.log.7:      at org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor$ChildExecutor.run(OrderedMemoryAwareThreadPoolExecutor.java:314)
api.log.7:      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
api.log.7:      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
api.log.7:      at java.lang.Thread.run(Thread.java:745)
api.log.7:      at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:375)
api.log.7:      at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:114)
api.log.7:      at org.jboss.resteasy.core.registry.RootNode.match(RootNode.java:43)
api.log.7:      at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
api.log.7:      at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:444)
api.log.7:      at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:234)
api.log.7:      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:171)
api.log.7:      at org.jboss.resteasy.plugins.server.netty.RequestDispatcher.service(RequestDispatcher.java:83)
api.log.7:      at org.jboss.resteasy.plugins.server.netty.RequestHandler.messageReceived(RequestHandler.java:56)
api.log.7:      at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
api.log.7:      at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
api.log.7:      at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
api.log.7:      at org.jboss.netty.handler.execution.ChannelUpstreamEventRunnable.doRun(ChannelUpstreamEventRunnable.java:43)
api.log.7:      at org.jboss.netty.handler.execution.ChannelEventRunnable.run(ChannelEventRunnable.java:67)
api.log.7:      at org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor$ChildExecutor.run(OrderedMemoryAwareThreadPoolExecutor.java:314)
api.log.7:      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
api.log.7:      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
api.log.7:      at java.lang.Thread.run(Thread.java:745)
                                                -----一个欢乐的程序猿
2019-09-23 17:19:46 CaptianG 阅读数 165
  • 零基础Linux命令详细案例讲解课程(第1季)--重定向和...

    课程亮点: 笔记加案例详细讲解Linux知识!!!提供详细的笔记作为辅助工具,200多条笔记帮助学员快速掌握Linux150多个知识点 课程内容: * 第1章:Linux命令行概述:系统级别命令、文件和目录操作 * 第2章: 重定向:标准输入输出重定向到文件、管理、过滤器 * 第3章: echo命令:单个字符展开、特殊符号展开、集合展开、算术运算符展开、变量名展开、系统命令展开等 课程特色: * 笔记Linux命令:用200条笔记串连所有知识点,让学员从一点一滴积累,学习过程无压力 * 笔记标题采用关键字标识法,帮助学员更加容易记住知识点 * 笔记以超链接形式让知识点关联起来,形式知识体系 * 采用先概念后实例再应用方式,知识点深入浅出 * 提供授课内容笔记作为课后复习以及工作备查工具 部分图标(电脑PC端查看):

    148 人正在学习 去看看 翁老师

Linux包过滤防火墙

Netfilter
位于linux内核中的包过滤功能体系
称为linux防火墙的“内核态”
Iptables
位于/sbin/iptables,用来管理防火墙规则的工具
称为linux防火墙的“用户态”
包过滤的工作层次
主要是网络层,针对IP数据包
体现在针对包内的IP地址,端口等信息的处理上
在这里插入图片描述
Iptables的表,链结构
规则链
规则的作用:对数据包进行过滤或处理
链的作用:容纳各种防火墙规则
链的分类依据:处理数据包的不同时机
默认包括5种规则链
INPUT:处理入站数据包
OUTPUT:处理出站数据包
FORWARD:处理转发数据包
POSTROUTING链:在进行路由选择后处理数据包
PREROUTING链:在进行路由选择前处理数据包
规则表
表的作用:容纳各种规则链
标的划分依据:防火墙规则的作用相似
默认包括4个规则表
Raw表:确定是否对该数据包进行状态跟踪
Mangle表:为数据包中的源,目标IP地址或端口
Nat表:修改数据包中的源,目标ip地址或端口
Filter表:确定是否放行该数据包
默认的表,链结构示意图
在这里插入图片描述
数据包过滤的匹配流程
规则表之间的顺序:raw—mangle—nat—filter
规则链之间的顺序
入站:PREROUTING—INPUT
出站:OUTPUT—POSTROUTING
转发:PREROUTING—FROWARD----POSTROUTING
规则链内的匹配顺序
按顺序依次检查,匹配即停止
若找不到相匹配的规则,则按该链的默认策略处理
数据包过滤的匹配流
在这里插入图片描述
Iptables的基本语法
语法构成:iptables [-t 表名] 选项 链名 条件 -j 控制类型
注意事项:
1.不指定表名时,默认指filter表
2.不指定链名时,默认指表内的所有链
3.除非设置链的默认策略,否则必须指定匹配条件
4.选项名,链名,控制类型使用大写字母,其余均为小写
控制类型:
ACCEPT:允许通过
DROP:不回应任何
REJECT:拒绝回应ICMP请求
LOG:记录日志信息,然后传给下一条规则链继续匹配,不对数据包进行控制。
选项名:
-A:在链的末尾追加一条规则
-I:在链的开头或指定序列号插入一条规则
查看规则列表
-L列出所有的规则条目
-n 以数字形式显示地址,端口等信息
-v 以更详细的方式显示规则信息
–line-numbers 查看规则时,显示规则的序列号
删除,清空规则
-D 删除链内的指定序列号的一条规则
iptables -D INPUT 10
-F 清空所有规则
iptables -F
设置默认策略
-P 为指定的链设置默认规则
iptables -t filter -P INPUT DROP
默认策略分两种 ACCEPT,DROP
规则的匹配条件:
通用匹配:
可直接使用,不依赖于其他条件或扩展
包括网络协议,IP地址,网络接口
协议匹配: -p 协议名
地址匹配: -s 源地址 -d 目的地址
接口匹配: -i 入站网卡 -o 出站网卡
iptables -I INPUT ! -p icmp j ACCEPT
!表示取反
iptables -A INPUT -s 192.168.8.252 -p icmp -j ACCEPT
iptables -A INPUT -s 192.168.8.0/24 -p icmp -j ACCEPT
iptables -I INPUT -i eth0 -p icmp -j DROP
隐含匹配:
要求以特定的协议匹配作为前提
包括:端口,TCP标记,ICMP类型
端口匹配:–sport 源端口 --dport 目的端口
TCP标记匹配:–tcp-flags 检查范围,被设置的标记
ICMP类型匹配:–icmp-type ICMP类型
iptables -I INPUT -s 192.168.8.252 -p tcp --dport 22 -j ACCEPT
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
–icmp-type: 8 icmp请求 0 icmp回显 3 不可达
显式匹配:
要求以 -m扩展模块 的形式明确指出类型
包括多端口,MAC地址,IP范围,数据包状态等条件
多端口匹配:-m multiport -sport/-dport
iptables -I INPUT -m multiport -p tcp --dports 80,443 -j REJECT
ip范围:-m IPrange --src-range
MAC范围:-m mac --mac-source mac地址
iptables -I INPUT -m mac --mac-source D8-9D-67-99-B2-E2 -p icmp -j DROP
状态匹配:-m state --state 连接状态
iptables -I INPUT -p tcp -m state --state
ESTABLISHED -j ACCEPT
保存防火墙规则
service iptables save在这里插入图片描述
常见匹配条件总汇
在这里插入图片描述

2018-11-22 15:50:20 pushilong 阅读数 90
  • 零基础Linux命令详细案例讲解课程(第1季)--重定向和...

    课程亮点: 笔记加案例详细讲解Linux知识!!!提供详细的笔记作为辅助工具,200多条笔记帮助学员快速掌握Linux150多个知识点 课程内容: * 第1章:Linux命令行概述:系统级别命令、文件和目录操作 * 第2章: 重定向:标准输入输出重定向到文件、管理、过滤器 * 第3章: echo命令:单个字符展开、特殊符号展开、集合展开、算术运算符展开、变量名展开、系统命令展开等 课程特色: * 笔记Linux命令:用200条笔记串连所有知识点,让学员从一点一滴积累,学习过程无压力 * 笔记标题采用关键字标识法,帮助学员更加容易记住知识点 * 笔记以超链接形式让知识点关联起来,形式知识体系 * 采用先概念后实例再应用方式,知识点深入浅出 * 提供授课内容笔记作为课后复习以及工作备查工具 部分图标(电脑PC端查看):

    148 人正在学习 去看看 翁老师

基于linux内核包过滤技术的应用网关

硬件形态

全千兆多WLAN核心路由器

基本原理

基本原理

应用场景

媒体内容过滤和深度识别
上网行为管理
应用网关或防火墙

主要功能

包括但不限于如下功能:

功能名称 说明
协议过滤 常用协议、用户自定义协议
端口过滤 传输层 源端口、目的端口
地址过滤 网络层 源地址、目的地址
文件识别 FTP/SBM文件上下载时文件类型识别,媒体文件检测,媒体文件分析,媒体文件格式过滤等,文件流量限制
网卡隔离 网卡间隔离
热备功能 支持单机、主备机工作模式,支持热备份

其他功能

基于此又如上网行为管理系统,能够分析常见的qq,邮件,http等内容,并可对文件内容,流媒体内容进行深度分析和识别。

客户定制

支持客户需求定制和客户个性化配置页面开发等。

没有更多推荐了,返回首页