centos7 本地yum源_centos6更换为阿里源

centos7 本地yum源_centos6更换为阿里源一、centos7配置yum源yum源分为本地yum源和网络yum源1、配置本地yum源步骤一:在centos虚拟机中挂载光盘1.创建挂载点目录[root@localhost~]#mkdir/mnt/cdrom[root@localhost~]#df/mnt/cdrom文件系统1K-块已用可用已用%挂载点/dev/sda33951733677184163179892020%/2.挂载光盘[root@loc

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

一、centos7配置yum源

yum源分为本地yum源和网络yum源

1、配置本地yum源

步骤一:在centos虚拟机中挂载光盘

1.创建挂载点目录

[root@localhost ~]# mkdir /mnt/cdrom
[root@localhost ~]# df /mnt/cdrom
文件系统          1K-块    已用     可用 已用% 挂载点
/dev/sda3      39517336 7718416 31798920   20% /

2.挂载光盘

[root@localhost ~]# mount /dev/cdrom /mnt/cdrom
mount: /dev/sr0 写保护,将以只读方式挂载

3.查看挂载记录

[root@localhost ~]# df -hT /mnt/cdrom
文件系统       类型     容量  已用  可用 已用% 挂载点
/dev/sr0       iso9660  4.3G  4.3G     0  100% /mnt/cdrom

步骤二:更改配置文件

1.进入/etc/yum.repos.d/中查看文件

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll
总用量 28
-rw-r--r--. 1 root root 1664 8月  30 2017 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 8月  30 2017 CentOS-CR.repo
-rw-r--r--. 1 root root  649 8月  30 2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 8月  30 2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 8月  30 2017 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 8月  30 2017 CentOS-Sources.repo
-rw-r--r--. 1 root root 3830 8月  30 2017 CentOS-Vault.repo

2.将CentOS-Base.repo和CentOS-Debuginfo.repo改名或者移动,绕过网络安装,以便使用本地安装

#本次使用改名 方便作为备份文件
[root@localhost yum.repos.d]# mv CentOS-Debuginfo.repo CentOS-Debuginfo.repo.bak
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak

3.编辑文件CentOS-Media.repo(使用vim编辑器)

[root@localhost yum.repos.d]# vim CentOS-Media.repo
# CentOS-Media.repo
#
# This repo can be used with mounted DVD media, verify the mount point for
# CentOS-7. You can use this repo and yum to install items directly off the
# DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c7-media [command]
# 
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c7-media [command]

[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/cdrom
gpgcheck=0		#用来检查GPG-KEY,0为不检查,1为检查
enabled=1		#是否用该yum源,0为禁用,1为使用
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

~                                                                               
~                                                                               
~                                                                               
"CentOS-Media.repo" 20L, 563C                                 17,1         全部

4.清除yum缓存,测试yum源配置

清除yum缓存

[root@localhost yum.repos.d]# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: c7-media
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors

测试

[root@localhost yum.repos.d]# yum list
已加载插件:fastestmirror, langpacks
c7-media                                                 | 3.6 kB     00:00     
(1/2): c7-media/group_gz                                   | 156 kB   00:00     
(2/2): c7-media/primary_db                                 | 3.1 MB   00:00     
Determining fastest mirrors
已安装的软件包
GConf2.x86_64                           3.2.6-8.el7                    @anaconda
GeoIP.x86_64                            1.5.0-11.el7                   @anaconda
ModemManager.x86_64                     1.6.0-2.el7                    @anaconda
ModemManager-glib.x86_64                1.6.0-2.el7                    @anaconda
NetworkManager.x86_64                   1:1.8.0-9.el7                  @anaconda
NetworkManager-adsl.x86_64              1:1.8.0-9.el7                  @anaconda
NetworkManager-glib.x86_64              1:1.8.0-9.el7                  @anaconda
NetworkManager-libnm.x86_64             1:1.8.0-9.el7                  @anaconda
NetworkManager-libreswan.x86_64         1.2.4-2.el7                    @anaconda
NetworkManager-libreswan-gnome.x86_64   1.2.4-2.el7                    @anaconda
NetworkManager-ppp.x86_64               1:1.8.0-9.el7                  @anaconda

出现已安装的软件包时,便成功配置了

2、配置网络yum源

步骤一:备份

1)进入/etc/yum.repos.d 查看目录下文件

