CentOS6升级到CentOS7
前提
- 只有独立服务器,PC,本地虚拟机,XEN,KVM架构的VPS才能升级成功,OpenVZ架构的VPS无法升级,望周知。
- 所有命令均在
root
下执行!
准备工作
vim /etc/yum.repos.d/upgrade.repo
[upgrade]
name=upgrade
baseurl=http://dev.centos.org/centos/6/upg/x86_64/
enabled=1
gpgcheck=0
接下来安装官方辅助工具:
yum -y install preupgrade-assistant-contents redhat-upgrade-tool preupgrade-assistant
安装好上述工具后,执行如下命令:
preupg
看到如下截图:
输入y
,即可开始升级准备工作,接下来会看到如下画面(需等待几分钟到十几分钟,工具需要扫描所有文件)
Gathering logs used by preupgrade assistant:
All installed packages : 01/11 ...finished (time 00:00s)
All changed files : 02/11 ...finished (time 01:51s)
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)
Service statuses : 06/11 ...finished (time 00:00s)
All installed files : 07/11 ...finished (time 00:01s)
All local files : 08/11 ...finished (time 00:10s)
All executable files : 09/11 ...finished (time 00:01s)
RedHat signed packages : 10/11 ...finished (time 00:00s)
CentOS signed packages : 11/11 ...finished (time 00:00s)
Assessment of the system, running checks / SCE scripts:
001/095 ...done (Configuration Files to Review)
002/095 ...done (File Lists for Manual Migration)
003/095 ...done (Bacula Backup Software)
004/095 ...done (MySQL configuration)
...
093/095 ...done (NIS server maps check)
094/095 ...done (NIS server MAXUID and MAXGID limits check)
095/095 ...done (NIS server config file back-up)
...
Tarball with results is stored here /root/preupgrade-results/preupg_results-140731025106.tar.gz .
The latest assessment is stored in directory /root/preupgrade .
Summary information:
We found some potential in-place upgrade risks.
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 .
上面是准备工作,接下来正式开始升级工作。
升级开始
导入CentOS7的KEY
rpm --import https://mirrors.ustc.edu.cn/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7
运行升级工具
redhat-upgrade-tool --network 7.0 --instrepo https://mirrors.ustc.edu.cn/centos/7/os/x86_64/
如果提示如下:
setting up repos...
.treeinfo preupgrade-assistant has not been run.
To perform this upgrade, either run preupg or run redhat-upgrade-tool --force
那么就强制升级
redhat-upgrade-tool --network 7.0 --force --instrepo http://centos.excellmedia.net/7.0.1406/os/x86_64/
接下来跟普通的update
差不多,看到下面内容时,表示升级所需的软件包都下载完毕了。
rpm transaction 100%[==================================================================================]
rpm install 100% [=====================================================================================]
setting up system for upgrade
Finished. Reboot to start upgrade.
接下来就重启系统
reboot
接下来可以打开主机上提供的远程管理工具,vnc之类的,就可以看到如下界面了
基本上跟系统update
差不多
完成之后就看到新的系统登录界面啦
接下来验证下:
cat /etc/redhat-release
CentOS Linux release 7.0.1406 (Core)
完事!
不过,升级有风险,注意备份数据!!切记!!
原来OpenVZ不能用这种方式升级,难怪我之前升级不成功!