在我们的日常自动测试中,我们使用 Ansible 从 Remi 的存储库安装 PHP 7.3。通常它可以正常工作,但有时(每月几次)它会失败并出现以下错误:
fatal: [vm1.int.zone]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"allow_downgrade": false,
"conf_file": null,
"disable_gpg_check": false,
"disable_plugin": [],
"disablerepo": null,
"enable_plugin": [],
"enablerepo": "epel,remi,remi-php73",
"exclude": null,
"install_repoquery": true,
"installroot": "/",
"list": null,
"name": [
"php",
"php-mcrypt",
"php-mbstring",
"php-xml",
"php-xsl",
"php-xmlrpc",
"php-pdo",
"php-cli",
"php-pgsql",
"php-pspell",
"php-pecl-ssh2",
"php-pecl-zip",
"php-smbclient",
"php-intl",
"php-mysql",
"php-curl",
"php-xdebug",
"php-process"
],
"security": false,
"skip_broken": false,
"state": "installed",
"update_cache": false,
"update_only": false,
"validate_certs": true
}
},
"msg": "Failure talking to yum: requested datatype primary not available"
有 3 个 Remi 仓库:
# ll -d /var/cache/yum/x86_64/7/remi*
drwxr-xr-x 4 root root 4096 Oct 22 22:12 /var/cache/yum/x86_64/7/remi
drwxr-xr-x 4 root root 4096 Oct 22 22:12 /var/cache/yum/x86_64/7/remi-php73
drwxr-xr-x 4 root root 4096 Oct 22 22:12 /var/cache/yum/x86_64/7/remi-safe
如果运行某些 yum 命令,其中任何一个都会导致问题,例如:
# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror2.int.zone
* epel: mirror2.int.zone
* extras: mirror2.int.zone
* remi-safe: mirror.serverion.com
* updates: mirror2.int.zone
Error: requested datatype primary not available
如果禁用 Remi 的存储库,一切都会正常。问题在于 Remi 存储库的缓存损坏,例如:
# ll /var/cache/yum/x86_64/7/remi-php73/
total 20
-rw-r--r-- 1 root root 0 Oct 22 22:12 cachecookie
drwxr-xr-x 2 root root 4096 Oct 22 22:12 gen
-rw-r--r-- 1 root root 2996 Oct 22 22:12 mirrorlist.txt
drwxr-xr-x 2 root root 4096 Oct 22 22:12 packages
-rw-r--r-- 1 root root 2259 Oct 22 22:12 repomd.xml
# ll /var/cache/yum/x86_64/7/remi-php73/gen/
total 0
通常,该目录如下所示:
# ll /var/cache/yum/x86_64/7/remi-php73/
total 232
-rw-r--r-- 1 root root 211219 Oct 22 14:03 7042a64df80e22496ef9a31990242357a84898e0f0272915cf7cce20b705d863-primary.sqlite.bz2
-rw-r--r-- 1 root root 0 Oct 23 04:24 cachecookie
drwxr-xr-x 2 root root 4096 Oct 23 04:24 gen
-rw-r--r-- 1 root root 2996 Oct 23 04:24 mirrorlist.txt
drwxr-xr-x 2 root root 4096 Oct 23 04:25 packages
-rw-r--r-- 1 root root 3095 Oct 22 14:03 repomd.xml
# ll /var/cache/yum/x86_64/7/remi-php73/gen/
total 996
-rw-r--r-- 1 root root 1015808 Oct 22 14:03 primary_db.sqlite
因此文件{长ID}-primary.sqlite.bz2和gen/primary_db.sqlite有时会因某种原因而缺失。
问题是造成这种情况的原因是什么?
答案1
事实证明,问题出在一些破损的镜子上,请参阅主题: