Centos6.8升级到7.8的全过程(亲测好使)

 

一、    升级背景原因

公司因业务需要购买了一台工作站,预装的是win10系统,公司需要centos7.8系统,则进行系统的更改,但是在更改安装系统时无法直接安装centos7.8系统,经过多番尝试确定只能安装centos6.8系统,最后只能安装后再进行升级!

二、    升级过程

首先在安装的centos6.8系统执行yum update –y升级到6.10,再开始升级到7.2,再升级到7.8就ok啦!

1.首先下载yum源,

wget –O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

2.更新源

#vim /etc/yum.repos.d/upgrade.repo 

[upgrade]

name=upgrade

baseurl=https://buildlogs.centos.org/centos/6/upg/x86_64/

enable=1

gpgcheck=0

3. 卸载6.x自带的较新的助手,并安装老版,否则会报错。(我的版本中没有可卸载的安装包)

#yum erase openscap -y 

#以下无法连接

#yum install http://dev.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm -y   

#以下两个连接都有效

yum install ftp://ftp.pbone.net/mirror/ftp.scientificlinux.org/linux/scientific/6.5/x86_64/updates/fastbugs/openscap-1.0.8-1.el6_5.x86_64.rpm  -y   

yum install https://buildlogs.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm -y

4. 安装升级系统助手

#利用到upgrade.repo源

#yum install redhat-upgrade-tool preupgrade-assistant-contents -y  

5.检测是否可以升级

#preupg -s CentOS6_7

Preupg tool doesn't do the actual upgrade.

Please ensure you have backed up your system and/or data in the event of a failed upgrade

 that would require a full re-install of the system from installation media.

Do you want to continue? y/n

y

Gathering logs used by preupgrade assistant:

All installed packages : 01/11 ...finished (time 00:00s)

All changed files      : 02/11 ...finished (time 01:56s)

Changed config files   : 03/11 ...finished (time 00:00s)

All users              : 04/11 ...finished (time 00:00s)

All groups             : 05/11 ...finished (time 00:00s)

RedHat signed packages : 10/11 ...finished (time 00:00s)

CentOS signed packages : 11/11 ...finished (time 00:00s)

......

Tarball with results is stored here /root/preupgrade-results/preupg_results-200304120406.tar.gz .

The latest assessment is stored in directory /root/preupgrade .

Summary information:

We found some critical issues. In-place upgrade is not advised.

Read the file /root/preupgrade/result.html for more details.

Upload results to UI by command:

e.g. preupg -u http://127.0.0.1:8099/submit/ -r /root/preupgrade-results/preupg_results-*.tar.gz .

6.导入CentOS7的key

#rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7

 

7.开始升级

#尝试过多个系统版本,均无法升级。

#centos-upgrade-tool-cli --network 7 --instrepo=http://vault.centos.org/centos/7.2.1511/os/x86_64/ --force

setting up repos...

cmdline-instrepo                                                                                  

cmdline-instrepo/primary_db                                                                       

No upgrade available for the following repos: base extras updates upgrade.treeinfo                                                            

preupgrade-assistant risk check found EXTREME risks for this upgrade.

Run preupg --riskcheck --verbose to view these risks.

Continuing with this upgrade is not recommended.

 

然后使用清华大学的源就没问题了

centos-upgrade-tool-cli --network 7 --instrepo=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.2.1511/os/x86_64/ --force

 

也可以下载镜像升级,

上传Centos7.2-DVD.iso文件

执行升级操作

centos-upgrade-tool-cli  --iso=/path/centos7.2-dvd.iso  --force

结束后进行重启

setting up repos...

.treeinfo | 1.1 kB 00:00

Preupgrade assistant risk check found risks for this upgrade.

You can run preupg --riskcheck --verbose to view these risks.

Addressing high risk issues is required before the in-place upgrade

and ignoring these risks may result in a broken upgrade and unsupported upgrade.

Please backup your data.

...

...

 

(276/277): zlib-1.2.7-17.el7.x86_64.rpm | 90 kB 00:00

(277/277): zlib-devel-1.2.7-17.el7.x86_64.rpm | 50 kB 00:00

