• 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 脚本内容:

    1. #!/bin/bash
    2. unknown_os ()
    3. {
    4. echo "Unfortunately, your operating system distribution and version are not supported by this script."
    5. echo
    6. echo "You can override the OS detection by setting os= and dist= prior to running this script."
    7. echo "You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version"
    8. echo
    9. echo "For example, to force Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh"
    10. echo
    11. echo "Please email support@packagecloud.io and let us know if you run into any issues."
    12. exit 1
    13. }
    14. gpg_check ()
    15. {
    16. echo "Checking for gpg..."
    17. if command -v gpg > /dev/null; then
    18. echo "Detected gpg..."
    19. else
    20. echo "Installing gnupg for GPG verification..."
    21. apt-get install -y gnupg
    22. if [ "$?" -ne "0" ]; then
    23. echo "Unable to install GPG! Your base system has a problem; please check your default OS's package repositories because GPG should work."
    24. echo "Repository installation aborted."
    25. exit 1
    26. fi
    27. fi
    28. }
    29. curl_check ()
    30. {
    31. echo "Checking for curl..."
    32. if command -v curl > /dev/null; then
    33. echo "Detected curl..."
    34. else
    35. echo "Installing curl..."
    36. apt-get install -q -y curl
    37. if [ "$?" -ne "0" ]; then
    38. echo "Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work."
    39. echo "Repository installation aborted."
    40. exit 1
    41. fi
    42. fi
    43. }
    44. install_debian_keyring ()
    45. {
    46. if [ "${os,,}" = "debian" ]; then
    47. echo "Installing debian-archive-keyring which is needed for installing "
    48. echo "apt-transport-https on many Debian systems."
    49. apt-get install -y debian-archive-keyring &> /dev/null
    50. fi
    51. }
    52. detect_os ()
    53. {
    54. if [[ ( -z "${os}" ) && ( -z "${dist}" ) ]]; then
    55. # some systems dont have lsb-release yet have the lsb_release binary and
    56. # vice-versa
    57. if [ -e /etc/lsb-release ]; then
    58. . /etc/lsb-release
    59. if [ "${ID}" = "raspbian" ]; then
    60. os=${ID}
    61. dist=`cut --delimiter='.' -f1 /etc/debian_version`
    62. else
    63. os=${DISTRIB_ID}
    64. dist=${DISTRIB_CODENAME}
    65. if [ -z "$dist" ]; then
    66. dist=${DISTRIB_RELEASE}
    67. fi
    68. fi
    69. elif [ `which lsb_release 2>/dev/null` ]; then
    70. dist=`lsb_release -c | cut -f2`
    71. os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'`
    72. elif [ -e /etc/debian_version ]; then
    73. # some Debians have jessie/sid in their /etc/debian_version
    74. # while others have '6.0.7'
    75. os=`cat /etc/issue | head -1 | awk '{ print tolower($1) }'`
    76. if grep -q '/' /etc/debian_version; then
    77. dist=`cut --delimiter='/' -f1 /etc/debian_version`
    78. else
    79. dist=`cut --delimiter='.' -f1 /etc/debian_version`
    80. fi
    81. else
    82. unknown_os
    83. fi
    84. fi
    85. if [ -z "$dist" ]; then
    86. unknown_os
    87. fi
    88. # remove whitespace from OS and dist name
    89. os="${os// /}"
    90. dist="${dist// /}"
    91. echo "Detected operating system as $os/$dist."
    92. }
    93. detect_version_id () {
    94. # detect version_id and round down float to integer
    95. if [ -f /etc/os-release ]; then
    96. . /etc/os-release
    97. version_id=${VERSION_ID%%.*}
    98. elif [ -f /usr/lib/os-release ]; then
    99. . /usr/lib/os-release
    100. version_id=${VERSION_ID%%.*}
    101. else
    102. version_id="1"
    103. fi
    104. }
    105. main ()
    106. {
    107. detect_os
    108. curl_check
    109. gpg_check
    110. detect_version_id
    111. # Need to first run apt-get update so that apt-transport-https can be
    112. # installed
    113. echo -n "Running apt-get update... "
    114. apt-get update &> /dev/null
    115. echo "done."
    116. # Install the debian-archive-keyring package on debian systems so that
    117. # apt-transport-https can be installed next
    118. install_debian_keyring
    119. echo -n "Installing apt-transport-https... "
    120. apt-get install -y apt-transport-https &> /dev/null
    121. echo "done."
    122. gpg_key_url="https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey"
    123. apt_config_url="https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/config_file.list?os=${os}&dist=${dist}&source=script"
    124. apt_source_path="/etc/apt/sources.list.d/gitlab_gitlab-ce.list"
    125. gpg_keyring_path="/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg"
    126. echo -n "Installing $apt_source_path..."
    127. # create an apt config file for this repository
    128. curl -sSf "${apt_config_url}" > $apt_source_path
    129. curl_exit_code=$?
    130. if [ "$curl_exit_code" = "22" ]; then
    131. echo
    132. echo
    133. echo -n "Unable to download repo config from: "
    134. echo "${apt_config_url}"
    135. echo
    136. echo "This usually happens if your operating system is not supported by "
    137. echo "packagecloud.io, or this script's OS detection failed."
    138. echo
    139. echo "You can override the OS detection by setting os= and dist= prior to running this script."
    140. echo "You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version"
    141. echo
    142. echo "For example, to force Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh"
    143. echo
    144. echo "If you are running a supported OS, please email support@packagecloud.io and report this."
    145. [ -e $apt_source_path ] && rm $apt_source_path
    146. exit 1
    147. elif [ "$curl_exit_code" = "35" -o "$curl_exit_code" = "60" ]; then
    148. echo "curl is unable to connect to packagecloud.io over TLS when running: "
    149. echo " curl ${apt_config_url}"
    150. echo "This is usually due to one of two things:"
    151. echo
    152. echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)"
    153. echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version"
    154. echo
    155. echo "Contact support@packagecloud.io with information about your system for help."
    156. [ -e $apt_source_path ] && rm $apt_source_path
    157. exit 1
    158. elif [ "$curl_exit_code" -gt "0" ]; then
    159. echo
    160. echo "Unable to run: "
    161. echo " curl ${apt_config_url}"
    162. echo
    163. echo "Double check your curl installation and try again."
    164. [ -e $apt_source_path ] && rm $apt_source_path
    165. exit 1
    166. else
    167. echo "done."
    168. fi
    169. echo -n "Importing packagecloud gpg key... "
    170. # import the gpg key
    171. curl -fsSL "${gpg_key_url}" | gpg --dearmor > ${gpg_keyring_path}
    172. # check for os/dist based on pre debian stretch
    173. if
    174. { [ "${os,,}" = "debian" ] && [ "${version_id}" -lt 9 ]; } ||
    175. { [ "${os,,}" = "ubuntu" ] && [ "${version_id}" -lt 16 ]; } ||
    176. { [ "${os,,}" = "linuxmint" ] && [ "${version_id}" -lt 19 ]; } ||
    177. { [ "${os,,}" = "raspbian" ] && [ "${version_id}" -lt 9 ]; } ||
    178. { { [ "${os,,}" = "elementaryos" ] || [ "${os,,}" = "elementary" ]; } && [ "${version_id}" -lt 5 ]; }
    179. then
    180. # move to trusted.gpg.d
    181. mv ${gpg_keyring_path} /etc/apt/trusted.gpg.d/gitlab_gitlab-ce.gpg
    182. fi
    183. echo "done."
    184. echo -n "Running apt-get update... "
    185. # update apt on this system
    186. apt-get update &> /dev/null
    187. echo "done."
    188. echo
    189. echo "The repository is setup! You can now install packages."
    190. }
    191. main

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

  • 相关阅读:
    46、优惠券秒杀(集群下的线程并发问题(微服务集群))
    【数据结构】字符串匹配(kmp算法)
    Joplin 的思维导图 Mindmap(脑图)插件
    【华为OD机试真题 JAVA】数组二叉树
    Python Opencv实践 - 轮廓检测
    护眼台灯该怎么样选择?2022如何选择一款好的护眼台灯
    Unity数据加密☀️ 三、加密DLL供Unity使用
    浅谈java开启异步线程的几种方法(@Async,AsyncManager,线程池)
    web前端-HTML图像,表格,列表的使用
    列表、元组和字典
  • 原文地址:https://blog.csdn.net/SHK242673/article/details/126938820