Redhat7 更换Centos 7 yum源

准备:win主机*1、Redhat最小化安装企业版*1


1、Xshell ssh链接redhat,并切换到root账户(后续按照等操作都在Xshell界面进行)

#这个比较简单,一般redhat ssh开机自启,ps命令能直接查看

1
2
3
4
5
6
7
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

2、win主机打开http://mirrors.163.com/centos/7/os/x86_64/Packages/,Ctrl+F查找wget并下载到本地,直接链接:wget-1.14-10.el7_0.1.x86_64.rpm

3、使用WinSCP,以root登录redhat

4、将下载的wget-1.14-10.el7_0.1.x86_64.rpm 传到/tmp目录

5、安装wget

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

6、卸载redhat自带的yum

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

注:a、xargs是一条Unix和类Unix操作系统的常用命令。它的作用是将参数列表转换成小块分段传递给其他命令,以避免参数列表过长的问题

       b、--nodeps  强制卸载,不管依赖性

7、下载centos的yum安装包,路径同2,可以直接使用下列链接

需要下载python-urlgrabber-3.10-8.el7.noarch.rpm

卸载原先的python-urlgrabber-3.10-4.el7.noarch.rpm

1
2
3
4
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。

8、安装以上下载包

1
2
3
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个需要一起安装,否则会出现依赖性错误

9、下载repo文件,注意切换目录

当然你可以简单点,直接将10中的repo复制,并在yum.repos.d目录新建*******.repo文件

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

10、编辑CentOS7-Base-163.repo文件,将其中的$releasever更改为centos的版本号7

此步骤建议下载到本机,使用记事本或notepad打开一键替换,再使用winscp上传到redhat

repo参考:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 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

11、yum clean all 清除原有缓存

12、yum makecache  获取yum列表

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

Metadata Cache Created

13、yum repolist可以查看源数据

1
2
3
4
5
6
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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值