testing upgrade transaction

rpm transaction 100% [======================================================================================================================================================]

rpm install 100% [==========================================================================================================================================================]

setting up system for upgrade

Finished. Reboot to start upgrade.

 

重启后查看升级后的系统版本

cat /etc/redhat-release

#CentOS Linux release 7.2.1511 (Core)

配置Centos7.4的yum源地址(可不做)

执行升级命令即可

yum upgrade 和 yum update -y

 

三、    升级后的问题处理

档升级完重启后,发现无法进行ssh连接,

ssh: connect to host x.x.x.x port 22: Connection refused

好吧,不是还可以登录 web 的终端,接上显示器后发现网卡和yum源都不好使,登录上,看到确实升级到了 CentOS 7 了,查看 sshd 服务情况,确实服务没启动:

# systemctl status sshd

  • ● sshd.service - OpenSSH server daemon

 Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)

 Active: activating (auto-restart) (Result: exit-code) since 三 2017-03-15 15:05:33 CST; 24s ago

 Docs: man:sshd(8)

 man:sshd_config(5)

 Process: 1788 ExecStart=/usr/sbin/sshd $OPTIONS (code=exited, status=127)

 Main PID: 1696 (code=exited, status=0/SUCCESS)

 CGroup: /system.slice/sshd.service

 ├─1710 sshd: root@pts/0

 ├─1712 -bash

 └─1789 systemctl status sshd

 

3月 15 15:05:33 allen05ren systemd[1]: sshd.service: control process exited, code=exited status=127

3月 15 15:05:33 allen05ren systemd[1]: Failed to start OpenSSH server daemon.

3月 15 15:05:33 allen05ren systemd[1]: Unit sshd.service entered failed state.

3月 15 15:05:33 allen05ren systemd[1]: sshd.service failed.

那就启动一下看看,发现启动不了,那就重新安装一下 ssh 服务,发现 yum 用不了:

# yum

There was a problem importing one of the Python modules

required to run yum. The error leading to this problem was:

 

libsasl2.so.2: cannot open shared object file: No such file or directory

 

Please install a package which provides this module, or

verify that the module is installed correctly.

 

It's possible that the above module doesn't match the

current version of Python, which is:

2.7.5 (default, Nov 20 2015, 02:00:19)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]

 

If you cannot solve this problem yourself, please go to

the yum faq at:

 http://yum.baseurl.org/wiki/Faq

不行就重新安装一下 yum 看看,看看 rpm 安装了什么版本的 yum,好吧 rpm 也用不了:

# rpm -qa|grep yum

grep: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory

搜索引擎搜索,发现只要做个软连接就可以了:

# ls -l /usr/lib64/libsasl2.so*

lrwxrwxrwx 1 root root 17 3月 15 14:14 /usr/lib64/libsasl2.so -> libsasl2.so.3.0.0

lrwxrwxrwx 1 root root 17 3月 15 14:12 /usr/lib64/libsasl2.so.3 -> libsasl2.so.3.0.0

-rwxr-xr-x 1 root root 121296 11月 21 2015 /usr/lib64/libsasl2.so.3.0.0

# ln -s /usr/lib64/libsasl2.so.3.0.0 /usr/lib64/libsasl2.so.2

# yum

Loaded plugins: fastestmirror

You need to give some command

Usage: yum [options] COMMAND

 

List of Commands:

 

check Check for problems in the rpmdb

check-update Check for available package updates

clean Remove cached data

deplist List a package's dependencies

libpcre.so.0 也软连接一下,都恢复正常了:

# ls -l /usr/lib64/libpcre.so*

lrwxrwxrwx 1 root root 16 3月 15 14:13 /usr/lib64/libpcre.so -> libpcre.so.1.2.0

lrwxrwxrwx 1 root root 16 3月 15 14:12 /usr/lib64/libpcre.so.1 -> libpcre.so.1.2.0

-rwxr-xr-x 1 root root 398272 11月 20 2015 /usr/lib64/libpcre.so.1.2.0

# ln -s /usr/lib64/libpcre.so.1.2.0 /usr/lib64/libpcre.so.0

