阿里云Centos6/7/8 转换为Red Hat Enterprise Linux(RHEL)6/7/8

Centos6

运行以下命令编辑CentOS-Base.repo 文件。

复制代码
vim /etc/yum.repos.d/CentOS-Base.repo 

按i进入编辑模式,修改以下内容切换源。

请根据实例不同的网络类型进行修改,具体内容如下:

复制代码
  [base]
  name=CentOS-6.10
  enabled=1
  failovermethod=priority
  baseurl=http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/os/$basearch/
  gpgcheck=1
  gpgkey=http://mirrors.cloud.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6

  [updates]
  name=CentOS-6.10
  enabled=1
  failovermethod=priority
  baseurl=http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/updates/$basearch/
  gpgcheck=1
  gpgkey=http://mirrors.cloud.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6

  [extras]
  name=CentOS-6.10
  enabled=1
  failovermethod=priority
  baseurl=http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/extras/$basearch/
  gpgcheck=1
  gpgkey=http://mirrors.cloud.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6

编辑完成后,按Esc键,并输入:wq保存退出文件。

运行以下命令编辑epel.repo 文件。

复制代码
vim /etc/yum.repos.d/epel.repo

按i进入编辑模式,修改以下内容切换源。

请根据实例不同的网络类型进行修改,具体内容如下:

复制代码
  [epel]
  name=Extra Packages for Enterprise Linux 6 - $basearch
  enabled=1
  failovermethod=priority
  baseurl=http://mirrors.cloud.aliyuncs.com/epel-archive/6/$basearch
  gpgcheck=0
  gpgkey=http://mirrors.cloud.aliyuncs.com/epel-archive/RPM-GPG-KEY-EPEL-6

编辑完成后,按Esc键,并输入:wq保存退出文件。

Centos7

运行以下命令,将Centos7 系统软件包升级到最新版本

bash 复制代码
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sudo wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

运行以下命令,更新系统软件包并重启系统。

bash 复制代码
sudo yum -y update
sudo reboot

运行以下命令,从Red Hat官方网站下载并安装convert2rhel工具。

复制代码
sudo curl -o /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release https://www.redhat.com/security/data/fd431d51.txt
sudo curl --create-dirs -o /etc/rhsm/ca/redhat-uep.pem https://ftp.redhat.com/redhat/convert2rhel/redhat-uep.pem
sudo curl -o /etc/yum.repos.d/convert2rhel.repo https://ftp.redhat.com/redhat/convert2rhel/7/convert2rhel.repo
sudo yum -y install convert2rhel

Centos 8

操作步骤

  1. 登录CentOS 8系统的ECS实例。

    具体操作,请参见连接方式概述

  2. 运行以下命令备份之前的repo文件。

    复制代码
    rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo
  3. 运行以下命令下载最新的repo文件。

    复制代码
    wget http://mirrors.cloud.aliyuncs.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo
    wget http://mirrors.cloud.aliyuncs.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo

    重要

    如果您的服务器不是ECS实例,请将命令中的源地址http://mirrors.cloud.aliyuncs.com替换为http://mirrors.aliyun.com。您也可以直接参考CentOS 镜像社区说明进行下载。

  4. 运行以下命令替换repo文件中的链接。

    复制代码
    sed -i 's/http:\/\/mirrors.cloud.aliyuncs.com/url_tmp/g'  /etc/yum.repos.d/Centos-vault-8.5.2111.repo &&  sed -i 's/http:\/\/mirrors.aliyun.com/http:\/\/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/url_tmp/http:\/\/mirrors.aliyun.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo
    sed -i 's/http:\/\/mirrors.aliyun.com/http:\/\/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repo
  5. 运行以下命令重新创建缓存。

    复制代码
    yum clean all && yum makecache

    后续步骤

    yum源和epel源切换完成后,即可使用yum install命令在实例上安装您所需要的软件包。

相关推荐
武文斌773 分钟前
计算机网络:网络基础、TCP编程
linux·网络·网络协议·tcp/ip·计算机网络
EnigmaCoder35 分钟前
【Linux】Vim编辑器:从入门到高效使用
linux·运维·编辑器·vim
我科绝伦(Huanhuan Zhou)1 小时前
Linux服务器性能优化总结
linux·服务器·性能优化
m0_571372821 小时前
关于linux软件编程9——网络编程1
linux·服务器·网络
白书宇2 小时前
12.从零开始写LINUX内核--控制台初始化
linux·c语言·驱动开发·嵌入式硬件·microsoft·iot
_童年的回忆_5 小时前
Linux下解决Git保存用户名和密码的方法
linux·运维·git
提笔惊蚂蚁10 小时前
终端VS命令解释器(Linux & Windows)
linux·运维·windows
Nimsolax11 小时前
Linux文件fd
linux
tb_first12 小时前
k8sday13数据存储(1.5/2)
linux·运维·服务器·云原生·容器·kubernetes
hzp66613 小时前
阿里云的centos8 服务器安装MySQL 8.0
mysql·阿里云·centos8