阿里云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命令在实例上安装您所需要的软件包。

相关推荐
jason.zeng@15022074 分钟前
centos中安装redis
linux·redis·centos
w236173460133 分钟前
Linux 服务器安全巡检与加固:从命令到实操(CentOS/Ubuntu 通用)
linux·服务器·安全·安全加固·安全巡检
TG_yunshuguoji1 小时前
阿里云云代理商:阿里云CDN刷新机制是什么?
服务器·阿里云·云计算
xiaogg36781 小时前
阿里云k8s1.33部署yaml和dockerfile配置文件
java·linux·kubernetes
python百炼成钢1 小时前
3.Linux 网络相关
linux·运维·网络·stm32·单片机
-指短琴长-4 小时前
Namespace隔离实战【Linux】
linux
心灵宝贝5 小时前
申威(sw_64)架构下如何安装java-1.8.0-swjdk的rpm包?
linux·运维·服务器
好记忆不如烂笔头abc5 小时前
linux系统记录登录用户的所有操作
java·linux·服务器
远向光5 小时前
k8s中的控制器
linux·容器·kubernetes
tan180°5 小时前
Linux网络HTTP(中)(8)
linux·网络·http