# rpm -qa|grep yum

yum-metadata-parser-1.1.4-10.el7.x86_64

yum-plugin-fastestmirror-1.1.31-34.el7.noarch

yum-3.4.3-132.el7.centos.0.1.noarch

发现再启动 ssh 服务也可以正常启动了,可以愉快地连接了。

整个升级过程差不多就告一段落了,再继续升级或做一些收尾的工作,比如上面升级时提示存在的哪些问题,然后再执行:

#查看残留的 CentOS 6.x 的文件包

rpm -qa | grep -i el6

查看一下残留的 CentOS 6.x 的文件包,不用的就卸载或卸载后重新安装 CentOS 7.x 的版本,这里就又遇到一个问题:grep 包还是 CentOS 6.x 的版本(虽然不影响使用)且版本号比当前 CentOS 7.x 的版本的版本还高,并且有大量其他包依赖此包,这时候就可以使用 yum 的软件包降版本命令:

yum downgrade grep

1

yum update 更新过程中报错

Finished Dependency Resolution

Error: Package: nettle-3.2-2.el6.x86_64 (epel)

           Requires: libgmp.so.3()(64bit)

Error: Package: gnutls-3.3.26-9.el7.x86_64 (base)

           Requires: libnettle.so.4()(64bit)

           Removing: nettle-2.7.1-4.el7.x86_64 (installed)

               libnettle.so.4()(64bit)

           Updated By: nettle-3.2-2.el6.x86_64 (epel)

              ~libnettle.so.6()(64bit)

           Available: nettle-2.7.1-8.el7.x86_64 (base)

               libnettle.so.4()(64bit)

Error: Package: gnutls-3.3.26-9.el7.x86_64 (base)

           Requires: libhogweed.so.2()(64bit)

           Removing: nettle-2.7.1-4.el7.x86_64 (installed)

               libhogweed.so.2()(64bit)

           Updated By: nettle-3.2-2.el6.x86_64 (epel)

              ~libhogweed.so.4()(64bit)

           Available: nettle-2.7.1-8.el7.x86_64 (base)

               libhogweed.so.2()(64bit)

 You could try using --skip-broken to work around the problem

** Found 28 pre-existing rpmdb problem(s), 'yum check' output follows:

cloog-ppl-0.15.7-1.2.el6.x86_64 has missing requires of libgmp.so.3()(64bit)

elfutils-libs-0.163-3.el7.x86_64 has missing requires of elfutils-libelf(x86-64) = ('0', '0.163', '3.el7')

libgcj-4.4.7-18.el6.x86_64 has missing requires of libgmp.so.3()(64bit)

libkadm5-1.10.3-65.el6.x86_64 has missing requires of krb5-libs(x86-64) = ('0', '1.10.3', '65.el6')

libkadm5-1.10.3-65.el6.x86_64 has missing requires of libkdb5.so.6()(64bit)

libkadm5-1.10.3-65.el6.x86_64 has missing requires of libkdb5.so.6(kdb5_6_MIT)(64bit)

ppl-0.10.2-11.el6.x86_64 has missing requires of libgmp.so.3()(64bit)

python-argparse-1.2.1-2.1.el6.noarch has missing requires of python(abi) = ('0', '2.6', None)

python-backports-ssl_match_hostname-3.4.0.2-5.el6.noarch has missing requires of python(abi) = ('0', '2.6', None)

python-crypto-2.6.1-2.el6.x86_64 has missing requires of libpython2.6.so.1.0()(64bit)

python-crypto-2.6.1-2.el6.x86_64 has missing requires of python(abi) = ('0', '2.6', None)

python-futures-3.0.3-1.el6.noarch has missing requires of python(abi) = ('0', '2.6', None)

python-jinja2-2.7.3-1.el6.noarch has missing requires of python(abi) = ('0', '2.6', None)

python-msgpack-0.4.6-1.el6.x86_64 has missing requires of libpython2.6.so.1.0()(64bit)

python-msgpack-0.4.6-1.el6.x86_64 has missing requires of python(abi) = ('0', '2.6', None)

python-requests-2.6.0-4.el6.noarch has missing requires of python(abi) = ('0', '2.6', None)

