一般在 Linux 环境中,常需要分析Log文件,来判断问题来源及解决问题的思路,怎样快速从繁多的Log里找到有用信息呢?
下面分享一下我的做法:
[oracle@c7m1 ~]$ cat -n alert_c7m1.log |grep FAST_START_MTTR_TARGET
433 MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
742 MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
.....
说明:
cat [参数] [目录及文件名] [条件]
-n 参数,代表显示行号, 无此参,默认隐藏
|grep 查询关键字,后跟查询字符型条件,如有空格或特殊字符,使用 "" 标识
[oracle@c7m1 ~]$ sed -n 400,741p alert_c7m1.log>tmp.log
说明:
sed -n [起始行号,结尾行号]+p [文件] > [输出到临时文件]
[起始行号,结尾行号]+p 一般评估查找的标志信息出现行号前后的完整性,可前推后延, 结尾行号后加 p
[oracle@c7m1 ~]$ cat tmp.log
Errors in file /home/oracle/diag/rdbms/c7m1/c7m1/trace/c7m1_ora_20296.trc:
....
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
....