由于 libssl 依赖性,`apt-get install librdkafka1` 在 Debian 9.x 上失败

`apt-get install librdkafka1` fails on Debian 9.x due to libssl dependency

基本 apt-get install librdkafka1 适用于 Debian 8.x 但无法适用于 Debian 9.x。这看起来像是关于 libssl 的依赖版本问题。 Debian 8.x 有 libssl1.0.0,Debian 9.x 有 libssl1.0.2 和 libssl1.1,但没有 libssl1.0.0,这个版本升级只会导致 librdkafka1 安装失败。

这很容易在最新的官方 Docker Debian 9 映像上重现:

docker pull debian:9
docker run --rm -it debian:9

然后在虚拟机中

cat /etc/debian_version
# 9.4

apt-get update
# Get basics to setup Confluent repository
apt-get install -y wget gnupg2 software-properties-common libssl1.0.2

wget -qO - http://packages.confluent.io/deb/4.1/archive.key | apt-key add -
add-apt-repository "deb [arch=amd64] http://packages.confluent.io/deb/4.1 stable main"
apt-get update

apt-cache policy libssl1.0.2 结果:

libssl1.0.2:
  Installed: 1.0.2l-2+deb9u3
  Candidate: 1.0.2l-2+deb9u3
  Version table:
 *** 1.0.2l-2+deb9u3 500
        500 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
        100 /var/lib/dpkg/status
     1.0.2l-2+deb9u2 500
        500 http://deb.debian.org/debian stretch/main amd64 Packages

apt-cache policy librdkafka1 结果:

librdkafka1:
  Installed: (none)
  Candidate: 0.11.4~1confluent4.1.0-1
  Version table:
     0.11.4~1confluent4.1.0-1 500
        500 http://packages.confluent.io/deb/4.1 stable/main amd64 Packages
     0.9.3-1 500
        500 http://deb.debian.org/debian stretch/main amd64 Packages

apt-get install librdkafka1 结果:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 librdkafka1 : Depends: libssl1.0.0 (>= 1.0.0) but it is not installable
E: Unable to correct problems, you have held broken packages.

apt-cache search libssl 生成以下内容。请注意,有 libssl1.0.2libssl1.1 但没有 libssl1.0.0

libssl-ocaml - OCaml bindings for OpenSSL (runtime)
libssl-ocaml-dev - OCaml bindings for OpenSSL
libssl-dev - Secure Sockets Layer toolkit - development files
libssl-doc - Secure Sockets Layer toolkit - development documentation
libssl1.1 - Secure Sockets Layer toolkit - shared libraries
libssl1.0-dev - Secure Sockets Layer toolkit - development files
libssl1.0.2 - Secure Sockets Layer toolkit - shared libraries

更新:这个问题在 Confluent 4.1、librdkafka 0.11.4 和 Debian 9.4 中仍然存在。

我认为您的 apt 来源有误。

正如日志所说,存储库 packages.confluent.io 正在被使用,并在 Debian 的存储库上提出一个新版本。

您可以使用 apt show python-kafka 或使用 apt-cache show python-kafka

从缓存中检查包的依赖项列表

dist-upgradeJessieStretch 了吗?

仅供参考,主要的 librdkafka 维护者 Edenhill 在评论中回答了这个问题:

Confluent does not yet provide librdkafka packages for Debian 9, but will do so soon. I suggest you build librdkafka from source until then, or check the standard Debian packages (which will most likely have an older version of librdkafka though)

librdkafka 根本不支持 Debian 9。从 Confluent Platform 4.1 开始仍然如此。 Confluent 平台仍未正式支持 Debian 9:https://docs.confluent.io/current/installation/installing_cp.html

librdkafka1 已添加到 stretch-backports:

https://packages.debian.org/stretch-backports/librdkafka1

要安装:

add-apt-repository "deb http://deb.debian.org/debian stretch-backports main contrib non-free"
apt-get update
apt-get install librdkafka1/stretch-backports

官方 Confluent 仓库中 librdkafka1 的版本不支持 Debian 9。从 Confluent 5.0 开始,Confluent 平台本身不正式支持 Debian 9: https://docs.confluent.io/current/installation/system-requirements.html#system-requirements