python-requests-2.6.0-4.el6.noarch has missing requires of python-ordereddict >= ('0', '1.1', None)

python-tornado-4.2.1-1.el6.x86_64 has missing requires of libpython2.6.so.1.0()(64bit)

python-tornado-4.2.1-1.el6.x86_64 has missing requires of python(abi) = ('0', '2.6', None)

python-urllib3-1.10.2-3.el6.noarch has missing requires of python(abi) = ('0', '2.6', None)

python-urllib3-1.10.2-3.el6.noarch has missing requires of python-ordereddict

python-zmq-14.5.0-2.el6.x86_64 has missing requires of libpython2.6.so.1.0()(64bit)

python-zmq-14.5.0-2.el6.x86_64 has missing requires of python(abi) = ('0', '2.6', None)

1:redhat-upgrade-tool-0.7.22-3.el6.centos.noarch has missing requires of preupgrade-assistant >= ('0', '1.0.2', '4')

1:redhat-upgrade-tool-0.7.22-3.el6.centos.noarch has missing requires of python(abi) = ('0', '2.6', None)

salt-2016.3.4-1.el6.noarch has missing requires of /usr/bin/python2.6

salt-2016.3.4-1.el6.noarch has missing requires of python(abi) = ('0', '2.6', None)

salt-minion-2016.3.4-1.el6.noarch has missing requires of /usr/bin/python2.6

这是由于EPEL版本不对导致的,依次执行下面的命令就好了

yum remove epel-release

yum --enablerepo=extras install epel-release

yum clean all

执行完上面的命令后有可能还会报下面的错

** Found 28 pre-existing rpmdb problem(s), 'yum check' output follows:

cloog-ppl-0.15.7-1.2.el6.x86_64 has missing requires of libgmp.so.3()(64bit)

elfutils-libs-0.163-3.el7.x86_64 has missing requires of elfutils-libelf(x86-64) = ('0', '0.163', '3.el7')

libgcj-4.4.7-18.el6.x86_64 has missing requires of libgmp.so.3()(64bit)

libkadm5-1.10.3-65.el6.x86_64 has missing requires of krb5-libs(x86-64) = ('0', '1.10.3', '65.el6')

libkadm5-1.10.3-65.el6.x86_64 has missing requires of libkdb5.so.6()(64bit)

libkadm5-1.10.3-65.el6.x86_64 has missing requires of libkdb5.so.6(kdb5_6_MIT)(64bit)

ppl-0.10.2-11.el6.x86_64 has missing requires of libgmp.so.3()(64bit)

python-argparse-1.2.1-2.1.el6.noarch has missing requires of python(abi) = ('0', '2.6', None)

python-backports-ssl_match_hostname-3.4.0.2-5.el6.noarch has missing requires of python(abi) = ('0', '2.6', None)

python-crypto-2.6.1-2.el6.x86_64 has missing requires of libpython2.6.so.1.0()(64bit)

python-crypto-2.6.1-2.el6.x86_64 has missing requires of python(abi) = ('0', '2.6', None)

python-futures-3.0.3-1.el6.noarch has missing requires of python(abi) = ('0', '2.6', None)

python-jinja2-2.7.3-1.el6.noarch has missing requires of python(abi) = ('0', '2.6', None)

python-msgpack-0.4.6-1.el6.x86_64 has missing requires of libpython2.6.so.1.0()(64bit)

python-msgpack-0.4.6-1.el6.x86_64 has missing requires of python(abi) = ('0', '2.6', None)

python-requests-2.6.0-4.el6.noarch has missing requires of python(abi) = ('0', '2.6', None)

python-requests-2.6.0-4.el6.noarch has missing requires of python-ordereddict >= ('0', '1.1', None)

python-tornado-4.2.1-1.el6.x86_64 has missing requires of libpython2.6.so.1.0()(64bit)

python-tornado-4.2.1-1.el6.x86_64 has missing requires of python(abi) = ('0', '2.6', None)

python-urllib3-1.10.2-3.el6.noarch has missing requires of python(abi) = ('0', '2.6', None)

