Redhat7 替換Centos7 yum源

Redhat7 是 Centos7的發行版本,因版權問題在使用yum會提示需註冊(就是要花錢ing);node

咱們轉而使用Centos7源替代;python


***************************************公告***************************************shell

如下內容純我的撰寫,請勿用於商業用途,轉載請註明出處,有錯誤及疑問請留言或私信,謝謝centos

###########################僅供參考,如涉及版權,請私信###########################緩存


準備:win主機*一、Redhat最小化安裝企業版*1less


一、Xshell ssh連接redhat,並切換到root帳戶(後續按照等操做都在Xshell界面進行)ssh

#這個比較簡單,通常redhat ssh開機自啓,ps命令能直接查看
ide

Last login: Tue Nov 10 09:59:08 2015 from **********
su
Password: 
ps -e|grep ssh
 1674 ?        00:00:00 sshd
 5814 ?        00:00:00 sshd
 5818 ?        00:00:00 sshd

二、win主機打開http://mirrors.163.com/centos/7/os/x86_64/Packages/,Ctrl+F查找wget並下載到本地,直接連接:wget-1.14-10.el7_0.1.x86_64.rpmthis

三、使用WinSCP,以root登陸redhaturl

四、將下載的wget-1.14-10.el7_0.1.x86_64.rpm 傳到/tmp目錄

五、安裝wget

cd /tmp
rpm -ivh wget-1.14-10.el7_0.1.x86_64.rpm

六、卸載redhat自帶的yum

rpm -qa | grep yum | xargs rpm -e --nodeps

注:a、xargs是一條Unix和類Unix操做系統的經常使用命令。它的做用是將參數列表轉換成小塊分段傳遞給其餘命令,以免參數列表過長的問題

       b、--nodeps  強制卸載,無論依賴性

七、下載centos的yum安裝包,路徑同2,能夠直接使用下列連接

wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-125.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-29.el7.noarch.rpm

注意:安裝包都在不斷更新,請按照包名本身匹配,當前可用2015-11。

八、安裝以上下載包

rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh yum-3.4.3-125.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-29.el7.noarch.rpm

[注] :最後2個須要一塊兒安裝,不然會出現依賴性錯誤

九、下載repo文件,注意切換目錄

固然你能夠簡單點,直接將10中的repo複製,並在yum.repos.d目錄新建*******.repo文件

cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

十、編輯CentOS7-Base-163.repo文件,將其中的$releasever更改成centos的版本號7

此步驟建議下載到本機,使用記事本或notepad打開一鍵替換,再使用winscp上傳到redhat

repo參考:

# 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 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/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 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/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 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

十一、yum clean all 清除原有緩存

十二、yum makecache  獲取yum列表

出現下面提示,表示yum更改完成:

Metadata Cache Created

1三、yum repolist能夠查看源數據

yum repolist
repo id                      repo name                             status
!base/x86_64                 CentOS-7 - Base - 163.com             8,652
!extras/x86_64               CentOS-7 - Extras - 163.com           275
!updates/x86_64              CentOS-7 - Updates - 163.com          1,707
repolist: 10,634

附件:repo7

相關文章
相關標籤/搜索