RedHat 7.X Yum源配置

本地光盘源配置

mkdir -p /iso
mount /dev/cdrom /iso
cp -rf /etc/yum.repos.d /etc/yum.repos.d_$(date '+%Y%m%d_%H%M%S')
rm -rf /etc/yum.repos.d/*
vi /etc/yum.repos.d/local.repo
填入如下内容:

[local]
name=local
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release

清除Yum缓存
yum clean all
yum makecache
yum list

网络源:

vi /etc/yum.repos.d/local.repo
添加内容如下

[base]
name= yum repo
baseurl=http://mirrors.aliyun.com/centos/7/os/$basearch/
enabled=1
gpgcheck=0

FTP源:

vi /etc/yum.repos.d/local.repo
添加内容如下

[linux]
name=base
baseurl=http://10.10.10.10/RedHat/rhel7.5x86_64 #这是企业内部搭建的http yum服务
enabled=1
gpgcheck=0

网络历史源:

目前RedHat历史版本的源只能从归档源中获取了,另外RedHat 新版本的源没有redhat用户是用不了的。

1.首先删除redhat原有的yum ,因为redhat 原本的yum 没有注册为redhat用户是用不了的。
rpm -aq|grep yum|xargs rpm -e --nodeps
2.下载归档的yum 安装包,下面以7.6为例
wget https://vault.centos.org/7.6.1810/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget https://vault.centos.org/7.6.1810/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
wget https://vault.centos.org/7.6.1810/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
wget https://vault.centos.org/7.6.1810/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget https://vault.centos.org/7.6.1810/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
rpm -ivh python-urlgrabber-3.10-9.el7.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
vi /etc/yum.repos.d/local.repo
在文件中写入

[local]
name=local
baseurl=file:///iso
gpgcheck=1
enabled=1
gpgkey=file:///iso/RPM-GPG-KEY-redhat-release
[base]
name=CentOS-$releasever - Base
baseurl=http://linuxsoft.cern.ch/centos-vault/7.6.1810/os/$basearch/
gpgcheck=1
gpgkey=http://linuxsoft.cern.ch/centos-vault/7.6.1810/os/x86_64/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-$releasever - Updates
baseurl=http://linuxsoft.cern.ch/centos-vault/7.6.1810/updates/$basearch/
gpgcheck=1
gpgkey=http://linuxsoft.cern.ch/centos-vault/7.6.1810/os/x86_64/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-$releasever - Extras
baseurl=http://linuxsoft.cern.ch/centos-vault/7.6.1810/extras//$basearch/
gpgcheck=1
gpgkey=http://linuxsoft.cern.ch/centos-vault/7.6.1810/os/x86_64/RPM-GPG-KEY-CentOS-7
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://linuxsoft.cern.ch/centos-vault/7.6.1810/centosplus//$basearch/
gpgcheck=1
enabled=0

清除缓存并更新
yum clean all
yum update
安装epel
yum install epel-release

RedHat 8.x Ali源可以参考如下写法

[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/7.5.1804/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/7.5.1804/os/x86_64/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.aliyun.com/centos/7.5.1804/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/7.5.1804/os/x86_64/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.aliyun.com/centos/7.5.1804/extras//$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/7.5.1804/os/x86_64/RPM-GPG-KEY-CentOS-7
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.aliyun.com/centos/7.5.1804/centosplus//$basearch/
gpgcheck=1
enabled=0

你可能感兴趣的:(linux,centos,运维)