[root@localhost yum.repos.d]# ll
总用量 28
-rw-r--r--. 1 root root 1664 8月  30 2017 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 1309 8月  30 2017 CentOS-CR.repo
-rw-r--r--. 1 root root  649 8月  30 2017 CentOS-Debuginfo.repo.bak
-rw-r--r--. 1 root root  314 8月  30 2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  563 3月  18 19:37 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 8月  30 2017 CentOS-Sources.repo
-rw-r--r--. 1 root root 3830 8月  30 2017 CentOS-Vault.repo

2)将所有文件备份到新建目录repo_bak下

[root@localhost yum.repos.d]# mkdir repo_bak
[root@localhost yum.repos.d]# mv *.repo repo_bak/
[root@localhost yum.repos.d]# mv *.repo.bak repo_bak/
[root@localhost yum.repos.d]# ll
总用量 0
drwxr-xr-x. 2 root root 195 3月  18 23:13 repo_bak

步骤二:下载阿里的CentOS-Base.repo 到/etc/yum.repos.d/

1)下载文件

[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0  15876      0 --:--:-- --:--:-- --:--:-- 15968
#查看文件是否下载完成
[root@localhost yum.repos.d]# ll
总用量 4
-rw-r--r--. 1 root root 2523 3月  18 23:16 CentOS-Base.repo
drwxr-xr-x. 2 root root  195 3月  18 23:13 repo_bak

2)运行yum clean all 清除缓存,运行 yum makecache 生成新的缓存

[root@localhost yum.repos.d]# yum clean all #清空缓存
已加载插件:fastestmirror, langpacks
正在清理软件源: base extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@localhost yum.repos.d]# yum makecache #生成新的缓存 
已加载插件:fastestmirror, langpacks
^Chttp://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#56 - "Callback aborted"
正在尝试其它镜像。
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; 未知的名称或服务"
正在尝试其它镜像。
base                                                            | 3.6 kB  00:00:00     
extras                                                          | 2.9 kB  00:00:00     
updates                                                         | 2.9 kB  00:00:00     
(1/10): base/7/x86_64/group_gz                                  | 153 kB  00:00:00     
(2/10): base/7/x86_64/primary_db                                | 6.1 MB  00:00:03     
(3/10): extras/7/x86_64/filelists_db                            | 226 kB  00:00:00     
(4/10): extras/7/x86_64/other_db                                | 134 kB  00:00:00     
(5/10): extras/7/x86_64/primary_db                              | 225 kB  00:00:00     
(6/10): base/7/x86_64/filelists_db                              | 7.2 MB  00:00:05     
(7/10): base/7/x86_64/other_db                                  | 2.6 MB  00:00:01     
(8/10): updates/7/x86_64/filelists_db                           | 3.9 MB  00:00:02     
(9/10): updates/7/x86_64/other_db                               | 516 kB  00:00:00     
(10/10): updates/7/x86_64/primary_db                            | 6.5 MB  00:00:03     
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
元数据缓存已建立

元数据缓已建立说明生成成功

步骤三:安装EPEL源

1)

[root@localhost yum.repos.d]# yum list | grep epel-release
epel-release.noarch                         7-11                       extras   
[root@localhost yum.repos.d]# yum install -y epel-release
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 epel-release.noarch.0.7-11 将被 安装
--> 解决依赖关系完成

依赖关系解决

=======================================================================================
 Package                  架构               版本             源                  大小
=======================================================================================
正在安装:
 epel-release             noarch             7-11             extras              15 k

事务概要
=======================================================================================
安装  1 软件包

