1 配置环境介绍
本篇文章介绍配置yum仓库使用本地源和网络源的详细过程,整个过程的代码将会贴出,经过测试可按此过程成功配置在我的Linux系统上使用。
虚拟机Linux:centOS 7.8 2003
2 本地源配置
步骤一:在centos[虚拟机](https://so.csdn.net/so/search?q=虚拟机&spm=1001.2101.3001.7020)中挂载光盘mount /dev/cdrom /mnt
步骤二:创建并更改配置文件
[fancy]这里随意
name=baravo_repo 这里随意
baseurl=file:///mnt/
gpgcheck=0
enabled=1
步骤三:检查配置情况
yum repolist all
出现我们的配置文件名,表示配置成功,接下来可以开始软件运行环境安装所对应rpm包的下载(yum install
命令)
过程记录:
Xshell 5 (Build 0655)
Copyright (c) 2002-2015 NetSarang Computer, Inc. All rights reserved.
Type `help' to learn how to use Xshell prompt.
[c:\~]$
Connecting to 192.168.16.227:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Last login: Thu Nov 24 10:25:58 2022
[root@bravooss ~]# ls /mnt
[root@bravooss ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@bravooss ~]# ls /mnt
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
[root@bravooss ~]# df -hT /mnt
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sr0 iso9660 4.5G 4.5G 0 100% /mnt
[root@bravooss ~]# cd /etc/yum.repos.d/
[root@bravooss yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo CentOS-x86_64-kernel.repo
[root@bravooss yum.repos.d]# rm -rf *
[root@bravooss yum.repos.d]# ls
[root@bravooss yum.repos.d]# vim bravo.repo
[root@bravooss yum.repos.d]# cat bravo.repo
[fancy]
name=baravo_repo
baseurl=file:///mnt/
gpgcheck=0
enabled=1
[root@bravooss yum.repos.d]# yum repolist all
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
fancy | 3.6 kB 00:00:00
(1/2): fancy/group_gz | 153 kB 00:00:00
(2/2): fancy/primary_db | 3.3 MB 00:00:00
源标识 源名称 状态
fancy baravo_repo 启用: 4,071
repolist: 4,071
[root@bravooss yum.repos.d]#
以上就完成了本地源的配置
3 转为网络源配置
由于本地源yum包较少,影响后续配置,我们需要继续配置yum网络源。
这里直接上代码
[root@bravooss yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2022-11-30 14:43:27-- https://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 119.96.90.239, 119.96.90.237, 119.96.90.243, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|119.96.90.239|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
100%[==============================================================================>] 2,523 --.-K/s 用时 0.008s
2022-11-30 14:43:27 (316 KB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])
[root@bravooss yum.repos.d]# ls
bak bravo.repo CentOS-Base.repo
[root@bravooss yum.repos.d]# vim CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/7/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/7/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/7/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/7/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/7/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
[root@bravooss yum.repos.d]# # 使用全局替换命令,将该文件中$releasever全部改成7
[root@bravooss yum.repos.d]# # :%s/$releasever/7/g
[root@bravooss yum.repos.d]# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: base extras fanncy updates
Cleaning up list of fastest mirrors
Other repos take up 19 M of disk space (use --verbose for details)
[root@bravooss yum.repos.d]# yum makecache
等待安装,出现“元数据缓已建立”说明生成成功。
以上就完成了yum仓库本地源转网络源的过程。
标签:repo,CentOS,mirrors,bravooss,CentOS7,yum,完整版,com From: https://www.cnblogs.com/fancy2022/p/16939735.html