美文网首页
CentOS 7.6 编译安装最新版本glibc2.30 实录

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

作者: 老房Ryan | 来源:发表于2019-10-05 10:50 被阅读0次

           基于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

    相关文章

      网友评论

          本文标题:CentOS 7.6 编译安装最新版本glibc2.30 实录

          本文链接:https://www.haomeiwen.com/subject/wkpvuctx.html