总下载量:15 k
安装大小:24 k
Downloading packages:
epel-release-7-11.noarch.rpm                                    |  15 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : epel-release-7-11.noarch                                           1/1 
  验证中      : epel-release-7-11.noarch                                           1/1 

已安装:
  epel-release.noarch 0:7-11                                                           

完毕!

2)再次检查文件,是否生成epel.repo和epel-testing.repo

[root@localhost yum.repos.d]# ll
总用量 12
-rw-r--r--. 1 root root 2523 3月  18 23:16 CentOS-Base.repo
-rw-r--r--. 1 root root  951 10月  2 2017 epel.repo
-rw-r--r--. 1 root root 1050 10月  2 2017 epel-testing.repo
drwxr-xr-x. 2 root root  195 3月  18 23:13 repo_bak

3)再次运行yum clean all 清除缓存,运行 yum makecache 生成新的缓存

[root@localhost yum.repos.d]# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: base epel extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@localhost yum.repos.d]# yum makecache 
已加载插件:fastestmirror, langpacks
base                                                            | 3.6 kB  00:00:00     
epel/x86_64/metalink                                            | 6.6 kB  00:00:00     
epel                                                            | 4.7 kB  00:00:00     
extras                                                          | 2.9 kB  00:00:00     
updates                                                         | 2.9 kB  00:00:00     
(1/16): base/7/x86_64/group_gz                                  | 153 kB  00:00:00     
(2/16): base/7/x86_64/filelists_db                              | 7.2 MB  00:00:01     
(3/16): base/7/x86_64/other_db                                  | 2.6 MB  00:00:00     
(4/16): epel/x86_64/updateinfo                                  | 1.0 MB  00:00:00     
(5/16): epel/x86_64/group_gz                                    |  96 kB  00:00:01     
(6/16): epel/x86_64/other_db                                    | 3.3 MB  00:00:01     
(7/16): epel/x86_64/primary_db                                  | 6.9 MB  00:00:01     
(8/16): extras/7/x86_64/filelists_db                            | 226 kB  00:00:00     
(9/16): extras/7/x86_64/other_db                                | 134 kB  00:00:00     
(10/16): extras/7/x86_64/primary_db                             | 225 kB  00:00:00     
(11/16): epel/x86_64/prestodelta                                | 1.2 kB  00:00:02     
(12/16): base/7/x86_64/primary_db                               | 6.1 MB  00:00:05     
(13/16): epel/x86_64/filelists_db                               |  12 MB  00:00:04     
(14/16): updates/7/x86_64/filelists_db                          | 3.9 MB  00:00:02     
(15/16): updates/7/x86_64/other_db                              | 516 kB  00:00:00     
(16/16): updates/7/x86_64/primary_db                            | 6.5 MB  00:00:03     
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * epel: mirrors.bfsu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
元数据缓存已建立

4)检查仓库是否启用

[root@localhost yum.repos.d]# yum repolist enabled 
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.bfsu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
源标识                   源名称                                                  状态
base/7/x86_64            CentOS-7 - Base - mirrors.aliyun.com                    10,072
epel/x86_64              Extra Packages for Enterprise Linux 7 - x86_64          13,558
extras/7/x86_64          CentOS-7 - Extras - mirrors.aliyun.com                     453
updates/7/x86_64         CentOS-7 - Updates - mirrors.aliyun.com                  1,898
repolist: 25,981

5)查看所有的仓库

