如何才能轻松地分析日志?

1、分割文件

[app@127-0-0-1 ~]# split -b 2m dump.rdb dump_
[app@127-0-0-1 ~]# ll
 total 19824
 -rw-r--r-- 1 root root  2097152 Jul 23 10:05 dump_aa
 -rw-r--r-- 1 root root  2097152 Jul 23 10:05 dump_ab
 -rw-r--r-- 1 root root  2097152 Jul 23 10:05 dump_ac
 -rw-r--r-- 1 root root  2097152 Jul 23 10:05 dump_ad
 -rw-r--r-- 1 root root  1758720 Jul 23 10:05 dump_ae
 -rw-r--r-- 1 root root 10147328 Jul 23 09:51 dump.rdb
[app@127-0-0-1 ~]# 

   计算:2097152 = 2*1024*1024 = 2m   默认命名 :aa ab ac ad ae 

2、合并文件

[app@127-0-0-1 ~]# cat dump_a* > redis_file
[app@127-0-0-1 ~]# ll
 total 29736
 -rw-r--r-- 1 root root  2097152 Jul 23 10:12 dump_aa
 -rw-r--r-- 1 root root  2097152 Jul 23 10:12 dump_ab
 -rw-r--r-- 1 root root  2097152 Jul 23 10:12 dump_ac
 -rw-r--r-- 1 root root  2097152 Jul 23 10:12 dump_ad
 -rw-r--r-- 1 root root  1758720 Jul 23 10:12 dump_ae
 -rw-r--r-- 1 root root 10147328 Jul 23 09:51 dump.rdb
 -rw-r--r-- 1 root root 10147328 Jul 23 14:01 redis_file
[app@127-0-0-1 ~]# 

   默认追加:aa  ab  ac  ad  ae

3、验证文件

[app@127-0-0-1 ~]# vimdiff  dump.rdb  redis_file   //对照两个文件内容是否一致
  2 files to edit
[app@127-0-0-1 ~]#

   结果:一致

+ +--40630 lines: REDIS0007ú redis-ver^F3.2.12ú-------------------------------------------------------|+ +--40630 lines: REDIS0007ú redis-ver^F3.2.12ú-------------------------------------------------------
  ~                                                                                                     |  ~                                                                                                     
  ~                                                                                                     |  ~                                                                                                     
  ~                                                                                                     |  ~                                                                                                     
  ~                                                                                                     |  ~                                                                                                     
  ~                                                                                                     |  ~                                                                                                     
  ~                                                                                                     |  ~                                                                                                     
  ~                                                                                                     |  ~                                                                                                     
  ~                                                                                                     |  ~                                                                                                     
dump.rdb                                                                              607,1          All redis_file                                                                            608,1          All

4、搜索数据

     对于冗余的数据,怎样才能快速的锁定有效数据的位置,从而更快的去锁定问题呢?不妨看下面……

[app@127-0-0-1 etc]$ grep  'Max_connections'  my.cnf
[app@127-0-0-1 etc]$ grep  'Max_connections'  my.cnf -i    //i  不区分大小写,默认是区分大小写
  max_connections=1000   
[app@127-0-0-1 etc]$ grep  'Max_connections'  my.cnf -in   //n  显示数据所在行数
  21:max_connections=1000                        //line:21
[app@127-0-0-1 etc]$ 
[app@127-0-0-1 etc]$ grep  -r  'Max_connections'  /etc -in   //r   在文件夹etc下搜索
  grep: /etc/modprobe.d/blacklist-nouveau.conf: Permission denied
  grep: /etc/audisp: Permission denied
  /etc/dbus-1/session.conf:57:  <limit name="max_connections_per_user">100000</limit>
  grep: /etc/dhcp: Permission denied
  /etc/my.cnf:21:max_connections=1000    //file:my.cn  line:21  data:max_connections=1000 
  grep: /etc/audit: Permission denied
[app@127-0-0-1 etc]$ 

  

  

缘于生活,而归于工作。本人所书,而意于分享。 如有转载,请注明出处! --活出自己范儿
原文地址:https://www.cnblogs.com/Small-sunshine/p/11230092.html