0


gitlab 安装,libc.so.6: version `GLIBC_2.25‘ not found

背景

ubuntu 16.04 以及 ubuntu18.05 安装 gitlab 都报错误:

/opt/gitlab/embedded/bin/ruby: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by /opt/gitlab/embedded/lib/libruby.so.2.4)

解决方法(一定要看完本文)

一、安装 glibc

可以看出来应该是我们的GLIBC版本过低的原因造成的,下面我们用命令查看glibc的版本

strings /usr/lib64/libc.so.6 |grep GLIBC_

或者

strings /lib/x86_64-linux-gnu/libc.so.6 |grep GLIBC_

GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17
GLIBC_2.18
GLIBC_2.22
GLIBC_2.23
GLIBC_PRIVATE

确实是不存在GLIBC_2.25,接下来我们就开始安装GLIBC的新版本

下载地址:Index of /gnu/glibc

选择自己合适的版本进行下载,然后就是解压和安装(我下载的是glibc-2.35.tar.xz),下面的命令按照顺序一个个输入

tar -xvf glibc-2.35.tar.xz
cd glibc-2.35
mkdir build
cd build
../configure --prefix=/usr/glibc2.25
make -j16
sudo make install

注意 configure 时,一定要指定 --prefix=/usr/glibcxxx,xxx为对应的版本号,否则 sudo make install 的时候,整个系统会崩溃,并报下面错误

Makefile:106: recipe for target 'install-symbolic-link' failed
make[1]: *** [install-symbolic-link] Segmentation fault (core dumped)
make[1]: Leaving directory '/home/xxx/Downloads/glibc-2.25'
Makefile:12: recipe for target 'install' failed
make: *** [install] Error 2

二、glibc 编译报错

../sysdeps/unix/sysv/linux/sys/syscall.h:24:24: fatal error: asm/unistd.h: 没有那个文件或目录

compilation terminated.
../Makerules:266: recipe for target '/home/shihaikuo/Downloads/glibc-2.25/build/tcb-offsets.h' failed

../sysdeps/unix/sysv/linux/sys/syscall.h:24:24: fatal error: asm/prctl.h: 没有那个文件或目录

解决方法:

因为glibc 编译,代码默认去/usr/include/asm/unistd.h /usr/include/asm/prctl.h 找头文,实际ubuntu 不存在该文件,进行软链接处理。

sudo ln -s /usr/include/asm-generic /usr/include/asm

如果还是没有解决,尝试下面方法解决:

configure 的时候可能有问题:

-I../include/ -include../include/unistd.h -include../include/prctl.h

在编译目录glibc-build下搜索头文件,而不是在源代码目录glibc-2.9下。

三、终极方法

前面尝试了各种方法,实际都是曲线救国,即通过清华等其他国内源手动下载deb安装。但是根本问题就出现在这里,gitlab-ce 不同版本适用不同的操作系统及版本。

也就是说,gitlib-ce 安装失败,提示GLIBC.2.25找不到,根本原因是 gitlab-ce 的版本同当前操作系统不一致。

那么如何解决呢,可以访问gitlab 官方服务器的,可以直接通过下面方法进行下载安装(因为script.deb.sh脚本会判断执行curl 的操作系统的版本,根据版本更新 apt 的源);

curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh |sudo bash

sudo apt-get update

sudo apt install gitlab-ce

获取:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu xenial/main amd64 gitlab-ce amd64 13.12.15-ce.0 [904 MB]
已下载 904 MB,耗时 48秒 (18.6 MB/s)
(正在读取数据库 ... 系统当前共安装有 304890 个文件和目录。)
正在卸载 gitlab-ee (10.7.0-ee.0) ...
正在选中未选择的软件包 gitlab-ce。
(正在读取数据库 ... 系统当前共安装有 221085 个文件和目录。)
正准备解包 .../gitlab-ce_13.12.15-ce.0_amd64.deb ...
正在解包 gitlab-ce (13.12.15-ce.0) ...
正在设置 gitlab-ce (13.12.15-ce.0) ...

上面是通过官方进行安装的过程,当前操作系统版本为 ubuntu-16.04.1,下载的gitlab 版本为 **gitlab-ce_13.12.15-ce.0_amd64.deb **

script.deb.sh 脚本内容:

#!/bin/bash

unknown_os ()
{
  echo "Unfortunately, your operating system distribution and version are not supported by this script."
  echo
  echo "You can override the OS detection by setting os= and dist= prior to running this script."
  echo "You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version"
  echo
  echo "For example, to force Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh"
  echo
  echo "Please email [email protected] and let us know if you run into any issues."
  exit 1
}

gpg_check ()
{
  echo "Checking for gpg..."
  if command -v gpg > /dev/null; then
    echo "Detected gpg..."
  else
    echo "Installing gnupg for GPG verification..."
    apt-get install -y gnupg
    if [ "$?" -ne "0" ]; then
      echo "Unable to install GPG! Your base system has a problem; please check your default OS's package repositories because GPG should work."
      echo "Repository installation aborted."
      exit 1
    fi
  fi
}

curl_check ()
{
  echo "Checking for curl..."
  if command -v curl > /dev/null; then
    echo "Detected curl..."
  else
    echo "Installing curl..."
    apt-get install -q -y curl
    if [ "$?" -ne "0" ]; then
      echo "Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work."
      echo "Repository installation aborted."
      exit 1
    fi
  fi
}

install_debian_keyring ()
{
  if [ "${os,,}" = "debian" ]; then
    echo "Installing debian-archive-keyring which is needed for installing "
    echo "apt-transport-https on many Debian systems."
    apt-get install -y debian-archive-keyring &> /dev/null
  fi
}

detect_os ()
{
  if [[ ( -z "${os}" ) && ( -z "${dist}" ) ]]; then
    # some systems dont have lsb-release yet have the lsb_release binary and
    # vice-versa
    if [ -e /etc/lsb-release ]; then
      . /etc/lsb-release

      if [ "${ID}" = "raspbian" ]; then
        os=${ID}
        dist=`cut --delimiter='.' -f1 /etc/debian_version`
      else
        os=${DISTRIB_ID}
        dist=${DISTRIB_CODENAME}

        if [ -z "$dist" ]; then
          dist=${DISTRIB_RELEASE}
        fi
      fi

    elif [ `which lsb_release 2>/dev/null` ]; then
      dist=`lsb_release -c | cut -f2`
      os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'`

    elif [ -e /etc/debian_version ]; then
      # some Debians have jessie/sid in their /etc/debian_version
      # while others have '6.0.7'
      os=`cat /etc/issue | head -1 | awk '{ print tolower($1) }'`
      if grep -q '/' /etc/debian_version; then
        dist=`cut --delimiter='/' -f1 /etc/debian_version`
      else
        dist=`cut --delimiter='.' -f1 /etc/debian_version`
      fi

    else
      unknown_os
    fi
  fi

  if [ -z "$dist" ]; then
    unknown_os
  fi

  # remove whitespace from OS and dist name
  os="${os// /}"
  dist="${dist// /}"

  echo "Detected operating system as $os/$dist."
}