[root@localhost yum.repos.d]# yum repolist all
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.bfsu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
源标识                        源名称                                       状态
base/7/x86_64                 CentOS-7 - Base - mirrors.aliyun.com         启用: 10,072
centosplus/7/x86_64           CentOS-7 - Plus - mirrors.aliyun.com         禁用
contrib/7/x86_64              CentOS-7 - Contrib - mirrors.aliyun.com      禁用
epel/x86_64                   Extra Packages for Enterprise Linux 7 - x86_ 启用: 13,558
epel-debuginfo/x86_64         Extra Packages for Enterprise Linux 7 - x86_ 禁用
epel-source/x86_64            Extra Packages for Enterprise Linux 7 - x86_ 禁用
epel-testing/x86_64           Extra Packages for Enterprise Linux 7 - Test 禁用
epel-testing-debuginfo/x86_64 Extra Packages for Enterprise Linux 7 - Test 禁用
epel-testing-source/x86_64    Extra Packages for Enterprise Linux 7 - Test 禁用
extras/7/x86_64               CentOS-7 - Extras - mirrors.aliyun.com       启用:    453
updates/7/x86_64              CentOS-7 - Updates - mirrors.aliyun.com      启用:  1,898
repolist: 25,981

步骤四:测试安装

[root@localhost yum.repos.d]# yum install -y httpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.bfsu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-97.el7.centos 将被 安装
--> 正在处理依赖关系 httpd-tools = 2.4.6-97.el7.centos,它被软件包 httpd-2.4.6-97.el7.centos.x86_64 需要
--> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-97.el7.centos.x86_64 需要
--> 正在处理依赖关系 libaprutil-1.so.0()(64bit),它被软件包 httpd-2.4.6-97.el7.centos.x86_64 需要
--> 正在处理依赖关系 libapr-1.so.0()(64bit),它被软件包 httpd-2.4.6-97.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 apr.x86_64.0.1.4.8-7.el7 将被 安装
---> 软件包 apr-util.x86_64.0.1.5.2-6.el7 将被 安装
---> 软件包 httpd-tools.x86_64.0.2.4.6-97.el7.centos 将被 安装
---> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=======================================================================================
 Package             架构           版本                         源               大小
=======================================================================================
正在安装:
 httpd               x86_64         2.4.6-97.el7.centos          updates         2.7 M
为依赖而安装:
 apr                 x86_64         1.4.8-7.el7                  base            104 k
 apr-util            x86_64         1.5.2-6.el7                  base             92 k
 httpd-tools         x86_64         2.4.6-97.el7.centos          updates          93 k
 mailcap             noarch         2.1.41-2.el7                 base             31 k

事务概要
=======================================================================================
安装  1 软件包 (+4 依赖软件包)

总下载量:3.0 M
安装大小:10 M
Downloading packages:
(1/5): apr-1.4.8-7.el7.x86_64.rpm                               | 104 kB  00:00:06     
(2/5): apr-util-1.5.2-6.el7.x86_64.rpm                          |  92 kB  00:00:06     
(3/5): mailcap-2.1.41-2.el7.noarch.rpm                          |  31 kB  00:00:00     
(4/5): httpd-tools-2.4.6-97.el7.centos.x86_64.rpm               |  93 kB  00:00:07     
(5/5): httpd-2.4.6-97.el7.centos.x86_64.rpm                     | 2.7 MB  00:00:07     
---------------------------------------------------------------------------------------
总计                                                      390 kB/s | 3.0 MB  00:07     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : apr-1.4.8-7.el7.x86_64                                             1/5 
  正在安装    : apr-util-1.5.2-6.el7.x86_64                                        2/5 
  正在安装    : httpd-tools-2.4.6-97.el7.centos.x86_64                             3/5 
  正在安装    : mailcap-2.1.41-2.el7.noarch                                        4/5 
  正在安装    : httpd-2.4.6-97.el7.centos.x86_64                                   5/5 
  验证中      : httpd-2.4.6-97.el7.centos.x86_64                                   1/5 
  验证中      : apr-1.4.8-7.el7.x86_64                                             2/5 
  验证中      : mailcap-2.1.41-2.el7.noarch                                        3/5 
  验证中      : httpd-tools-2.4.6-97.el7.centos.x86_64                             4/5 
  验证中      : apr-util-1.5.2-6.el7.x86_64                                        5/5 

已安装:
  httpd.x86_64 0:2.4.6-97.el7.centos                                                   

