阿里云SMC迁移RedHat/CentOS 5 内核升级
1. 起因
服务器需要迁移上阿里云,有几台服务器用的是Redhat 5.x,在使用SMC进行迁移时出现以下报错.
bash
[2023-12-13 09:50:55] [Error] Check System Info Failed, code=S16_111, msg=Get OS Info Failed: [error] grub is too old for CentOS/Red Hat 5, please upgrade to grub 1.99 or higher. FAILED
[2023-12-13 09:50:55] [Warn] Goto Aliyun Not Finished! See Details Info In Log File [/root/smc/go2aliyun_client2.7.3_linux_x86_64/Logs/go2aliyun_client_20231213.log].
Get More Help From Online Docs:
(Chinese) https://help.aliyun.com/product/121538.html
(International) https://www.alibabacloud.com/help/product/121538.htm
You Can Try Again After The Problem Is Solved.
Exit...
根据报错内容显然是由于我们的grub版本低于1.99,看来是要升级grub
查看了下阿里的手册,同样需要将Kernel升级到2.6.18-398
看下我们现在的版本
bash
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.8 (Tikanga)
[root@localhost ~]# grub --version
grub (GNU GRUB 0.97)
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.18-308.el5 #1 SMP Fri Jan 27 17:17:51 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
名称 | 现在版本 | 升级后版本 |
---|---|---|
grub | 0.97 | 1.99 |
Kernel | 2.6.18-308 | 2.6.18-398 |
flex | 无 | 2.6.4 |
2. 升级
2.1 下载需要的补丁包
bash
mkdir /root/smc
cd /root/smc
依次下载以下4个软件,并上传到服务器/root/smc目录.rhel5的openssl版本过低直接wget会报错.
Kernel补丁包
bash
https://vault.centos.org/5.11/os/x86_64/CentOS/kernel-2.6.18-398.el5.x86_64.rpm
flex安装包
bash
https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz
grub安装包
bash
https://alpha.gnu.org/gnu/grub/grub-2.02~rc1.tar.gz
阿里SMC
bash
https://p2v-tools.oss-cn-hangzhou.aliyuncs.com/smc/go2aliyun_client_linux_x86_64.tar.gz?spm=5176.smc-next_import-source-server.0.0.2fcd18e6KUtfYE&file=go2aliyun_client_linux_x86_64.tar.gz
此时/root/smc目录下有4个文件
2.2 升级Kernel
bash
rpm -ivh ./kernel-2.6.18-398.el5.x86_64.rpm
2.3 安装flex
- 备份grub文件,报错忽略
bash
mv /sbin/grub /sbin/grub-old
mv /sbin/grub-install /sbin/grub-install-old
mv /sbin/grub-mkconfig /sbin/grub-mkconfig-old
- 安装依赖包
bash
yum install -y bison gcc make
- 安装flex
bash
tar xzf flex-2.6.4.tar.gz
cd flex-2.6.4
./configure
make -j4 && make install
如果返回0那么就继续,否则检查下报错
- 创建软连接
bash
ln -s /usr/local/bin/flex /usr/bin/flex
2.4 安装grub
- 编译安装grub
bash
cd ..
tar xzf grub-2.02_rc1.tar.gz
cd grub-2.02~rc1/
./configure
sed -i -e "s/-Werror//" ./grub-core/Makefile
sed -i -e "s/-Werror//" ./Makefile
make && make install
- 创建软连接
bash
ln -s /usr/local/sbin/grub-install /sbin/grub-install
ln -s /usr/local/sbin/grub-mkconfig /sbin/grub-mkconfig
- 确认grub是否安装成功
bash
grub-install --version
3. 修改启动配置
- 检查grub配置
bash
grub-mkconfig -o /boot/grub/grub.cfg
grub-install --no-floppy --modules=part_msdos --boot-directory=/boot /dev/sda
- 查看内核启动项列表
bash
grep menuentry /boot/grub/grub.cfg
确认3处红框内容和截图一致
写入grub重启选择,如果不在这个位置将0改为1,2,3...其他次序的数字
bash
mkdir -p /usr/local/etc/default/
echo "GRUB_DEFAULT=0" > /usr/local/etc/default/grub
- 重启
bash
reboot
- 重启后确认
4. 确认smc
bash
cd smc/
tar xf go2aliyun_client_linux_x86_64.tar.gz
cd go2aliyun_client2.7.3_linux_x86_64/
chmod +x go2aliyun_client
./go2aliyun_client
迁移任务就正常开始了
至此阿里云SMC迁移RedHat/CentOS 5 内核升级完成