阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Red Hat Linux安装CentOS的yum源

37次阅读
没有评论

共计 4807 个字符,预计需要花费 13 分钟才能阅读完成。

导读 RedHat 凭借其卓越的稳定性和强大的服务占领着企业 linux 大部分市场,系统本身免费,但是其服务却是收费的,例如其软件包管理服务 yum。不想出钱那就自己配置 yum 源就好了,因为 yum 在线更新是收费的,未注册则不能使用,这个是要填序列号激活的,解决办法是更换为 CentOS 的 yum。
设置步骤

Red Hat Linux 安装 CentOS 的 yum 源

1. 查询原有的 yum

[root@orcl ~]# rpm -qa |grep yum 
yum-plugin-fastestmirror-1.1.30-37.el6.noarch 
yum-metadata-parser-1.1.2-16.el6.i686 
yum-utils-1.1.30-37.el6.noarch 
yum-plugin-security-1.1.30-37.el6.noarch 
yum-3.2.29-75.el6.centos.noarch 
yum-rhn-plugin-0.9.1-43.el6.noarch

2. 删除原有的 yum

[root@orcl ~]# rpm -aq|grep yum|xargs rpm -e –-nodeps 
[root@orcl ~]# rpm -qa |grep yum 
[root@orcl ~]#

3. 查询原有 yum 配置

[root@orcl ~]# whereis yum 
yum: /etc/yum 
[root@orcl ~]# rm -fr /etc/yum

4. 下载需要的安装包
http://mirrors.163.com/centos/6.8/os/i386/Packages/
系统为 32 的,所以我选择 i386。64 的自行查找 x86_64。
可以使用

wget http://mirrors.163.com/centos/6.8/os/i386/Packages/yum-3.2.29-73.el6.centos.noarch.rpm

下载

yum-3.2.29-73.el6.centos.noarch.rpm 
yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm 
yum-metadata-parser-1.1.2-16.el6.i686.rpm 
Python-iniparse-0.3.1-2.1.el6.noarch.rpm

5. 安装 python

[root@orcl ~]# rpm -ivh python-iniparse-….noarch.rpm 
warning: python-iniparse-0.4-9.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY 
error: Failed dependencies: 
python(abi) = 2.7 is needed by python-iniparse-0.4-9.el7.noarch

当前安装版本与服务器不兼容,退后一个版本再试。
查看当前发行版本号

cat /etc/issue
遇到的错误

Red Hat Linux 安装 CentOS 的 yum 源

系统位数与安装程序包位数不一致 file /bin/ls

error: Failed dependencies: 
libc.so.6()(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64 
libc.so.6(GLIBC_2.2.5)(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64 
libglib-2.0.so.0()(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64 
libpthread.so.0()(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64 
libpython2.6.so.1.0()(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64 
libsqlite3.so.0()(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64 
libxml2.so.2()(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64 
libxml2.so.2(LIBXML2_2.4.30)(64bit) is needed by yum-metadata-parser-1.1.2-16.el6.x86_64
重新下载 32 位程序包
[root@orcl ~]# rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm 
Preparing… ########################################### [100%] 
package python-iniparse-0.3.1-2.1.el6.noarch is already installed 
[root@orcl ~]# rpm -ivh yum-metadata-parser-1.1.2-16.el6.i686.rpm 
Preparing… ########################################### [100%] 
1:yum-metadata-parser ########################################### [100%] 
[root@orcl ~]# rpm -ivh yum-3.2.29-73.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm 
Preparing… ########################################### [100%] 
1:yum-plugin-fastestmirro########################################### [50%] 
2:yum ########################################### [100%] 
[root@orcl ~]#

注意最后两个包必需同时安装,否则会相互依赖
更改 yum 源(使用网易的 CentOS 镜像源)

[root@localhost yum]# cd /etc/yum.repos.d/ 
[root@localhost yum.repos.d]# rm -rf * 
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo 
[root@localhost yum.repos.d]# vi CentOS6-Base-163.repo

将所有 $releasever 修改为具体的版本号,我这里写的是 6.8,这个自己打开(http://mirrors.163.com/centos)找一下就可以。

# 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
baseurl=http://mirrors.163.com/centos/6.8/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates 
[updates]
name=CentOS-$releasever - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6.8/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6.8/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6.8/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6.8/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

清理 yum 缓存

yum clean all

显示已安程序包及可安程序包

yum list

可以按要求更新程序包或安装

yum update / yum install 包名 

到此结束了,亲们

阿里云 2 核 2G 服务器 3M 带宽 61 元 1 年,有高配

腾讯云新客低至 82 元 / 年,老客户 99 元 / 年

代金券:在阿里云专用满减优惠券

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2024-07-24发表,共计4807字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中