centos 7.2执行yum -y install报错Metadata file does not match checksum
分析结论
1,Metadata file does not match checksum报错在于元文件的校验值与元文件不匹配
2,元数据是指 mnt/repodata/436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz 这种文件
其所在路径为 光盘/repodata
3,yum的配置文件分为主配置文件和 各自独立的配置文件
4,yum主配置文件在/etc/yum.conf
5, yum各自独立的配置文件在/etc/yum.repos.d/不同的子目录
6,续上,这个不同的子目录对应于自定义的yum配置源配置文件
7,yum的本地cache缓存可见yum主配置文件/etc/yum.conf获取
8,关于元文件的校验值与元文件的配置信息在 repomd.xml获取,其具体内容如下:
42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454 --sha256校验算法
3464f99938d4614cd1c9048a8e78a8016b5fc0732d2aed9108f45a1e58cf3e80
--sha256校验算法对应的元数据或元文件
1449702849
10
2958583
13557760
9,上述的配置在本地及光盘皆存在
分析明细
1,yum安装报错 Metadata file does not match checksum
[root@card2 yum.repos.d]# yum -y install gcc
已加载插件:fastestmirror
base | 3.6 kB 00:00:00
base/group_gz FAILED
file:///mnt/repodata/436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz: [Errno -1] Metadata file does not match checksum 0 B --:--:-- ETA
正在尝试其它镜像。
base/primary_db FAILED [ ] 0.0 B/s | 20 kB --:--:-- ETA
file:///mnt/repodata/42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2: [Errno -1] Metadata file does not match checksum/s | 20 kB --:--:-- ETA
正在尝试其它镜像。
Determining fastest mirrors
base/primary_db FAILED [ ] 0.0 B/s | 20 kB --:--:-- ETA
file:///mnt/repodata/42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2: [Errno -1] Metadata file does not match checksum/s | 20 kB --:--:-- ETA
正在尝试其它镜像。
base/primary_db | 20 kB 00:00:14
file:///mnt/repodata/42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2: [Errno -1] Metadata file does not match checksum
正在尝试其它镜像。
2,可见上述的base对应如下配置文件中的[base]
[root@card2 yum.repos.d]# pwd
/etc/yum.repos.d
[root@card2 yum.repos.d]# ll
总用量 8
-rw-r--r--. 1 root root 63 9月 13 09:06 local.repo
-rw-r--r--. 1 root root 557 9月 12 18:28 ori.x
[root@card2 yum.repos.d]# pwd
/etc/yum.repos.d
[root@card2 yum.repos.d]# more local.repo
[base]
name=local-vcd
baseurl=file:///mnt
enabled=1
gpgcheck=0
[root@card2 yum.repos.d]#
3,从报错可知是加载光盘中的如下很长的文件校验好像与什么不匹配
[root@card2 yum.repos.d]# ls -l /mnt/repodata/436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz
-r--r--r--. 1 root root 158802 12月 10 2015 /mnt/repodata/436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz
[root@card2 yum.repos.d]#
上述长文件打不开
[root@card2 yum.repos.d]# strings /mnt/repodata/436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz
[root@card2 yum.repos.d]# ^C
4,会不会上述加载光盘中的长文件与光盘对应目录的配置文件repomd.xml有什么关系呢
[root@card2 repodata]# pwd
/mnt/repodata
[root@card2 repodata]# more repomd.xml
1449702798
3eda3fefdbaf4777fcab430c80bc438293c512f22fd706b12c6567d535b2142a
1449702849
746824
cfa741341d5d270d5b42d6220e2908d053c39a2d8346986bf48cee360e6f7ce8
cf0c38f2d85b81e960c77d48e6abd48f521caa9ec83662e308dbb53bc62c0ead
1449702839
2997550
37183151
---可见是这个报错了,里面内容包括 checksum校验值以及引用的文件
436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98
3eda3fefdbaf4777fcab430c80bc438293c512f22fd706b12c6567d535b2142a
1449702849
158802
6990209f63a9fd811f13e830ac3c6de4c5d70a42b1c6873e4329b523d394c3bd
76a6786b724d57813cba57980917809d4dc3eefba5a6a11a2432d6bbd2fd6233
1449702839
1430575
11601661
42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454
3464f99938d4614cd1c9048a8e78a8016b5fc0732d2aed9108f45a1e58cf3e80
1449702849
10
2958583
13557760
9710c85f1049b4c60c74ae5fd51d3e98e4ecd50a43ab53ff641690fb164a6d63
a0422ef0698b20718bf4c013cbb1c4f10456432eaf5d3a4afd9955ed6968aaf7
1449702841
10
1259881
7371776
40bac61f2a462557e757c2183511f57d07fba2c0dd63f99b48f0b466b7f2b8d2
46168cc31d3f6872bbccf30d495bd8e5d8f631669285b693e2bd66373aa32f9c
1449702839
975743
7907616
d863fcc08a4e8d47382001c3f22693ed77e03815a76cedf34d8256d4c12f6f0d
3f18b4fee4a56bb57bed280bbc9d0f285d94c2bab6cddd4292681b7073dbe27c
1449702846
10
2995501
18021376
[root@card2 repodata]#
5,从本地来看,校验值也是匹配的
[root@card2 base]# pwd
/var/cache/yum/x86_64/7/base
436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98
3eda3fefdbaf4777fcab430c80bc438293c512f22fd706b12c6567d535b2142a
1449702849
158802
6,再尝试另一个角度分析,对比现在不正常的这个与集群节点1正常的对应目录进行对比分析
---当前节点不正常
[root@card2 base]# pwd
/var/cache/yum/x86_64/7/base
[root@card2 base]# ll
总用量 8
drwxr-xr-x. 2 root root 6 9月 13 09:06 gen
drwxr-xr-x. 2 root root 6 9月 12 14:18 packages
-rw-r--r--. 1 root root 3732 12月 10 2015 repomd.xml
---集群节点正常
[root@card1 c7-media]# pwd
/var/cache/yum/x86_64/7/c7-media
[root@card1 c7-media]# ll
总用量 3064
-rw-r--r--. 1 root root 2958583 12月 10 2015 42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2
-rw-r--r--. 1 root root 158802 12月 10 2015 436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz
-rw-r--r--. 1 root root 0 9月 12 15:49 cachecookie
drwxr-xr-x. 2 root root 30 9月 12 15:49 gen
drwxr-xr-x. 2 root root 6 9月 12 15:48 packages
-rw-r--r--. 1 root root 3732 12月 10 2015 repomd.xml
[root@card1 c7-media]#
7,根据上述分析,从光盘对应目录把上述的长文件复制到本地对应目录中
[root@card2 repodata]# cp 42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2 /var/cache/yum/x86_64/7/base
cp:是否覆盖"/var/cache/yum/x86_64/7/base/42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2"? yes
cp: 读取"42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2" 时出错: 输入/输出错误
cp: 扩展"/var/cache/yum/x86_64/7/base/42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2" 失败: 输入/输出错误
[root@card2 repodata]# cp 436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz /var/cache/yum/x86_64/7/base
cp: 读取"436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz" 时出错: 输入/输出错误
cp: 扩展"/var/cache/yum/x86_64/7/base/436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz" 失败: 输入/输出错误
[root@card2 repodata]#
[root@card2 base]# touch cachecookie
[root@card2 base]# ll
总用量 28
-r--r--r--. 1 root root 20480 9月 13 10:15 42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2
-r--r--r--. 1 root root 0 9月 13 10:16 436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz
-rw-r--r--. 1 root root 0 9月 13 10:17 cachecookie
drwxr-xr-x. 2 root root 6 9月 13 09:06 gen
drwxr-xr-x. 2 root root 6 9月 12 14:18 packages
-rw-r--r--. 1 root root 3732 12月 10 2015 repomd.xml
8,继续分析找解决方法
---集群正常节点的
[root@card1 c7-media]# pwd
/var/cache/yum/x86_64/7/c7-media
[root@card1 c7-media]# ll
总用量 3064
-rw-r--r--. 1 root root 2958583 12月 10 2015 42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2
-rw-r--r--. 1 root root 158802 12月 10 2015 436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz
-rw-r--r--. 1 root root 0 9月 12 15:49 cachecookie
drwxr-xr-x. 2 root root 30 9月 12 15:49 gen
drwxr-xr-x. 2 root root 6 9月 12 15:48 packages
-rw-r--r--. 1 root root 3732 12月 10 2015 repomd.xml
[root@card1 c7-media]# sha256sum 42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2
42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454 42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2
[root@card1 c7-media]# sha256sum 436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz
436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98 436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz
[root@card1 c7-media]#
[root@card1 c7-media]# more repomd.xml |grep 42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454
42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454
[root@card1 c7-media]#
[root@card1 repodata]# pwd
/mnt/repodata
[root@card1 repodata]# sha256sum 42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2
42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454 42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2
[root@card1 repodata]#
[root@card1 repodata]# sha256sum 436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz
436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98 436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz
[root@card1 repodata]#
----节点不正常的
[root@card2 repodata]# pwd
/mnt/repodata
[root@card2 repodata]# sha256sum 42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2
sha256sum: 42a80e759522768b2cc357553bb64bd7345b06abeb60187f881089b859a63454-primary.sqlite.bz2: 输入/输出错误
[root@card2 repodata]#
[root@card2 repodata]# sha256sum 436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz
sha256sum: 436345f4b666f0a461d479ccfabc2c22823d4f2173c2653e5250fea62f0afe98-c7-x86_64-comps.xml.gz: 输入/输出错误
[root@card2 repodata]#
[root@card2 repodata]# sha256sum 9710c85f1049b4c60c74ae5fd51d3e98e4ecd50a43ab53ff641690fb164a6d63-other.sqlite.bz2
sha256sum: 9710c85f1049b4c60c74ae5fd51d3e98e4ecd50a43ab53ff641690fb164a6d63-other.sqlite.bz2: 输入/输出错误
[root@card2 repodata]#
[root@card2 ~]# umount /mnt
[root@card2 ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@card2 ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 50G 886M 50G 2% /
devtmpfs 24G 0 24G 0% /dev
tmpfs 24G 0 24G 0% /dev/shm
tmpfs 24G 26M 24G 1% /run
tmpfs 24G 0 24G 0% /sys/fs/cgroup
/dev/mapper/centos-home 1.6T 33M 1.6T 1% /home
/dev/sda1 497M 127M 370M 26% /boot
tmpfs 4.7G 0 4.7G 0% /run/user/0
/dev/sr0 4.1G 4.1G 0 100% /mnt
[root@card2 ~]#
9,可见可能是不正常节点上面挂载的光盘有问题,尝试替换正常节点的光盘,问题解决