作为依赖被安装:
  apr.x86_64 0:1.4.8-7.el7                        apr-util.x86_64 0:1.5.2-6.el7       
  httpd-tools.x86_64 0:2.4.6-97.el7.centos        mailcap.noarch 0:2.1.41-2.el7       

完毕!

2)卸载

事务概要
=======================================================================================
移除  1 软件包

安装大小:9.4 M
是否继续?[y/N]:y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在删除    : httpd-2.4.6-97.el7.centos.x86_64                                   1/1 
  验证中      : httpd-2.4.6-97.el7.centos.x86_64                                   1/1 

删除:
  httpd.x86_64 0:2.4.6-97.el7.centos                                                   

完毕!

有兴趣可以借阅Linux下安装python3

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/170095.html原文链接:https://javaforall.net

(0)
上一篇 2022年8月13日 下午9:16
下一篇 2022年8月13日 下午9:16


相关推荐

  • JVM内存结构概述

    JVM内存结构概述本节将会介绍一下JVM的内存结构,JVM运行时数据区的各个组成部分:堆,方法区,程序计数器,Java虚拟机栈,本地方法栈,还会对Java堆的分代划分做个简单的介绍。目录前言JVM是什么JVM内存结构概览运行时数据区程序计数器Java虚拟机栈本地方法栈方法区运行时常量池Java堆直接内存前言JVM是Java中比较难理解和掌握的一部分,也是面试…

    2022年6月3日
    48
  • 第十一周上机项目2 求最大公约数「建议收藏」

    第十一周上机项目2 求最大公约数「建议收藏」问题及代码:/**Copyright(c)2014,烟台大学计算机学院*Allrightsreserved.*文件名称:test.cpp*作者:曹莉萍*完成日期:2014年10月27日*版本号:v1.0**问题描述:求几个数的最大公约数*输入描述:输入几个不同的整数,求出这几个数的最大公约数*程序输出:最大公约数*/#in

    2022年4月30日
    36
  • Fusionio性能测试与瓶颈分析

    Fusionio性能测试与瓶颈分析来源 http www hellodb net 2011 06 fusionio performance html 测试环境 DellR510 2 E5620 24G Fusion ioioDrive320 测试工具 RedhatLinux5 3 OracleOrion1 测试一 8K 随机读 IOPS 超过 5W 吞吐量超过 400M 响应时间在 IOPS 达

    2026年3月19日
    2
  • c语言strstr的使用及模拟实现strstr函数[通俗易懂]

    c语言strstr的使用及模拟实现strstr函数[通俗易懂]c语言strstr的使用及模拟实现strstr函数

    2022年10月10日
    4
  • 为什么腾讯游戏都靠抄袭_腾讯帝国究竟有多庞大

    为什么腾讯游戏都靠抄袭_腾讯帝国究竟有多庞大随着IT行业的蓬勃发展,带给人们巨大便易,财富的同时也会随之带来一些社会问题。腾讯企业作为目前中国网络不可或缺的一份子,在崛起的一路上却一直伴随着网民的质疑之声。腾讯帝国的崛起靠的是抄袭吗?在这里我不妄作定论,只浅谈个人见解。互联网的老网民应该知道,腾讯QQ原名“OICQ”,而这正是腾讯被指责抄袭的第一步。。有人说腾讯QQ其实是一款完全复制了ICQ的产品。ICQ即ISEEKYOU的缩写,互联网

    2026年2月22日
    3
  • 本地mysql文件浏览器_可视化数据库浏览器(SQLite Database Browser)

    本地mysql文件浏览器_可视化数据库浏览器(SQLite Database Browser)SQLiteDatabaseBrowser可以管理所有iphone数据,基于Qt库开发,主要是为非技术用户创建、修改和编辑SQLite数据库的工具,使用向导方式实现。用来处理SQLite3数据库文件的应用程序,它能够打开sqlite3数据库文件(常见的文件扩展名为.db,.db3,.s3db;只要文件是SQLite3数据库文件,其扩展名不规范也不要紧)。SQLiteDatabas…

    2025年10月15日
    3

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号