问题描述
【X10000】如何将生成的系统日志通过md5算法做校验?
解决方法
我们经常需要将一个目标集群的日志取回来解压分析,如何将生成的系统日志通过md5算法做校验确认日志没有破损?
1.生成md5和sha256校验文件
[root@localhost tmp]# md5sum sosreport-localhost-2023-04-11-znklpmf.tar.xz >sosreport.md5
[root@localhost tmp]# sha256sum sosreport-localhost-2023-04-11-znklpmf.tar.xz > sosreport.sha256
[root@localhost tmp]# ll
total 12032
-rw-------. 1 root root 12308316 Apr 11 13:28 sosreport-localhost-2023-04-11-znklpmf.tar.xz
-rw-r--r--. 1 root root 80 Apr 11 13:47 sosreport.md5
-rw-r--r--. 1 root root 112 Apr 11 13:48 sosreport.sha256
2.使用md5sum和sha256sum在本地校验md5和sha256码,这2个工具x10000默认系统都已经安装
[root@B20-node3 log]# ll
total 12028
-rw------- 1 root root 12308316 Apr 11 13:51 sosreport-localhost-2023-04-11-znklpmf.tar.xz
-rw-r--r-- 1 root root 80 Apr 11 13:51 sosreport.md5
-rw-r--r-- 1 root root 112 Apr 11 13:51 sosreport.sha256
[root@B20-node3 log]# md5sum -c sosreport.md5
sosreport-localhost-2023-04-11-znklpmf.tar.xz: OK ====《 校验成功,文件无损坏,显示ok
[root@B20-node3 log]# sha256sum -c sosreport.sha256
sosreport-localhost-2023-04-11-znklpmf.tar.xz: OK ====《 校验成功,文件无损坏,显示ok
如果传输过程中文件被破坏,校验结果会如下显示
[root@B20-node3 log]# md5sum -c 2.md5
2: FAILED
md5sum: WARNING: 1 computed checksum did NOT match
[root@B20-node3 tmp]# sha256sum -c 1.256
1: FAILED
sha256sum: WARNING: 1 computed checksum did NOT match