CentOS 6.9 升級 glibc 2.12 到 2.17(qbit)

qbit發表於2022-07-06

前言

  • 當前日期是 2022.7.6,CentOS 6 停止維護更新日期是 2020.11.30,CentOS 6 已停止維護近兩年
  • 由於種種原因,qbit 需要在 CentOS 6.9 上通過 Miniconda 安裝 Python 3.8,發現 glibc 版本太舊裝不上,於是試驗升級了glibc
  • 初始環境

    CentOS 6.9 x86_64
    glibc 2.12

升級步驟

  • 直接安裝 MiniConda3 報錯

    $ sh Miniconda3-py38_4.12.0-Linux-x86_64.sh 
    WARNING:
      The installer is not compatible with the version of the Linux distribution
      installed on your system. The version of GLIBC is no longer supported.
      Found version 2.12, which is less than 2.17
    Aborting installation.
    
  • 檢視當前 glibc 版本

    $ ldd --version
    ldd (GNU libc) 2.12
    Copyright (C) 2010 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    由 Roland McGrath 和 Ulrich Drepper 編寫。
  • 切換軟體倉庫(centos-vault源)

     curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
  • 生成快取

    yum makecache
  • github 上的指令碼升級 glibc,指令碼內容如下

    #!/bin/bash
    
    # update glibc to 2.17 for CentOS 6
    
    GLIBC=glibc
    OS=el6
    SERVER=https://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6
    VERSION=2.17-55
    FULL_VERSION=$GLIBC-$VERSION.fc20
    X64=x86_64
    I386=i386
    I636=i686
    REPO_32=epel-6-$I386
    REPO_64=epel-6-$X64
    
    SERVER_32=$SERVER/$REPO_32/$FULL_VERSION
    RPM_32=$VERSION.$OS.$I636.rpm
    SERVER_64=$SERVER/$REPO_64/$FULL_VERSION
    RPM_64=$VERSION.$OS.$X64.rpm
    
    # Packages
    P_1=$GLIBC
    P_2=$GLIBC-common
    P_3=$GLIBC-devel
    P_4=$GLIBC-headers
    P_5=$GLIBC-static
    P_6=$GLIBC-utils
    P_7=nscd
    
    # Required as dependency of glibc-utils
    sudo yum install --assumeyes gd
    
    # 64-bit
    sudo rpm -Uvh --force $SERVER_64/$P_1-$RPM_64 $SERVER_64/$P_2-$RPM_64 $SERVER_64/$P_3-$RPM_64 $SERVER_64/$P_4-$RPM_64 $SERVER_64/$P_5-$RPM_64 $SERVER_64/$P_6-$RPM_64 $SERVER_64/$P_7-$RPM_64
    # Print out versions
    strings /lib64/libc.so.6 | grep GLIBC
  • 再次檢查當前 glibc 版本(不用重啟)

    $ ldd --version
    ldd (GNU libc) 2.17
    Copyright (C) 2012 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    Written by Roland McGrath and Ulrich Drepper.
  • 正常安裝 Miniconda3

    $ sh Miniconda3-py38_4.12.0-Linux-x86_64.sh 
    
    Welcome to Miniconda3 py38_4.12.0
    
    In order to continue the installation process, please review the license
    agreement.
    Please, press ENTER to continue
    >>> 

後記

  • 安裝 Miniconda 後發現 pip3 不能安裝包,一直卡住不動

    $ pip3 install pipx -vvv
    Using pip 21.2.4 from /home/centos/miniconda3/lib/python3.8/site-packages/pip (python 3.8)
    Non-user install because site-packages writeable
    Created temporary directory: /tmp/pip-ephem-wheel-cache-jyavgj8d
    Created temporary directory: /tmp/pip-req-tracker-uag0fca1
    Initialized build tracking at /tmp/pip-req-tracker-uag0fca1
    Created build tracker: /tmp/pip-req-tracker-uag0fca1
    Entered build tracker: /tmp/pip-req-tracker-uag0fca1
    Created temporary directory: /tmp/pip-install-i3llrili
    Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
     1 location(s) to search for versions of pipx:
     https://mirrors.aliyun.com/pypi/simple/pipx/
    Fetching project page and analyzing links: https://mirrors.aliyun.com/pypi/simple/pipx/
    Getting page https://mirrors.aliyun.com/pypi/simple/pipx/
    Found index url https://mirrors.aliyun.com/pypi/simple/
    Looking up "https://mirrors.aliyun.com/pypi/simple/pipx/" in the cache
    Request header has "max_age" as 0, cache bypassed
    Starting new HTTPS connection (1): mirrors.aliyun.com:443
  • 排查後發現是 Miniconda 的 openssl 有問題

    $ which openssl
    ~/miniconda3/bin/openssl
    $ openssl version
    OpenSSL 1.1.1n  15 Mar 2022
    $ openssl s_client mirrors.aliyun.com:443
    卡住...
  • 解決方式一,用 http 倉庫代替 https 倉庫

    pip3 config set global.index-url http://mirrors.aliyun.com/pypi/simple/
    pip3 config set global.trusted-host mirrors.aliyun.com
本文出自qbit snap

相關文章