最近公司领导突然问有没有做过系统升级,从centos6.5到centos7.x,我想这还不简单,直接配置下yum源,yum updata 完事,不过升级中可能会有不兼容问题等。自己做了个测试,centos6.5 升级到centos7.2 ,不能直接yum update。具体操作如下。
安装升级辅助工具
配置yum源
cat > /etc/yum.repos.d/upgrade.repo << EOF [upgrade] name=upgrade baseurl=https://buildlogs.centos.org/centos/6/upg/x86_64/ enable=1 gpgcheck=0 EOF
安装辅助工具
yum install redhat-upgrade-tool preupgrade-assistant-contents -y
卸载openscap
由于centos 6.5自带的助手之一版本较高,所以需要卸载了装个更老的。
yum erase openscap -y
移走系统自带的yum源
mkdir -p /etc/yum.repos.d/repo
mv /etc/yum.repos.d/CentOS-* /etc/yum.repos.d/repo/
这样就可以使用之前配置好的yum源来安装openscap。
问题:是否可以先将系统自带的repo文件移走,直接使用我们配置好的安装?
--- 不能,因为安装辅助工具需要一些依赖包,如果移走系统自带的repo,将无法安装这些依赖。报错信息如下:
--> Processing Dependency: yum >= 3.2.29-43 for package: 1:redhat-upgrade-tool-0.7.22-3.el6.centos.noarch --> Finished Dependency Resolution Error: Package: preupgrade-assistant-1.0.2-36.0.1.el6.centos.x86_64 (upgrade) Requires: pkgconfig(libpcre) Error: Package: preupgrade-assistant-1.0.2-36.0.1.el6.centos.x86_64 (upgrade) Requires: libxslt.so.1()(64bit) Error: Package: preupgrade-assistant-1.0.2-36.0.1.el6.centos.x86_64 (upgrade) Requires: libxslt.so.1(LIBXML2_1.0.11)(64bit) Error: Package: preupgrade-assistant-1.0.2-36.0.1.el6.centos.x86_64 (upgrade) Requires: libexslt.so.0()(64bit) Error: Package: openscap-1.0.8-1.0.1.el6.centos.x86_64 (upgrade) Requires: libexslt.so.0()(64bit) Error: Package: preupgrade-assistant-1.0.2-36.0.1.el6.centos.x86_64 (upgrade) Requires: libxslt.so.1(LIBXML2_1.1.18)(64bit) Error: Package: openscap-1.0.8-1.0.1.el6.centos.x86_64 (upgrade) Requires: libxslt.so.1(LIBXML2_1.1.18)(64bit) Error: Package: openscap-1.0.8-1.0.1.el6.centos.x86_64 (upgrade) Requires: libxslt.so.1(LIBXML2_1.0.11)(64bit) Error: Package: openscap-1.0.8-1.0.1.el6.centos.x86_64 (upgrade) Requires: libxslt.so.1()(64bit) Error: Package: 1:redhat-upgrade-tool-0.7.22-3.el6.centos.noarch (upgrade) Requires: yum >= 3.2.29-43 Installed: yum-3.2.29-40.el6.centos.noarch (@anaconda-CentOS-201311272149.x86_64/6.5) yum = 3.2.29-40.el6.centos Error: Package: preupgrade-assistant-1.0.2-36.0.1.el6.centos.x86_64 (upgrade) Requires: pkgconfig(libxslt) Error: Package: preupgrade-assistant-1.0.2-36.0.1.el6.centos.x86_64 (upgrade) Requires: pkgconfig(libxml-2.0) You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest
检查
升级前检查潜在问题,执行命令:
preupg -s CentOS6_7
注意:是否可以直接升级,不检查?
--- 不建议,如果检查,执行升级命令后,会有提示,如下:
setting up repos... upgradeiso | 3.6 kB 00:00 ... upgradeiso/primary_db | 2.8 MB 00:00 ... Unable to open file /root/preupgrade/result.xml preupgrade-assistant has not been run. To perform this upgrade, either run preupg or run redhat-upgrade-tool --force
升级
在线升级建议连接国外网,国内网下载速度实在太慢。离线升级比较快,建议使用iso镜像离线升级。
在线:
centos-upgrade-tool-cli --network 7 --instrepo=
离线:
centos-upgrade-tool-cli --iso=
验证
[root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core)