一、yum配置本地仓库
1、挂载光盘
[root@localhost ~]# mount /dev/sr0 /mnt/ [root@localhost ~]# df -hT 文件系统 类型 容量 已用 可用 已用% 挂载点 devtmpfs devtmpfs 966M 0 966M 0% /dev tmpfs tmpfs 983M 0 983M 0% /dev/shm tmpfs tmpfs 983M 8.7M 974M 1% /run tmpfs tmpfs 983M 0 983M 0% /sys/fs/cgroup /dev/mapper/rhel-root xfs 50G 2.0G 49G 4% / /dev/mapper/rhel-home xfs 67G 511M 67G 1% /home /dev/nvme0n1p1 xfs 1014M 156M 859M 16% /boot tmpfs tmpfs 197M 0 197M 0% /run/user/0 /dev/sr0 iso9660 7.4G 7.4G 0 100% /mnt
2、配置repo文件
[root@localhost ~]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# touch dvd.repo [root@localhost yum.repos.d]# ls dvd.repo redhat.repo [root@localhost yum.repos.d]# vim dvd.repo [BaseOS] name=baseos baseurl=file:///mnt/BaseOS gpgcheck=0 enabled=1 [AppStream] name=appstream baseurl=file:///mnt/AppStream gpgcheck=0 enabled=1
3、清理本地缓存
[root@localhost yum.repos.d]# yum clean all Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 12 文件已删除
4、建立元数据
[root@localhost yum.repos.d]# yum makecache Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. baseos 11 MB/s | 2.2 MB 00:00 appstream 30 MB/s | 5.6 MB 00:00 上次元数据过期检查:0:00:01 前,执行于 2020年08月13日 星期四 15时05分23秒。 元数据缓存已建立。
5、检测本地yum仓库
[root@localhost yum.repos.d]# yum repolist all Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 上次元数据过期检查:0:00:51 前,执行于 2020年08月13日 星期四 15时05分23秒。 仓库标识 仓库名称 状态 AppStream appstream 启用: 4,820 BaseOS baseos 启用: 1,661
6、列出本地yum仓库所有的软件包
[root@localhost yum.repos.d]# yum list all Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 上次元数据过期检查:0:03:52 前,执行于 2020年08月13日 星期四 15时05分23秒。 已安装的软件包 NetworkManager.x86_64 1:1.20.0-3.el8 @anaconda NetworkManager-libnm.x86_64 1:1.20.0-3.el8 @anaconda NetworkManager-team.x86_64 1:1.20.0-3.el8 @anaconda NetworkManager-tui.x86_64 1:1.20.0-3.el8 @anaconda PackageKit.x86_64 1.1.12-3.el8 @AppStream PackageKit-glib.x86_64 1.1.12-3.el8 @AppStream abattis-cantarell-fonts.noarch 0.0.25-4.el8 @AppStream acl.x86_64 2.2.53-1.el8 @anaconda adcli.x86_64 0.8.2-3.el8 @anaconda ..................
二、yum配置网络仓库
1、网络仓库源
- 阿里云yum仓库
- 163yum仓库
- epel源
- xx大学yum仓库
- 官方网络yum仓库(国外)
2、下载阿里云yum仓库
阿里云镜像官网:https://developer.aliyun.com/mirror
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo --2020-08-13 15:16:56-- https://mirrors.aliyun.com/repo/Centos-7.repo 正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 153.99.248.248, 218.98.31.240, 218.98.31.244, ... 正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|153.99.248.248|:443... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:2523 (2.5K) [application/octet-stream] 正在保存至: “/etc/yum.repos.d/CentOS-Base.repo” /etc/yum.repos.d/CentOS-Base.repo 100%[====================================================================================================>] 2.46K --.-KB/s 用时 0s 2020-08-13 15:16:57 (20.1 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523]) [root@localhost ~]# ls /etc/yum.repos.d/ CentOS-Base.repo dvd.repo redhat.repo
3、安装阿里云epel源
[root@localhost ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo --2020-08-13 15:20:46-- http://mirrors.aliyun.com/repo/epel-7.repo 正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 218.98.31.243, 218.98.31.241, 153.99.248.248, ... 正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|218.98.31.243|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:664 [application/octet-stream] 正在保存至: “/etc/yum.repos.d/epel.repo” /etc/yum.repos.d/epel.repo 100%[====================================================================================================>] 664 --.-KB/s 用时 0s 2020-08-13 15:20:46 (46.2 MB/s) - 已保存 “/etc/yum.repos.d/epel.repo” [664/664]) [root@localhost ~]# ls /etc/yum.repos.d/ CentOS-Base.repo dvd.repo epel.repo redhat.repo
4、安装软件官方仓库
//示例安装一个nginx官方的仓库 [root@localhost yum.repos.d]# touch nginx.repo [root@localhost yum.repos.d]# ls dvd.repo nginx.repo redhat.repo //首先创建一个rngin.epo文件 [root@localhost yum.repos.d]# vim nginx.repo [nginx] name=nginx repo baseurl=http://nginx.org/Packahges/centos/7/$basearch gpgcheck=0 enable=1 //配置nginx网络源仓库完成,接着清理缓存,建立元数据,查看nginx仓库是否启用 [root@localhost yum.repos.d]# yum clean all Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 12 文件已删除 [root@localhost yum.repos.d]# yum clean all Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 12 文件已删除 [root@localhost yum.repos.d]# yum makecache Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. baseos 101 MB/s | 2.2 MB 00:00 appstream 120 MB/s | 5.6 MB 00:00 nginx repo 52 kB/s | 73 kB 00:01 元数据缓存已建立。 [root@localhost yum.repos.d]# yum repolist all Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 上次元数据过期检查:0:00:18 前,执行于 2020年08月13日 星期四 15时27分51秒。 仓库标识 仓库名称 状态 AppStream appstream 启用: 4,820 BaseOS baseos 启用: 1,661 nginx nginx repo 启用: 162
5、下载安装base和epel仓库
[root@localhost ~]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# ls dvd.repo redhat.repo [root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo --2020-08-13 15:38:07-- https://mirrors.aliyun.com/repo/Centos-7.repo 正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 218.98.31.240, 221.6.157.215, 218.98.31.241, ... 正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|218.98.31.240|:443... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:2523 (2.5K) [application/octet-stream] 正在保存至: “/etc/yum.repos.d/CentOS-Base.repo” /etc/yum.repos.d/CentOS-Base.repo 100%[====================================================================================================>] 2.46K --.-KB/s 用时 0s 2020-08-13 15:38:07 (39.6 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523]) [root@localhost ~]# sed -i 's#$releasever#7#g' /etc/yum.repos.d/CentOS-Base.repo [root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo --2020-08-13 15:38:33-- http://mirrors.aliyun.com/repo/epel-7.repo 正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 221.6.157.214, 218.98.31.249, 218.98.31.244, ... 正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|221.6.157.214|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:664 [application/octet-stream] 正在保存至: “/etc/yum.repos.d/epel.repo” /etc/yum.repos.d/epel.repo 100%[====================================================================================================>] 664 --.-KB/s 用时 0s 2020-08-13 15:38:33 (58.1 MB/s) - 已保存 “/etc/yum.repos.d/epel.repo” [664/664]) [root@localhost yum.repos.d]# ls CentOS-Base.repo dvd.repo epel.repo redhat.repo