redhat服務(wù)器更換為centos yum源方式
請看完全篇文章在決定是否參考該文章
1.卸載原有的yum
# 查看是有安裝了yum rpm -qa|grep yum # 卸載原有的yum rpm -qa|grep yum|xargs rpm -e --nodeps
2.找一個自己喜歡的目錄新建checkYum.sh(文件名隨意)
該文件主要是下載yum源需要的內(nèi)容并且安裝yum
#!/bin/bash # 7.9.2009 對應(yīng)的centos的版本號 wget http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm wget http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm wget http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm rpm -ivh /pkg/yum-*
3.下載響應(yīng)的repo源文件
# 建議先將該目錄下的文件進(jìn)行備份 cd /etc/yum.repos.d/CentOS-Base.repo # 該命令也可以寫到上一步的文件中一起下載 # 如果寫到文件中可以使用 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
4.修改CentOS-Base.repo文件內(nèi)容
4.1. 下載后的源文件
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus - 163.com baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
4.2. 修改后的文件
將所有的$releasever更改為自己下載.rpm文件對應(yīng)的版本
eg:
我自己:http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-3.4.3-169.el7.centos.noarch.rpm;
我這里下載的是7.9.2009的所以將$releasever更改為7.9.2009,其他的不需要更改
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-7.9.2009 - Base - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os baseurl=http://mirrors.163.com/centos/7.9.2009/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-7.9.2009 - Updates - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates baseurl=http://mirrors.163.com/centos/7.9.2009/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-7.9.2009 - Extras - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras baseurl=http://mirrors.163.com/centos/7.9.2009/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-7.9.2009 - Plus - 163.com baseurl=http://mirrors.163.com/centos/7.9.2009/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
5.更新
yum clean all && yum makecache
6.查看是否更新成功
yum repolist all
7.以上命令可以完全寫到一個統(tǒng)一shell腳本中
rpm -qa | grep yun | xargs rpm -e --nodeps wget http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm wget http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm wget http://mirrors.163.com/centos/7.9.2009/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm rpm -ivh /pkg/yum-* # 下載repo源文件 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo # 統(tǒng)一將$releasever更改為指定的版本 sed -i "s/\$releasever/7.9.2009/g" /etc/yum.repos.d/CentOS-Base.repo yum clean all && yum makecache yum repolist all
總結(jié)
以上使用的redhat版本為redhat7.5,請根據(jù)自己的版本進(jìn)行更改
這些僅為個人經(jīng)驗(yàn),希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
在VMware虛擬機(jī)里安裝Linux操作系統(tǒng)
這篇文章介紹了在VMware虛擬機(jī)里安裝Linux操作系統(tǒng)的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-03-03
阿里云OSS訪問權(quán)限配置(RAM權(quán)限控制)實(shí)現(xiàn)
這篇文章主要介紹了阿里云OSS訪問權(quán)限配置(RAM權(quán)限控制)實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08
Linux安裝Python虛擬環(huán)境virtualenv的方法
下面小編就為大家?guī)硪黄狶inux安裝Python虛擬環(huán)境virtualenv的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-01-01
使用 Linux seq 命令生成數(shù)字序列(推薦)
seq命令用于以指定增量從首數(shù)開始打印數(shù)字到尾數(shù),即產(chǎn)生從某個數(shù)到另外一個數(shù)之間的所有整數(shù),并且可以對整數(shù)的格式、寬度、分割符號進(jìn)行控制。這篇文章主要介紹了使用 Linux seq 命令生成數(shù)字序列,需要的朋友可以參考下2020-01-01
ubuntu19系統(tǒng)及以下版本安裝android studio的教程
這篇文章主要介紹了ubuntu19系統(tǒng)及以下版本安裝android studio的教程,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下2019-10-10
grub損壞,開機(jī)出現(xiàn)GRUB 2 啟動提示符的解決方法
下面小編就為大家?guī)硪黄猤rub損壞,開機(jī)出現(xiàn)GRUB 2 啟動提示符的解決方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-12-12
Linux系統(tǒng)配置網(wǎng)絡(luò)詳細(xì)介紹
大家好,本篇文章主要講的是Linux系統(tǒng)配置網(wǎng)絡(luò)詳細(xì)介紹,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽2022-01-01

