RedHat Yum & Yum Update & EPEL

yum install epel-release

Redhat Linux通常由于没有注册,导致yum程序无法使用,需要将其替换为centos的yum程序。

1. 下载Yum的安装包,由于体系结构的不同和包的更新,因此目录和文件名的版本号可能需要调整以下。

#wget http://centos.ustc.edu.cn/centos/5/os/{i386|x86_64}/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm
#wget http://centos.ustc.edu.cn/centos/5/os/{i386|x86_64}/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.1.noarch.rpm
#wget http://centos.ustc.edu.cn/centos/5/os/{i386|x86_64}/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm

2. 查出当前的yum程序,进行卸载

#rpm -qa|grep yum
# rpm -e yum-3.2.22-20.el5 --nodeps
# rpm -e yum-updatesd-0.9-2.el5 --nodeps
# rpm -e yum-security-1.1.16-13.el5 --nodeps
# rpm -e yum-metadata-parser-1.1.2-3.el5 --nodeps
# rpm -e yum-rhn-plugin-0.5.4-13.el5 --nodeps

3. 下载并导入KEY
# cd /etc/pki/rpm-gpg/
# wget http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*

4. 安装yum安装包
rpm -ivh yum-3.2.22-39.el5.centos.noarch.rpm \
yum-fastestmirror-1.1.16-21.el5.centos.1.noarch.rpm \
yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm

5. 修改配置文件

Vi /etc/yum.repos.d/rhel-debuginfo.repo

[base]
name=Red Hat Enterprise Linux $releasever -Base
baseurl=http://mirrors.sohu.com/centos/5.5/os/$basearch/
gpgcheck=1

[update]
name=Red Hat Enterprise Linux $releasever -Updates
baseurl=http://mirrors.sohu.com/centos/5.5/updates/$basearch/
gpgcheck=1

[extras]
name=Red Hat Enterprise Linux $releasever -Extras
baseurl=http://mirrors.sohu.com/centos/5.5/extras/$basearch/
gpgcheck=1

[addons]
name=Red Hat Enterprise Linux $releasever -Addons
baseurl=http://mirrors.sohu.com/centos/5.5/addons/$basearch/
gpgcheck=1

至此yum安装完成,可以 yum install 安装程序

###########################################

CentOS 7 repo

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

yum clean all
yum makecache

######################################

yum update

RedHat/CentOS/Fedora使用  yum update  更新时默认会都会升级内核,比如从CENTOS6.8升级到CENTOS6.9,结果可能导致php5.2等无法使用;有些服务器硬件(特别是组装的机器)在升级内核后,新的内核可能也会认不出某些硬件,要重新安装驱动,很麻烦。所以在生产环境中不要轻易的升级内核,除非你确定升级内核后不会出现麻烦的问题。

不升级内核方法:

在 /etc/yum.conf 的 [main] 后面添加以下配置即可!

exclude=kernel*
exclude=centos-release*

#################################

EPEL

-bit.edu.cn
rpm -ivh http://mirror.bit.edu.cn/fedora/epel/epel-release-latest-6.noarch.rpm
rpm -ivh http://mirror.bit.edu.cn/fedora/epel/epel-release-latest-7.noarch.rpm
yum repolist

-官方源直接安装

CentOS/RHEL 5:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm

CentOS/RHEL 6:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

CentOS/RHEL 7:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

-手动阿里安装
1、备份(如有配置其他epel源)
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup

2、下载新repo 到/etc/yum.repos.d/

epel(RHEL 7)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

epel(RHEL 6)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

epel(RHEL 5)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo

此条目发表在linux分类目录,贴了, 标签。将固定链接加入收藏夹。