一、RHEL8/CentOS8配置本地yum源
1. 挂载光盘镜像配置本地yum源 先移走系统默认的repo文件 cd /etc/yum.repos.d/ mkdir repobak mv *.repo repobak/ 2. 挂载本地光盘镜像 mkdir /mnt/cdrom mount -t iso9660 /soft/rhel-8.2-x86_64-dvd.iso /mnt/cdrom 3. 编辑本地yum源repo文件 vi CentOS-LocalMedia.repo [local-BaseOS] name=CentOS-BaseOS baseurl=file:///mnt/cdrom/BaseOS gpgcheck=0 enabled=1 [local-AppStream] name=CentOS-AppStream baseurl=file:///mnt/cdrom/AppStream gpgcheck=0 enabled=1 4. 生成本地缓存和测试 dnf clean all dnf makecache
dnf install iotop -y
二、RHEL8/CentOS8配置网络yum源
1. 阿里云yum源 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo 或者 curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo 2. 阿里云epel yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm sed -i 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel* sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel* 4. fedora yum源(代替阿里云) yum install -y https://download-ib01.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/e/epel-release-8-9.el8.noarch.rpm 3. 生成缓存和测试 yum makecache yum search bashtop
三、RHEL7/CentOS7 配置本地yum源
1. 挂载DVD mount -t iso9660 /soft/CentOS-7-x86_64-DVD-1804.iso /mnt/cdrom/ 2. 禁用网络yum源 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak 3. vi CentOS-Media.repo [centos-local] name=CentOS-$releasever - Media baseurl=file:///mnt/cdrom/ gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 4. yum加载源 yum clean all
四、RHEL7/CentOS7 配置网络yum源(如果有最新的可以去网页目录检查)
1. yum安装 yum install -y https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-13.noarch.rpm 2. 测试 yum makecache yum install bashtop
五、阿里云镜像站
https://developer.aliyun.com/mirror/?spm=a2c6h.13651104.0.d1002.2cfe3730uq1zwk