CentOS 6 升级到 7
有些教程会让你将 CentOS 6 更新到最新,我不建议这么做。这么做会导致后续升级的时候有些包无法升级到 7;因为,6 下面该包的版本比 7 下面该包的版本还要高,从而无法自动对该包进行升级。
添加 upgradetool 源
cat <<EOF >/etc/yum.repos.d/upgradetool.repo [upgrade] name=CentOS-$releasever - Upgrade Tool baseurl=https://buildlogs.centos.org/centos/6/upg/x86_64/ gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 EOF
很多网上教程都是 dev.centos.org 这个域名,但现在这个域名已经不能用了,改成了 buildlogs.centos.org。
安装升级工具
yum erase openscp yum install -y https://buildlogs.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm yum install -y redhat-upgrade-tool preupgrade-assistant-contents
注意,这里要指定 URL 安装下 openscp;否则,自动安装的最新版 openscp 会导致以下错误:[1]
096/096 ...done (NIS server config file back-up) Assessment finished (time 184:41s) 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'
进行升级可行性分析。这一步会比较耗时,如果装的东西多,可能要两三个小时。
preupg
如果没有紧要的错误,就可以开始升级了。升级的话,不能升级到最新版本。如果尝试升级到最新版本,会有以下错误提示。自动升级工具支持升级到 7.2。[2]
setting up repos... No upgrade available for the following repos: base extras updates .treeinfo | 353 B 00:00 getting boot images... Downloading failed: invalid data in .treeinfo: No section: 'checksums'
导入 key
rpm --import https://mirrors.aliyun.com/centos-vault/7.2.1511/os/x86_64/RPM-GPG-KEY-CentOS-7
执行升级命令。
centos-upgrade-tool-cli --network 7 --instrepo=https://mirrors.aliyun.com/centos-vault/7.2.1511/os/x86_64/
如果升级程序检测到升级存在风险,则会有以下提示。
setting up repos... No upgrade available for the following repos: base extras updates .treeinfo | 354 B 00:00 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.
如果检查之后,觉得这些风险可以承受,可以加上 –force 强制升级。另外,在 riskcheck 报告里,有提示说可以加 –cleanup-post 选项,把无法升级的包自动清除掉;这里建议不要加该选项,自动升级程序并不能很好的把所有库及程序替换好,因此,还存在使用就库的情况;如果把旧库都清理掉,就会导致有些功能不能用;例如,无法上网,无法使用 yum 等。
centos-upgrade-tool-cli --network 7 --force --instrepo=https://mirrors.aliyun.com/centos-vault/7.2.1511/os/x86_64/
如果尝试了升级到最新版本,再来升级到 7.2,会出现类似以下错误:
Downloading failed: failure: repodata/6882feea31727f25dc12063b4bab119501d25dbf6cb6fa0f5b78b8e3d5401ea4-filelists.sqlite.bz2 from cmdline-instrepo: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
需要执行升级清理,再升级。
centos-upgrade-tool-cli --clean
最后升级后有各种问题,没能解决。放弃了。