首页 > 系统相关 >Linux:CentOS7-yum仓库本地源和网络源配置(完整版)

Linux:CentOS7-yum仓库本地源和网络源配置(完整版)

时间:2022-11-30 21:15:23浏览次数:40  
标签:repo CentOS mirrors bravooss CentOS7 yum 完整版 com

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

相关文章

  • CentOS7 安装 cri-o 运行时的 Kubernetes
    1.环境系统:CentOSLinuxrelease7.7.1908(Core)Kubernetes:1.25.4Cri-o:1.252.安装crio根据官方文档:curl-L-o/etc/yum.repos.d/devel:kubic:libcontainers:......
  • 完整版代码(亲测可用),给网站加上访客统计—你是第位访客
    完整版代码(亲测可用),给网站加上访客统计—你是第位访客一般我们看见一些网站下放都有"第几位访客"的记数,那个代码是什么呢?如果要在网站源代码中修改,插入是在什么位置呢?下......
  • centos7安装redis
    安装依赖yuminstall-ygccyum-yinstallcentos-release-sclyum-yinstalldevtoolset-9-gccdevtoolset-9-gcc-c++devtoolset-9-binutilssclenabledevtoolse......
  • 练习_(if、case)多系统配置yum源
    #!/usr/bash/binyum_server=192.168.201.130os_version=`cat/etc/redhat-release|awk'{print$4}'|awk-F"."'{print$1"."$2}'`[-d/etc/yum.repos.d]||mk......
  • Linux 系统 yum更换源
    操作步骤1、yum源进行备份进入到yum源的配置文件中执行命令如下:cd/etc/yum.repos.d将yum源进行备份:mvCentos-Base.repoCentos-Base.repo.bak2、获取阿里的yum源配......
  • Centos7 搭建单机Spark分布式集群
    (目录)1.JDKHadoopSpark安装与配置1.1解压包官网下载jdk、hadoop、sprak对应的包,注意版本tar-zxvfjdk-8u241-linux-x64.tar.gztar-zxvfhadoop-3.2.2.tar.gz ......
  • 如何在yum.conf配置文件中指定自定义的yum库文件目录?
    使用自定义的yum库文件,方法非常的简单,只需2个步骤:1、创建自定义yum源目录2、修改yum.conf配置文件 具体的操作如下:1、创建yum源目录 mkdir-p/etc/yum.......
  • centos7 升级 openssh (用来避坑)
    是的,踩坑了,导致服务器远程登录不上去,最后只能想其他办法了。所以有必要记下来具体的操作。环境centos7.9,自带的openssh为7.4,准备升级到7.9p1.编译openssh先编......
  • centos8 安装svn(yum)
    1、安装yuminstallsubversion  2、查看版本svnserve--version 3、创建库mkdir/var/svnsvnadmincreate/var/svn/test4、......
  • centos7 docker离线安装教程
    离线安装包下载docker离线安装时需要两个安装包:selinux包、docker包,下载地址:https://download.docker.com/linux/centos/7/x86_64/stable/Packages/selinux包下载https:/......