目录
可算找到了对的文档,做了2天没做出来,一直报错,要不是 他家 的文档估计现在还做不出来,哎,为知识付个费用,也值
我写的这份文档如果你没有执行成功,你需要联系卖家,因为我也还没具体弄懂哪是哪,不过确实成功升级了,也没啥问题,先解决了眼前问题再说吧
源
[root@c7-1 ~]# vim /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
# 添加如下2段
[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/sclo/
# mirrorlist=https://mirrors.aliyun.com?arch=$basearch&release=7&repo=sclo-sclo
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
#mirrorlist=https://mirrors.aliyun.com?arch=$basearch&release=7&repo=sclo-rh
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
[root@c7-1 ~]# yum clean all && yum makecache
[root@c7-1 ~]# yum repolist
[root@c7-1 ~]# strings /lib64/libc.so.6 | grep ^GLIBC_
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17 # 这是自带的最高的版本
GLIBC_PRIVATE
安装
# 安装gcc8
[root@localhost ~]# yum update -y && yum install -y centos-release-scl
[root@localhost ~]# yum install -y bison wget bzip2 gcc gcc-c++ glibc-headers nss-devel
# 升级make
[root@localhost ~]# wget http://ftp.gnu.org/gnu/make/make-4.2.1.tar.gz
[root@localhost ~]# tar -zxvf make-4.2.1.tar.gz
[root@localhost ~]# mkdir make-4.2.1/build && cd make-4.2.1/build
[root@localhost build]# ../configure --prefix=/usr/local/make && make -j4 && make install
[root@localhost build]# export PATH=/usr/local/make/bin:$PATH
[root@localhost build]# ln -s /usr/local/make/bin/make /usr/local/make/bin/gmake
[root@localhost build]# make -v
GNU Make 4.2.1
[root@c7-1 build]# cd
# 升级GCC
[root@c7-1 ~]# yum install -y devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-binutils
[root@c7-1 ~]# echo "source /opt/rh/devtoolset-8/enable" | tee -a /etc/profile
[root@c7-1 ~]# source /etc/profile
[root@c7-1 ~]# gcc -v
....
....
gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)
# 下载并安装Glibc
[root@c7-1 ~]# wget https://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.xz
[root@c7-1 ~]# xz -d glibc-2.28.tar.xz && tar -xvf glibc-2.28.tar
[root@c7-1 ~]# mkdir glibc-2.28/build && cd glibc-2.28/build
[root@c7-1 build]# ../configure --prefix=/usr --with-headers=/usr/include \
--with-binutils=/usr/bin --disable-profile --enable-add-ons
[root@c7-1 build]# ../configure --prefix=/usr \
--with-headers=/usr/include \
--with-binutils=/usr/bin \
--enable-add-ons \
--enable-obsolete-nsl \
--disable-profile \
--disable-sanity-checks \
--disable-werror
[root@c7-1 build]# make -j4
[root@c7-1 build]# make install
[root@c7-1 build]# strings /lib64/libc.so.6 | grep ^GLIBC_2.28
GLIBC_2.28
GLIBC_2.28
[root@c7-1 build]# cd
后期
报错1:-bash: warning: setlocale: LC_TIME:cannot change locale(en_US.UTF-8)
解决
# 重新生成本地化文件
在升级glibc后,可能需要重新生成本地化文件,确保系统能够识别并使用正确的本地化环境。你可以使用以下命令重新生成所有本地化文件:
[root@c7-1 ~]# localedef -c -i en_US -f UTF-8 en_US.UTF-8
注:这将重新生成 en_US.UTF-8 本地化环境
# 更新系统的 locale 设置
如果 en_US.UTF-8 本地化环境缺失或损坏,可以通过安装或重新配置来修复它
首先确认是否已安装所需的本地化包
[root@c7-1 ~]# yum -y install glibc-common
然后,重新设置系统本地化配置。你可以使用 localectl 命令来设置系统默认的语言和地区:
[root@c7-1 ~]# localectl set-locale LANG=en_US.UTF-8
# 验证本地化环境是否生效,确保本地化环境已经正确设置
[root@c7-1 ~]# locale
locale: 无法将 LC_ALL 设置为缺省的语区: 没有那个文件或目录
LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC=zh_CN.UTF-8
LC_TIME=zh_CN.UTF-8
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY=zh_CN.UTF-8
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER=zh_CN.UTF-8
LC_NAME=zh_CN.UTF-8
LC_ADDRESS=zh_CN.UTF-8
LC_TELEPHONE=zh_CN.UTF-8
LC_MEASUREMENT=zh_CN.UTF-8
LC_IDENTIFICATION=zh_CN.UTF-8
LC_ALL=
# 重新生成缺失的语言环境文件
如果 glibc-common 已安装,但仍然没有找到 zh_CN.UTF-8 或其他所需的本地化文件,可以尝试重新生成这些语言环境文件
[root@c7-1 ~]# localedef -c -i zh_CN -f UTF-8 zh_CN.UTF-8
[root@c7-1 ~]# localedef -c -i en_US -f UTF-8 en_US.UTF-8
注:这将生成 zh_CN.UTF-8 和 en_US.UTF-8 语言环境,解决 locale 配置缺失的问题
# 检查 /etc/locale.conf 文件
检查并确认 /etc/locale.conf 中的配置是否正确,尤其是 LANG 和 LC_ALL 变量
[root@c7-1 ~]# vim /etc/locale.conf
LANG=zh_CN.UTF-8
LC_ALL=zh_CN.UTF-8
注:如只想使用zh_CN.UTF-8,并且没有LC_ALL,可删除LC_ALL变量或者将其设置为合适的值。确保其他 LC_* 变量也指向正确的语言环境
# 检查系统本地化设置
[root@c7-1 ~]# locale
LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC=zh_CN.UTF-8
LC_TIME=zh_CN.UTF-8
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY=zh_CN.UTF-8
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER=zh_CN.UTF-8
LC_NAME=zh_CN.UTF-8
LC_ADDRESS=zh_CN.UTF-8
LC_TELEPHONE=zh_CN.UTF-8
LC_MEASUREMENT=zh_CN.UTF-8
LC_IDENTIFICATION=zh_CN.UTF-8
LC_ALL=
# 重新加载 shell 环境
如果所有配置都正确,可以尝试重新加载 shell 环境
[root@c7-1 ~]# source /etc/profile
或者直接重启:
[root@c7-1 ~]# reboot # 最好重启下
# 清除缓存
为了确保新的glibc配置生效,可以清除系统的缓存
[root@c7-1 ~]# ldconfig
标签:zh,CN,c7,glibc,CentOS7.9,2.28,UTF,root,LC
From: https://www.cnblogs.com/smlile-you-me/p/18652334