detect_version_id () {
  # detect version_id and round down float to integer
  if [ -f /etc/os-release ]; then
    . /etc/os-release
    version_id=${VERSION_ID%%.*}
  elif [ -f /usr/lib/os-release ]; then
    . /usr/lib/os-release
    version_id=${VERSION_ID%%.*}
  else
    version_id="1"
  fi
}

main ()
{
  detect_os
  curl_check
  gpg_check
  detect_version_id

  # Need to first run apt-get update so that apt-transport-https can be
  # installed
  echo -n "Running apt-get update... "
  apt-get update &> /dev/null
  echo "done."

  # Install the debian-archive-keyring package on debian systems so that
  # apt-transport-https can be installed next
  install_debian_keyring

  echo -n "Installing apt-transport-https... "
  apt-get install -y apt-transport-https &> /dev/null
  echo "done."

  gpg_key_url="https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey"
  apt_config_url="https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/config_file.list?os=${os}&dist=${dist}&source=script"

  apt_source_path="/etc/apt/sources.list.d/gitlab_gitlab-ce.list"
  gpg_keyring_path="/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg"

  echo -n "Installing $apt_source_path..."

  # create an apt config file for this repository
  curl -sSf "${apt_config_url}" > $apt_source_path
  curl_exit_code=$?

  if [ "$curl_exit_code" = "22" ]; then
    echo
    echo
    echo -n "Unable to download repo config from: "
    echo "${apt_config_url}"
    echo
    echo "This usually happens if your operating system is not supported by "
    echo "packagecloud.io, or this script's OS detection failed."
    echo
    echo "You can override the OS detection by setting os= and dist= prior to running this script."
    echo "You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version"
    echo
    echo "For example, to force Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh"
    echo
    echo "If you are running a supported OS, please email [email protected] and report this."
    [ -e $apt_source_path ] && rm $apt_source_path
    exit 1
  elif [ "$curl_exit_code" = "35" -o "$curl_exit_code" = "60" ]; then
    echo "curl is unable to connect to packagecloud.io over TLS when running: "
    echo "    curl ${apt_config_url}"
    echo "This is usually due to one of two things:"
    echo
    echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)"
    echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version"
    echo
    echo "Contact [email protected] with information about your system for help."
    [ -e $apt_source_path ] && rm $apt_source_path
    exit 1
  elif [ "$curl_exit_code" -gt "0" ]; then
    echo
    echo "Unable to run: "
    echo "    curl ${apt_config_url}"
    echo
    echo "Double check your curl installation and try again."
    [ -e $apt_source_path ] && rm $apt_source_path
    exit 1
  else
    echo "done."
  fi

  echo -n "Importing packagecloud gpg key... "
  # import the gpg key
  curl -fsSL "${gpg_key_url}" | gpg --dearmor > ${gpg_keyring_path}
  # check for os/dist based on pre debian stretch
  if
  { [ "${os,,}" = "debian" ] && [ "${version_id}" -lt 9 ]; } ||
  { [ "${os,,}" = "ubuntu" ] && [ "${version_id}" -lt 16 ]; } ||
  { [ "${os,,}" = "linuxmint" ] && [ "${version_id}" -lt 19 ]; } ||
  { [ "${os,,}" = "raspbian" ] && [ "${version_id}" -lt 9 ]; } ||
  { { [ "${os,,}" = "elementaryos" ] || [ "${os,,}" = "elementary" ]; } && [ "${version_id}" -lt 5 ]; }
  then
    # move to trusted.gpg.d
    mv ${gpg_keyring_path} /etc/apt/trusted.gpg.d/gitlab_gitlab-ce.gpg
  fi
  echo "done."

  echo -n "Running apt-get update... "
  # update apt on this system
  apt-get update &> /dev/null
  echo "done."

  echo
  echo "The repository is setup! You can now install packages."
}

main

所以针对无法访问官方服务器的,可以在可以访问官方服务器的电脑上进行安装,并获取curl 下来的版本,并通过手动下载的方式下载到电脑进行手动安装(sudo dpkg -i xxx.deb)。

标签: ubuntu linux 运维

本文转载自: https://blog.csdn.net/SHK242673/article/details/126938820
版权归原作者 水无声风无痕 所有, 如有侵权,请联系我们删除。

“gitlab 安装,libc.so.6: version `GLIBC_2.25‘ not found”的评论:

还没有评论