一、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

最新文章

  1. web api7
  2. crontab 案例
  3. iOS多线程之5.GCD的基本使用
  4. 【转】C#中将JSon数据转换成实体类,将实体类转换成Json
  5. 《MySchool数据库设计优化》内部测试
  6. Eclipse在已创建的project中导入其他文件
  7. iptables 基础知识
  8. 图像金字塔及其在 OpenCV 中的应用范例(上)
  9. C#textbox右击弹出菜单
  10. 5个让DBA爱上你的SQL技巧
  11. scp 对拷文件夹 和 文件夹下的所有文件 对拷文件并重命名
  12. java基础之String
  13. Ubuntu13.04 Eclipse下编译安装Hadoop插件及使用小例
  14. salesforce 零基础学习(六十六)VF页面应善于使用变量和函数(二)常用函数的使用
  15. ES6字符串方法
  16. UCS业务知识介绍
  17. 数据挖掘进阶之序列模式挖掘GSP算法
  18. Flask 之东方不败一
  19. Boolean.getBoolean用法
  20. Python遍历一个文件夹下有几个Excel文件及每个Excel文件有几个Sheet

热门文章

  1. Android创建自定义Application
  2. 二、python学习-函数
  3. Spring Boot 2.4 新特性,全新的Cron表达式处理机制
  4. 关gzip压缩,我有新发现
  5. 2-69.x的平方根
  6. 1087 All Roads Lead to Rome
  7. hdu4284 dfs+floyd
  8. hdu4179 限制最短路
  9. Python小程序 -- 人民币小写转大写辅助工具
  10. DVWA之File Inclusion