squid升级问题记录

1 操作流程

原系统中squid版本如下3.5.20,因漏扫,需进行版本升级,本次需求是升级到4.15版本,安装包已经提前下载完毕,下载的为tar包。


查看squid版本:

[root@local ~]# squid -v
Squid Cache: Version 3.5.20
Service Name: squid
configure options:  '--host=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share'  (省略其他配置信息)
[root@local ~]#

1.1 停止squid,卸载原版本

查看当前squid状态,并停止服务:

[root@local squid-4.15]# systemctl status squid
● squid.service - Squid caching proxy
   Loaded: loaded (/usr/lib/systemd/system/squid.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2021-06-15 15:50:15 CST; 1 years 2 months ago
 Main PID: 24155 (squid)
   CGroup: /system.slice/squid.service
           ├─24155 /usr/sbin/squid -f /etc/squid/squid.conf
           ├─24157 (squid-1) -f /etc/squid/squid.conf
           └─24158 (logfile-daemon) /var/log/squid/access.log

Jun 15 15:50:15 local systemd[1]: Starting Squid caching proxy...
Jun 15 15:50:15 local squid[24155]: Squid Parent: will start 1 kids
Jun 15 15:50:15 local squid[24155]: Squid Parent: (squid-1) process 24157 started
Jun 15 15:50:15 local systemd[1]: Started Squid caching proxy.
[root@local squid-4.15]#
[root@local squid-4.15]#
[root@local squid-4.15]# systemctl stop squid
[root@local squid-4.15]#

服务停止后,使用以下命令将原squid版本卸载:

yum -y remove squid

1.2 安装新版本

将新版本tar包上传至服务器并解压,进入到文件到/opt目录下:

tar zxvf squid-4.15.tar.gz -C /opt

进入到安装目录,配置configure(configure后面的参数可根据实际需求添加,这里只做示范):

[root@local /]cd /opt/squid-4.15
[root@local squid-4.15]./configure --prefix=/usr/local/squid --sysconfdir=/etc/squid --enable-linux-netfilter
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
(=======省略中间内容======)
checking simplified host os... linux (version )
checking whether g++ supports C++11 features by default... no
checking whether g++ supports C++11 features with -std=c++11... no
checking whether g++ supports C++11 features with -std=c++0x... no
configure: error: *** A compiler with support for C++11 language features is required.
[root@local squid-4.15]#

这里就出现问题了,最后有错误信息,本次升级的第一个问题就出现了!!!

1.3 安装gcc(升级gcc)

上述问题是应为gcc版本较低造成的,那就升级gcc。

查看了以下当前的gcc版本为4.8.5:

[root@local opt]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
[root@local opt]#

在 http://ftp.gnu.org/gnu/gcc/gcc-8.3.0/ 下载了8.3.0版本的tar包(gcc-8.3.0.tar.gz),并上传到了服务器,解压缩,进入到安装目录,执行configure命令:

./configure --prefix=/usr/local/gcc-8.3.0 --enable-threads=posix --disable-checking --enable--long-long --with-system-zlib --enable-languages=c,c++,objc,obj-c++,java

这里记得也没安装成功,报错了,具体报错信息忘记记录了,gcc目录的同级的还有gmp、mpfr、mpc,就尝试先升级他们,再进行gcc的升级。

[root@local ~]# cd /opt/gcc
[root@local gcc]# ll
total 115608
drwxr-xr-x 38 1000  1000      4096 Aug 16 23:15 gcc-8.3.0
-rw-r--r--  1 root root  114263784 Feb 22  2019 gcc-8.3.0.tar.gz
drwxr-xr-x 16 1001 wheel      4096 Aug 16 23:08 gmp-6.1.2
-rw-r--r--  1 root root    1946336 Dec 19  2016 gmp-6.1.2.tar.xz
drwxr-xr-x  7 1001  1001      4096 Aug 16 23:10 mpc-1.1.0
-rw-r--r--  1 root root     701263 Jan 11  2018 mpc-1.1.0.tar.gz
drwxr-xr-x  9 1000  1000      4096 Aug 16 23:08 mpfr-4.0.2
-rw-r--r--  1 root root    1441996 Feb  1  2019 mpfr-4.0.2.tar.xz
[root@local gcc]#

最终结果,升级失败。。。。之后的内容进行不下去因为需要通过yum安装一些依赖,但是,这个服务器yum命令无法使用,连接不上镜像,可能是网络的原因,因为时间紧急,就更换为通过rpm的方式进行安装。

1.4 rpm安装gcc相关依赖

下载了gcc的rpm包,放到了服务器/opt/gcc2文件夹下,并通过rpm命令进行安装:

[root@local ~]# cd /opt/gcc2
[root@local gcc2]#
[root@local gcc2]#
[root@local gcc2]# ll
total 47740
-rw-r--r-- 1 root root 16963328 Aug 17 01:08 gcc-4.8.5-44.el7.x86_64.mpc
-rw-r--r-- 1 root root  7531804 Aug 17 01:09 gcc-c++-4.8.5-44.el7.x86_64.rpm
-rw-r--r-- 1 root root  4466232 Aug 17 01:09 glibc-2.17-326.el7_9.i686.rpm
-rw-r--r-- 1 root root  3817244 Aug 17 01:09 glibc-2.17-326.el7_9.x86_64.rpm
-rw-r--r-- 1 root root 12059896 Aug 17 01:09 glibc-common-2.17-326.el7_9.x86_64.rpm
-rw-r--r-- 1 root root  1128524 Aug 17 01:09 glibc-devel-2.17-326.el7_9.x86_64.rpm
-rw-r--r-- 1 root root   707512 Aug 17 01:09 glibc-headers-2.17-326.el7_9.x86_64.rpm
-rw-r--r-- 1 root root   313196 Aug 17 01:09 libstdc++-4.8.5-44.el7.x86_64.rpm
-rw-r--r-- 1 root root  1581424 Aug 17 01:09 libstdc++-devel-4.8.5-44.el7.x86_64.rpm
-rw-r--r-- 1 root root   295692 Aug 17 01:09 nscd-2.17-326.el7_9.x86_64.rpm
[root@local gcc2]#
[root@local gcc2]#
[root@local gcc2]# rpm -ivh *.rpm --nodeps --force
Preparing...                          ################################# [100%]
Updating / installing...
   1:glibc-common-2.17-326.el7_9      ################################# [ 10%]
   2:glibc-2.17-326.el7_9             warning: /etc/nsswitch.conf created as /etc/nsswitch.conf.rpmnew
################################# [ 20%]
   3:libstdc++-4.8.5-44.el7           ################################# [ 30%]
   4:libstdc++-devel-4.8.5-44.el7     ################################# [ 40%]
   5:glibc-headers-2.17-326.el7_9     ################################# [ 50%]
   6:glibc-devel-2.17-326.el7_9       ################################# [ 60%]
   7:gcc-4.8.5-44.el7                 ################################# [ 70%]
   8:gcc-c++-4.8.5-44.el7             ################################# [ 80%]
   9:nscd-2.17-326.el7_9              ################################# [ 90%]
  10:glibc-2.17-326.el7_9             ################################# [100%]
[root@local gcc2]#
[root@local gcc2]#

1.5 继续安装gcc

[root@local gcc-8.3.0]#
[root@local gcc-8.3.0]# ./configure --prefix=/usr/local/gcc-8.3.0 --enable-threads=posix --disable-checking --enable--long-long --with-system-                                                                                                                                zlib --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --disable-multilib
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu

............

echo timestamp > doc/gcc.1
(pod2man --center="GNU" --release="gcc-8.3.0" --date=2019-02-22 --section=1 gcc.pod > doc/gcc.1.T$$ && \
        mv -f doc/gcc.1.T$$ doc/gcc.1) || \
        (rm -f doc/gcc.1.T$$ && exit 1)
cp doc/gcc.1 doc/g++.1
/opt/gcc-8.3.0/host-x86_64-pc-linux-gnu/gcc/xgcc -B/opt/gcc-8.3.0/host-x86_64-pc-linux-gnu/gcc/ -xc -nostdinc /dev/null -S -o /dev/null -fself-test=../.././gcc/                                                                                                                                testsuite/selftests
/opt/gcc-8.3.0/host-x86_64-pc-linux-gnu/gcc/cc1: error while loading shared libraries: libmpfr.so.6: cannot open shared object file: No such file or directory
make[3]: *** [s-selftest-c] Error 1
rm gcc.pod
make[3]: Leaving directory `/opt/gcc-8.3.0/host-x86_64-pc-linux-gnu/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/opt/gcc-8.3.0'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/opt/gcc-8.3.0'
make: *** [all] Error 2
[root@local gcc-8.3.0]#
[root@local gcc-8.3.0]#

看结果多多少少还是有些错误的,但是当时就抱着试试看的态度,再次安装了一下squid。

1.6 安装squid

[root@local squid-4.15]#
[root@local squid-4.15]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk

....................

make[1]: Entering directory `/opt/squid-4.15'
make[2]: Entering directory `/opt/squid-4.15'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/opt/squid-4.15'
make[1]: Leaving directory `/opt/squid-4.15'
[root@local squid-4.15]#

竟然看着没什么问题!!安装成功了?

查看squid版本发现命令找不到,切换成squid用户,用户不可用,查看squid用户是存在的,只是是nologin状态。

[root@local squid-4.15]# squid -v
-bash: squid: command not found
[root@local squid-4.15]#
[root@local sbin]# su - squid
Last login: Wed Aug 17 02:00:38 CST 2022 on pts/6
su: warning: cannot change directory to /var/spool/squid: No such file or directory
This account is currently not available.
[root@local sbin]#
[root@local sbin]# cat /etc/passwd
(其他用户信息就不展示了)
squid:x:23:23::/var/spool/squid:/sbin/nologin
[root@local sbin]#

先删除了squid用户,重新新建一次,用授权:

[root@local sbin]# userdel -r squid
[root@local sbin]# useradd -M -s /sbin/nologin squid
[root@local sbin]# chown -R squid.squid /usr/local/squid/var/
[root@local home]# chown -R squid:squid /home/squid/
[root@local local]# chmod -R 777 squid/

重新进入到squid的sbin目录,发现版本已经变了,升级成功

[root@local sbin]# squid -v
Squid Cache: Version 4.15
Service Name: squid
configure options:  '--prefix=/usr/local/squid' '--sysconfdir=/etc/squid' '--enable-linux-netfilter' --enable-ltdl-convenience
[root@local sbin]#

2 问题记录汇总

2.1 A compiler with support for C++11 language features is required

问题描述:这个错误信息的意思就是当前的gcc版本较低,需要安装高版本gcc编译器以支持c++11
问题原因:gcc版本较低
解决方案:升级gcc版本
解决步骤:网上有很多文章,可参考https://www.cnblogs.com/anyanpeng/p/14974537.html

2.2 configure: error: C++ preprocessor “/lib/cpp” fails sanity check

问题描述:安装gcc时出现的
问题原因:缺少必要的C++库
解决方案:安装相应的依赖库

yum install glibc-headers
yum install gcc-c++

2.3 yum命令连接镜像超时

猜测应该是因为内网的原因导致,但是之前貌似是可以的,因为时间问题,当时没有细研究,之后有时间再看看

[root@local gcc-8.3.0]# yum install squid -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml                                                                                                                                : (28, 'Resolving timed out after 30534 milliseconds')
Trying other mirror.
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/r                                                                                                                                epodata/repomd.xml: (28, 'Resolving timed out after 30531 milliseconds')
Trying other mirror.
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: (2                                                                                                                                8, 'Resolving timed out after 30532 milliseconds')
Trying other mirror.
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: (28, '                                                                                                                                Resolving timed out after 30528 milliseconds')
Trying other mirror.
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/re                                                                                                                                pomd.xml: (28, 'Resolving timed out after 30532 milliseconds')
Trying other mirror.
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: (2                                                                                                                                8, 'Resolving timed out after 30532 milliseconds')
Trying other mirror.
 Current download cancelled, interrupt (ctrl-c) again within two seconds
to exit.

http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/re                                                                                                                                pomd.xml: (28, 'Resolving timed out after 30534 milliseconds')
Trying other mirror.
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: (2                                                                                                                                8, 'Resolving timed out after 30537 milliseconds')
Trying other mirror.


 One of the configured repositories failed (CentOS-7 - Base - mirrors.aliyun.com),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=base ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable base
        or
            subscription-manager repos --disable=base

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=base.skip_if_unavailable=true

failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try.
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: (28, '                                                                                                                                Resolving timed out after 30534 milliseconds')
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/re                                                                                                                                pomd.xml: (28, 'Resolving timed out after 30531 milliseconds')
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: (2                                                                                                                                8, 'Resolving timed out after 30532 milliseconds')
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: (28, '                                                                                                                                Resolving timed out after 30528 milliseconds')
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/re                                                                                                                                pomd.xml: (28, 'Resolving timed out after 30532 milliseconds')
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: (2                                                                                                                                8, 'Resolving timed out after 30532 milliseconds')
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 15] user interrupt
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/re                                                                                                                                pomd.xml: (28, 'Resolving timed out after 30534 milliseconds')
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: (2                                                                                                                                8, 'Resolving timed out after 30537 milliseconds')
[root@local gcc-8.3.0]#
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值