CentOS 7.6 编译安装最新版本glibc2.30 实录

       基于CentOS上安装ScyllaDB数据库的朋友应该都会遇到glibc必须为2.28及以上版本的问题,目前阿里去上提供的最高版本CentOS7.6中的glibc版本为2.27,所以必须要升级,但升级glibc并不是一件容易的事,如果操作不当还会影响一些API和服务的正常运行,所以在升级之前请先做好备份。


升级前的准备工作:

  1、升级gcc到9.2.0(请参考我的另一遍博文[https://yq.aliyun.com/articles/718551?spm=a2c4e.11155435.0.0.47163312EbbvoU](《》))

  2、安装Python3.8.0

  3、升级GNU Make 3.82到4.2.1

    wget http://ftp.gnu.org/gnu/make/make-4.2.1.tar.gz

    tar -zxvf make-4.2.1.tar.gz

    cd make-4.2.1

    mkdir build

    cd build

    ../configure --prefix=/opt/make && make && make install

    export PATH=/opt/make/bin:$PATh

    ln -s /opt/make/bin/make /opt/make/bin/gmake

    make -v


root@xxx-xxxx ~ # cat /etc/redhat-release # 查看当前linux版本信息

CentOS Linux release 7.6.1810 (Core)

root@xxx-xxxx ~ # strings /lib64/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

......

......

posix_spawnp@GLIBC_2.2.5

getrpcent_r@@GLIBC_2.2.5

getprotobynumber_r@@GLIBC_2.2.5

_IO_file_close_it@@GLIBC_2.2.5

_obstack@GLIBC_2.2.5

root@xxx-xxxx ~ #  wget -c -P /opt/tmp/ http://ftp.gnu.org/gnu/glibc/glibc-2.30.tar.gz

--2019-09-18 11:39:49--  http://ftp.gnu.org/gnu/glibc/glibc-2.30.tar.gz

正在解析主机 ftp.gnu.org (ftp.gnu.org)... 209.51.188.20, 2001:470:142:3::b

正在连接 ftp.gnu.org (ftp.gnu.org)|209.51.188.20|:80... 已连接。

已发出 HTTP 请求,正在等待回应... 200 OK

长度:32664968 (31M) [application/x-gzip]

正在保存至: “glibc-2.30.tar.gz”

100%[===========================================================================>] 32,664,968  116KB/s 用时 19m 34s

2019-09-18 11:59:24 (27.2 KB/s) - 已保存 “glibc-2.30.tar.gz” [32664968/32664968])

root@xxx-xxxx ~ # cd /opt/tmp/

root@xxx-xxxx /opt/tmp # tar -zxvf glibc-2.30.tar.gz    # 解压缩源码包

glibc-2.30/

glibc-2.30/.gitattributes

glibc-2.30/.gitignore

glibc-2.30/COPYING

glibc-2.30/COPYING.LIB

glibc-2.30/ChangeLog

glibc-2.30/ChangeLog.old/

glibc-2.30/ChangeLog.old/ChangeLog.1

glibc-2.30/ChangeLog.old/ChangeLog.10

glibc-2.30/ChangeLog.old/ChangeLog.11

......

......

glibc-2.30/wctype/wcfuncs_l.c

glibc-2.30/wctype/wchar-lookup.h

glibc-2.30/wctype/wctrans.c

glibc-2.30/wctype/wctrans_l.c

glibc-2.30/wctype/wctype.c

glibc-2.30/wctype/wctype.h

glibc-2.30/wctype/wctype_l.c

root@xxx-xxxx /opt/tmp # cd glibc-2.30

root@xxx-xxxx /opt/tmp/glibc-2.30 # mkdir build

root@xxx-xxxx /opt/tmp/glibc-2.30 # cd build

root@xxx-xxxx /opt/tmp/glibc-2.30/build # ../configure  --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

checking build system type... x86_64-pc-linux-gnu

checking host system type... x86_64-pc-linux-gnu

checking for gcc... gcc

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for readelf... readelf

checking for g++... g++

checking whether we are using the GNU C++ compiler... yes

checking whether g++ accepts -g... yes

checking whether g++ can link programs... yes

checking for sysdeps preconfigure fragments... aarch64 alpha arm csky hppa i386 m68k microblaze mips nios2 powerpc riscv s390 sh sparc x86_64 checking whether gcc compiles in -mx32 mode by default... no

checking for use of fpu sysdeps directories... yes

checking for -fstack-protector... yes

checking for -fstack-protector-strong... yes

checking for -fstack-protector-all... yes

checking for assembler and linker STT_GNU_IFUNC support... yes

checking for gcc attribute ifunc support... yes

checking whether the linker supports textrels along with ifunc... yes

checking if compiler warns about alias for function with incompatible types... yes

checking sysdep dirs... sysdeps/unix/sysv/linux/x86_64/64 sysdeps/unix/sysv/linux/x86_64 sysdeps/unix/sysv/linux/x86 sysdeps/x86/nptl sysdeps/unix/sysv/linux/wordsize-64 sysdeps/x86_64/nptl sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/x86_64 sysdeps/unix sysdeps/posix sysdeps/x86_64/64 sysdeps/x86_64/fpu/multiarch sysdeps/x86_64/fpu sysdeps/x86/fpu sysdeps/x86_64/multiarch sysdeps/x86_64 sysdeps/x86 sysdeps/ieee754/float128 sysdeps/ieee754/ldbl-96 sysdeps/ieee754/dbl-64/wordsize-64 sysdeps/ieee754/dbl-64 sysdeps/ieee754/flt-32 sysdeps/wordsize-64 sysdeps/ieee754 sysdeps/generic

checking for a BSD-compatible install... /usr/bin/install -c

checking whether ln -s works... yes

checking whether /usr/bin/as is GNU as... yes

checking whether /usr/bin/ld is GNU ld... yes

checking for /usr/bin/as... /usr/bin/as

checking version of /usr/bin/as... 2.27, ok

checking for /usr/bin/ld... /usr/bin/ld

checking version of /usr/bin/ld... 2.27, ok

checking for gnumake... no

checking for gmake... gmake

checking version of gmake... 4.2.1, ok

checking for gnumsgfmt... no

checking for gmsgfmt... no

checking for msgfmt... msgfmt

checking version of msgfmt... 0.19.8.1, ok

checking for makeinfo... makeinfo

checking version of makeinfo... 5.1, ok

checking for sed... sed

checking version of sed... 4.2.2, ok

checking for gawk... gawk

checking version of gawk... 4.0.2, ok

checking for bison... bison

checking version of bison... 3.0.4, ok

checking if gcc -B/usr/bin/ is sufficient to build libc... yes

checking for nm... nm

checking for python3... python3

checking version of python3... 3.8.0, ok

checking LD_LIBRARY_PATH variable... ok

checking for bash... /usr/bin/bash

checking for perl... /usr/bin/perl

checking for install-info... /usr/sbin/install-info

checking for .set assembler directive... yes

checking linker support for protected data symbol... yes

checking linker support for INSERT in linker script... yes

checking for broken __attribute__((alias()))... no

checking whether to put _rtld_local into .sdata section... no

checking whether to use .ctors/.dtors header and trailer... no

checking for libunwind-support in compiler... no

checking whether --noexecstack is desirable for .S files... yes

checking for -z combreloc... yes

checking for linker that supports -z execstack... yes

checking for linker that supports --no-dynamic-linker... yes

checking for -static-pie... yes

checking for -fpie... yes

checking for --hash-style option... yes

checking for sufficient default -shared layout... no

checking for GLOB_DAT reloc... yes

checking linker output format... elf64-x86-64

checking for -fno-toplevel-reorder -fno-section-anchors... yes

checking for -mtls-dialect=gnu2... yes

checking whether cc puts quotes around section names... no

checking for __builtin_memset... yes

checking for redirection of built-in functions... yes

checking for compiler option to disable generation of FMA instructions... -ffp-contract=off

checking if gcc -B/usr/bin/ accepts -fno-tree-loop-distribute-patterns with __attribute__ ((__optimize__))... yes

checking for libgd... no

checking for is_selinux_enabled in -lselinux... yes

checking for audit_log_user_avc_message in -laudit... no

checking for cap_init in -lcap... no

checking for _FORTIFY_SOURCE predefine... no

checking whether the linker provides working __ehdr_start... yes

checking for __builtin_trap with no external dependencies... yes

checking whether the C++ compiler supports thread_local... no

running configure fragment for sysdeps/unix/sysv/linux/x86_64/64

running configure fragment for sysdeps/unix/sysv/linux/x86_64

running configure fragment for sysdeps/unix/sysv/linux

checking installed Linux kernel header files... 3.2.0 or later

checking for kernel header at least 3.2.0... ok

checking for symlinks in /usr/include... ok

running configure fragment for sysdeps/gnu

running configure fragment for sysdeps/x86_64

checking for AVX512DQ support in assembler... yes

checking for AVX512 support... yes

checking -mprefer-vector-width=128... yes

checking for Intel MPX support... yes

running configure fragment for sysdeps/x86

checking whether -fPIC is default... no

checking whether -fPIE is default... no

configure: creating ./config.status

config.status: creating config.make

config.status: creating Makefile

config.status: creating config.h

config.status: config.h is unchanged

config.status: executing default commands

# 如果支行没有错误会生成makefile,如果有错按照错误提示解决,一般都是一些依赖项目的版本不正确升级一下即可

root@xxx-xxxx /opt/tmp/glibc-2.30/build # make

make -r PARALLELMFLAGS="" -C .. objdir=`pwd` all

make[1]: Entering directory '/opt/tmp/glibc-2.30'

......

......

make[2]: Leaving directory '/opt/tmp/glibc-2.30/elf'

make[1]: Leaving directory '/opt/tmp/glibc-2.30'    # 编译成功

root@xxx-xxxx /opt/tmp/glibc-2.30/build # make install

LC_ALL=C; export LC_ALL; \

make -r PARALLELMFLAGS="" -C .. objdir=`pwd` install

make[1]: Entering directory '/opt/tmp/glibc-2.30'

make  subdir=csu -C csu ..=../ subdir_lib

make  subdir=iconv -C iconv ..=../ subdir_lib

......

......

LD_SO=ld-linux-x86-64.so.2 CC="gcc -B/usr/bin/" /usr/bin/perl scripts/test-installation.pl /opt/tmp/glibc-2.30/build/

/usr/bin/ld: cannot find -lnss_test2

collect2: error: ld returned 1 exit status  # 此编译错误可以无视

Execution of gcc -B/usr/bin/ failed!        # 此编译错误可以无视

The script has found some problems with your installation!

Please read the FAQ and the README file and check the following:

- Did you change the gcc specs file (necessary after upgrading from

  Linux libc5)?

- Are there any symbolic links of the form libXXX.so to old libraries?

  Links like libm.so -> libm.so.5 (where libm.so.5 is an old library) are wrong,

  libm.so should point to the newly installed glibc file - and there should be

  only one such link (check e.g. /lib and /usr/lib)

You should restart this script from your build directory after you've

fixed all problems!

Btw. the script doesn't work if you're installing GNU libc not as your

primary library!

make[1]: *** [Makefile:111: install] Error 1

make[1]: Leaving directory '/opt/tmp/glibc-2.30'

make: *** [Makefile:12: install] Error 2    # 此编译错误可以无视

root@xxx-xxxx /opt/tmp/glibc-2.30/build # ls -l /lib64/libc.so.6    # 检验是否成功

lrwxrwxrwx 1 root root 12 Sep 18 15:14 /lib64/libc.so.6 -> libc-2.30.so    # 表示安装成功

root@xxx-xxxx ~ #


以上内容来自我的CSDN博客:https://blog.csdn.net/RyanFang/article/details/100984938

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,847评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,208评论 1 292
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,587评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,942评论 0 205
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,332评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,587评论 1 218
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,853评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,568评论 0 198
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,273评论 1 242
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,542评论 2 246
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,033评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,373评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,031评论 3 236
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,073评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,830评论 0 195
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,628评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,537评论 2 269

推荐阅读更多精彩内容