故障案例:Oracle Linux 9.4 无法正常使用 dnf

故障案例:Oracle Linux 9.4 无法正常使用 dnf

ShawnYan Lv.6

Description

在 Oracle Linux 9.4 的实验环境中,我们遇到了一个棘手的问题:无法正常使用 dnf 进行软件包管理。以下是详细的故障现象和解决方案。

尝试安装 cmake 时,遇到以下错误。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[root@ol9 ~]# dnf install cmake
Last metadata expiration check: 1:01:03 ago on Tue 22 Oct 2024 01:34:43 AM CST.
Dependencies resolved.
======================================================================================================================================================================================================================================
Package Architecture Version Repository Size
======================================================================================================================================================================================================================================
Installing:
cmake x86_64 3.26.5-2.el9 ol9_appstream 8.7 M
Installing dependencies:
cmake-data noarch 3.26.5-2.el9 ol9_appstream 4.8 M
cmake-filesystem x86_64 3.26.5-2.el9 ol9_appstream 11 k
cmake-rpm-macros noarch 3.26.5-2.el9 ol9_appstream 15 k

Transaction Summary
======================================================================================================================================================================================================================================
Install 4 Packages

Total download size: 14 M
Installed size: 38 M
Is this ok [y/N]: y
Downloading Packages:
(1-3/4): cmake-filesystem-3.26.5-2.el9.x86_64.rpm 0% [ ] --- B/s | 0 B --:-- ETA

[MIRROR] cmake-3.26.5-2.el9.x86_64.rpm: Curl error (52): Server returned nothing (no headers, no data) for https://yum.oracle.com/repo/OracleLinux/OL9/appstream/x86_64/getPackage/cmake-3.26.5-2.el9.x86_64.rpm [Empty reply from server]
[MIRROR] cmake-3.26.5-2.el9.x86_64.rpm: Curl error (35): SSL connect error for https://yum.oracle.com/repo/OracleLinux/OL9/appstream/x86_64/getPackage/cmake-3.26.5-2.el9.x86_64.rpm [OpenSSL SSL_connect: SSL_ERROR_ZERO_RETURN in connection to yum.oracle.com:443 ]
^C(1-3/4): cmake-filesystem-3.26.5-2.el9.x86_64.rpm 0% [ ] --- B/s | 0 B --:-- ETA
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: Error downloading packages:
Interrupted by a SIGINT signal

原因:在某些特定网站上使用 curl 时,不会返回任何输出,而是显示错误消息。当远程端意外关闭 TLS 连接(即未正确关闭)时,Oracle Linux 9 自带的 curl 会失败。

1
2
[shawnyan@ol9 ~]$ curl https://xml-gateway-test.schufa.de
curl: (56) OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading, errno 0

检查确认系统版本和内核信息:

1
2
3
4
5
6
[shawnyan@ol9 ~]$ cat /etc/oracle-release
Oracle Linux Server release 9.4
[shawnyan@ol9 ~]$ uname -r
5.15.0-205.149.5.1.el9uek.x86_64
[shawnyan@ol9 ~]$ uname -v
#2 SMP Fri Apr 5 11:29:36 PDT 2024

检查 curl 和 openssl 版本:

1
2
3
4
5
6
7
[shawnyan@ol9 ~]$ curl --version
curl 7.76.1 (x86_64-redhat-linux-gnu) libcurl/7.76.1 OpenSSL/3.0.7 zlib/1.2.11 brotli/1.0.9 libidn2/2.3.0 libpsl/0.21.1 (+libidn2/2.3.0) libssh/0.10.4/openssl/zlib nghttp2/1.43.0
Release-Date: 2021-04-14
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets
[shawnyan@ol9 ~]$ openssl version
OpenSSL 3.0.7 1 Nov 2022 (Library: OpenSSL 3.0.7 1 Nov 2022)

Fix: Upgrade libcurl

解决方案:升级 libcurl,在本地编译安装 curl 源码。

  1. 下载 curl 源码

https://github.com/curl/curl/releases/download/curl-7_88_1/curl-7.88.1.zip

  1. 编译安装
