1. 在线下载安装包
yum -y --downloadonly --downloaddir=./gccupdate install centos-release-scl
cd gccupdate
rpm -ivh ./*
yum -y --downloadonly --downloaddir=./gcc7 install devtoolset-7 # 下载gcc 7
#yum -y --downloadonly --downloaddir=./gcc9 install devtoolset-9 # 也可下载gcc 9
cd gcc7
rpm -Uvh ./*
#cd gcc9
#rpm -Uvh ./*
# scl -l
devtoolset-7
devtoolset-9
# scl enable devtoolset-9 bash
# gcc --version
gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# ls /opt/rh
devtoolset-7 devtoolset-9
# scl enable devtoolset-7 bash # 临时使用版本7
# echo "source /opt/rh/devtoolset-7/enable" >>/etc/profile # 开机使用版本7
2. 打包软件包,上传其他服务器,完成升级
tar -czvf gccupdate.tar.gz gccupdate