python-urllib3-1.10.2-3.el6.noarch has missing requires of python-ordereddict

python-zmq-14.5.0-2.el6.x86_64 has missing requires of libpython2.6.so.1.0()(64bit)

python-zmq-14.5.0-2.el6.x86_64 has missing requires of python(abi) = ('0', '2.6', None)

1:redhat-upgrade-tool-0.7.22-3.el6.centos.noarch has missing requires of preupgrade-assistant >= ('0', '1.0.2', '4')

1:redhat-upgrade-tool-0.7.22-3.el6.centos.noarch has missing requires of python(abi) = ('0', '2.6', None)

salt-2016.3.4-1.el6.noarch has missing requires of /usr/bin/python2.6

salt-2016.3.4-1.el6.noarch has missing requires of python(abi) = ('0', '2.6', None)

salt-minion-2016.3.4-1.el6.noarch has missing requires of /usr/bin/python2.6

这是由于python相关的包不对导致的可以先卸载上面的python包,然后在重装就好了

#卸载python-urllib3

yum remove python-urllib3 -y

#安装python-urllib3

yum install python-urllib3 -y

我的没有这个包;

百度了一圈,有的说是安装包冲突导致的;然后卸载掉冲突的包再执行就OK啦!

比如:yum -y remove grub2-common*  openldap

注意:当卸载掉openldap后,出现了yum、sshd奔溃的问题;

yum命令后出现libldap-2.4.so.2: cannot open shared object file

# yum

There was a problem importing one of the Python modules

required to run yum. The error leading to this problem was:

 

   libldap-2.4.so.2: cannot open shared object file: No such file or directory

 

Please install a package which provides this module, or

verify that the module is installed correctly.

解决方案:

下载如下一些包(我的系统是centos7的),辛亏提前安装了wget,通外网;要不然就惨了

# wget http://ftp.pbone.net/mirror/ftp.scientificlinux.org/linux/scientific/6.4/x86_64/updates/fastbugs/openldap-2.4.23-32.el6_4.1.x86_64.rpm

# rpm -ivh --force --nodeps openldap-2.4.23-32.el6_4.1.x86_64.rpm
warning: openldap-2.4.23-32.el6_4.1.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 192a7d7d: NOKEY
Preparing...                ########################################### [100%]
   1:openldap               ########################################### [100%]

然后yum就好使了!

最后一个问题是:

网卡启动失败,但是ip地址获取正常

Failed to start LSB: Bring up/down networking.

解决方案:

造成网卡不能使用的原因是,系统后MAC地址已经更改但是在系统内部的配置文件还没有更,这就导致了真实的MAC地址与配置文件中的MAC地址不一致。

第一种办法直接关闭NetworManager

systemctl stop NetworkManager       centos7系统没启动这个服务


第二种办法修改配置文件

/etc/udev/rules.d/70-persistent-net.rules只要70-persistent-net.rules配置文件中的MAC地址与ifcfg-xxx的MAC地址相同就可以了。但是我打开70-persistent-net.rules配置文件发现配置文件全是注释,然后就直接在ifcfg-xxx文件中添加了HWADDR=MAC 对应的MAC地址。
修改完配置文件后发现还是提示错误。

vim /etc/udev/rules.d/70-persistent-net.rules            网卡中添加了也不好使


第三种办法

使用这一条命令将清除协议地址,尽然还是不管用,无奈之下重启系统,发现重启后网络服务恢复正常。

ip addr flush dev ens33/eth0      这个方法是可以成功解决问题的

Failed to start LSB: Bring up/down networking 的报错就是因为升级后真实的MAC地址与配置文件的MAC地址不相符造成的,使用以上三种办法试着解决。最后不要忘了重启系统。

四、    参考文档

https://blog.51cto.com/sky9896/2475359

https://blog.csdn.net/you227/article/details/79140913

https://www.jianshu.com/p/e44b274efb83

 

白驹过隙,当看到比你优秀的人比你还努力的时候,你也会越来越优秀,相信越努力越幸运!

posted @ 2020-09-03 11:11  阑风珊月  阅读(5444)  评论(2编辑  收藏  举报