1
2
3
4
unzip curl-7.88.1.zip
cd curl-7.88.1/
./configure --with-openssl
make && make install
  1. 声明动态库
1
export LD_LIBRARY_PATH=/usr/local/lib
  1. 确认已链接到新版本的 libcurl
1
2
3
4
[root@ol9 ~]# ldd /bin/curl | grep libcurl
libcurl.so.4 => /usr/local/lib/libcurl.so.4 (0x00007f73034d6000)
[root@ol9 ~]# ll /usr/local/lib/libcurl.so.4
lrwxrwxrwx 1 root root 16 Oct 22 18:31 /usr/local/lib/libcurl.so.4 -> libcurl.so.4.8.0
  1. 再次执行 dnf 安装 cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
[root@ol9 ~]# dnf install cmake
Last metadata expiration check: 1:06:26 ago on Tue 22 Oct 2024 05:58:43 PM CST.
Dependencies resolved.
======================================================================================================================================================================================================================================
Package Architecture Version Repository Size
======================================================================================================================================================================================================================================
Installing:
cmake x86_64 3.26.5-2.el9 ol9_appstream 8.7 M
Installing dependencies:
cmake-data noarch 3.26.5-2.el9 ol9_appstream 4.8 M
cmake-filesystem x86_64 3.26.5-2.el9 ol9_appstream 11 k
cmake-rpm-macros noarch 3.26.5-2.el9 ol9_appstream 15 k

Transaction Summary
======================================================================================================================================================================================================================================
Install 4 Packages

Total download size: 14 M
Installed size: 38 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): cmake-filesystem-3.26.5-2.el9.x86_64.rpm 36 kB/s | 11 kB 00:00
(2/4): cmake-rpm-macros-3.26.5-2.el9.noarch.rpm 210 kB/s | 15 kB 00:00
(3/4): cmake-data-3.26.5-2.el9.noarch.rpm 4.1 MB/s | 4.8 MB 00:01
(4/4): cmake-3.26.5-2.el9.x86_64.rpm 6.6 MB/s | 8.7 MB 00:01
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 10 MB/s | 14 MB 00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : cmake-rpm-macros-3.26.5-2.el9.noarch 1/4
Installing : cmake-filesystem-3.26.5-2.el9.x86_64 2/4
Installing : cmake-data-3.26.5-2.el9.noarch 3/4
Installing : cmake-3.26.5-2.el9.x86_64 4/4
Running scriptlet: cmake-3.26.5-2.el9.x86_64 4/4
Verifying : cmake-3.26.5-2.el9.x86_64 1/4
Verifying : cmake-data-3.26.5-2.el9.noarch 2/4
Verifying : cmake-filesystem-3.26.5-2.el9.x86_64 3/4
Verifying : cmake-rpm-macros-3.26.5-2.el9.noarch 4/4

Installed:
cmake-3.26.5-2.el9.x86_64 cmake-data-3.26.5-2.el9.noarch cmake-filesystem-3.26.5-2.el9.x86_64 cmake-rpm-macros-3.26.5-2.el9.noarch

Complete!

安装成功,问题解决。

Have a nice day ~

– / END / –

  • Title: 故障案例:Oracle Linux 9.4 无法正常使用 dnf
  • Author: ShawnYan
  • Created at: 2024-10-22 23:00:00
  • Updated at: 2024-10-22 23:00:00
  • Link: https://shawnyan.cn/2024/linux/oracle-linux-9-dnf-does-not-work/
  • License: This work is licensed under CC BY-NC-SA 4.0.
if (hexo-config('comment.enable') == true && hexo-config('comment.system') != "") { if (hexo-config('comment.system') == "waline") { @require "./waline.styl" } else if (hexo-config('comment.system') == "gitalk") { @require "./gitalk.styl" } else if (hexo-config('comment.system') == "twikoo") { @require "./twikoo.styl" } } .comments-container display inline-block margin-top $spacing-unit width 100% #comment-anchor width 100% height 10px .comment-area-title width 100% margin 10px 0 font-size 1.38rem color var(--default-text-color) font-family 'Consolas', '宋体', sans-serif font-weight bold i color var(--default-text-color) +redefine-tablet() margin 5px 0 font-size 1.2rem