CentOS6-x到CentOS7-x的在线升级
缘起
相比Debian系的Linux发布版(如Debian、Ubuntu),都能很好地支持在线大版本升级,RedHat系的Linux发布版(如RedHat、CentOS),其大版本升级一直是为人所诟病的问题。
这种情况到了CentOS7,终于有了改观:RedHat放出了UpgradeTool,同样,CentOS自然也有了。
注意:如果已经是CentOS6.7以后的版本了,在线升级到CentOS7可能会有问题,因为CentOS6.7以后版本有些软件的版本已经比CentOS7还高了,升级可能会出问题。
具体步骤
安装软件
cat <<EOF >/etc/yum.repos.d/upgradetool.repo
[upg]
name=CentOS-$releasever - Upgrade Tool
baseurl=http://dev.centos.org/centos/6/upg/x86_64/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
EOF
yum -y install redhat-upgrade-tool \
preupgrade-assistant-contents;
升级前可行性分析
preupg -l; # 列出预升级的可用内容,多半是"CentOS6_7"
preupg -s CentOS6_7; # 这里的"CentOS6_7"是上个命令的输出
# 上面这个命令生成的报告需要看看,主要是关于升级的风险的
# 个人经验就是升级前尽量将非官方的rpm安装的软件都删掉
# 安装的第三方的rpm包越少,升级的风险越小
问题:
I/O warning : failed to load external entity "/usr/share/openscap/xsl/security-guide.xsl"
compilation error: file /usr/share/preupgrade/xsl/preup.xsl line 40 element import
xsl:import : unable to load /usr/share/openscap/xsl/security-guide.xsl
I/O warning : failed to load external entity "/usr/share/openscap/xsl/oval-report.xsl"
compilation error: file /usr/share/preupgrade/xsl/preup.xsl line 41 element import
xsl:import : unable to load /usr/share/openscap/xsl/oval-report.xsl
I/O warning : failed to load external entity "/usr/share/openscap/xsl/sce-report.xsl"
compilation error: file /usr/share/preupgrade/xsl/preup.xsl line 42 element import
xsl:import : unable to load /usr/share/openscap/xsl/sce-report.xsl
OpenSCAP Error:: Could not parse XSLT file '/usr/share/preupgrade/xsl/preup.xsl' [oscapxml.c:416]
Unable to open file /root/preupgrade/result.html
Usage: preupg [options]
preupg: error: [Errno 2] No such file or directory: '/root/preupgrade/result.html'
遇到问题那么就找原因和解决方法,通过搜索引擎搜索,找到 CentOS 官方论坛的一篇帖子,帖子中有一回复如下:
Erase the existing version of openscap (I had openscap 1.2) and install openscap-1.0.8-1.0.1 from http://dev.centos.org/centos/6/upg and redo the upgrade.
根据他的方法,把 openscap 软件包的版本降低之后,重新再安装此工具及其预升级助手:
[root@allen05ren ~]# yum erase openscap
[root@allen05ren ~]# yum install http://dev.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm
[root@allen05ren ~]# yum install redhat-upgrade-tool preupgrade-assistant-contents
重新执行 preupg -s CentOS6_7 命令: OK!
[root@allen05ren ~]# 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/10 ...finished (time 00:00s)
All changed files : 02/10 ...finished (time 00:48s)
Changed config files : 03/10 ...finished (time 00:00s)
All users : 04/10 ...finished (time 00:00s)
...
042/100 ...done (samba shared directories selinux)
043/100 ...done (CUPS Browsing/BrowsePoll configuration)
044/100 ...done (CVS Package Split)
...
|samba shared directories selinux |notapplicable |
|CUPS Browsing/BrowsePoll configuration |notapplicable |
|CVS Package Split |notapplicable |
...
---------------------
本文来自 五月七日茴香 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/you227/article/details/79140913?utm_source=copy
开始升级
rpm --import \
http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7;
centos-upgrade-tool-cli --network 7 \
--instrepo=http://vault.centos.org/centos/7.2.1511/os/x86_64/;
# 上面这个命令的--instrepo参数用的是官方的repo,
# 如果自己搭建的有repo镜像(一般都有吧),用自己的就好
# 需要注意的是,这个镜像目录下需要有文件.treeinfo
# 没有的话就去官方的位置拷贝一个下来,记得版本号要一致哟
reboot; # 最后,重启机器即可
收尾工作
机器起来后,登上服务器,需要做一些擦屁股的工作,比如,看还有没有CentOS6的软件残余,用命令:
rpm -qa | grep -i el6;
有的话要么想办法删掉,要么想办法将其升级到el7的相应的软件包。