一、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  CurrentDload  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 kapr-util            x86_64         1.5.2-6.el7                  base             92 khttpd-tools         x86_64         2.4.6-97.el7.centos          updates          93 kmailcap             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

Centos7配置yum源(本地yum源和阿里网络yum源)相关推荐

  1. CentOS 7 配置yum本地base源和阿里云epel源

    yum仓库的配置文件都存放在/etc/yum.repo.d/目录下,并且文件名必须以.repo结尾. base源:解决rpm依赖性关系 epel源:Extra Packages for Enterpr ...

  2. centos7.5.1804配置本地yum源和阿里云yum源以及163源

    一.用Centos镜像搭建本地yum源 由于安装centos后的默认yum源为centos的官方的地址,所以在国内使用很慢甚至无法访问,所以一般的做法都是把默认的yum源替换成aliyun的yum源或 ...

  3. Linux(CentOS7.1)修改默认yum源为国内的阿里云yum源

    官方的yum源在国内访问效果不佳. 需要改为国内比较好的阿里云或者网易的yum源 修改方式: 下载wget yum install wget -y echo 备份当前的yum源 mv /etc/yum ...

  4. Linux中yum源不能使用故障解决---网络yum配置

    报错问题展示:[root@NISEC-6601 yum]# yum clean all bash: yum: 未找到命令... 或者 无法使用YUM源的问题如下: [root@localhost ~] ...

  5. 源码 状态机_阿里中间件seata源码剖析七:saga模式实现

    saga模式是分布式事务中使用比较多的一种模式,他主要应用在长流程的服务,对一个全局事务,如果某个节点抛出了异常,则从这个节点往前依次回滚或补偿事务.今天我们就来看看它的源码实现. 状态机初始化 在之 ...

  6. 易语言php注册,易语言简单ASP网络验证源码 PHP一键搭建网络验证源码

    说明: 易语言简单ASP网络验证源码 ,很不错的易语言源码,适合易语言爱好者学习, (Easy language simple ASP network verification source code ...

  7. centos7镜像加速_虚拟机 Linux CentOS7 安装Docker 详解:使用 阿里云Yum源;附加云镜像加速器...

    Docker 要求 CentOS 系统的内核版本高于 3.10 ,先检查一下,如内核版本不符合,不建议参考该贴安装!(CentOS版本 大于7.0以上版本,一般都可以:建议先查询系统内核版本) 如系统 ...

  8. linux上centos镜像磁盘,VirtualBox中配置linuxCentOS的本地磁盘镜像iso作为其软件源

    下载VirtualBox软件和CentOS的磁盘镜像(.iso文件) 在VirtualBox虚拟机中安装好CentOS,安装步骤不叙述. 开始配置 操作1 打开虚拟机设置 打开你的VirtualBox ...

  9. Centos7配置阿里云yum源及epel源

    Background 踩坑记录吧.下次可以直接复制粘贴,不用再去排查是哪个字母字符少了多了,我这都是执行成功的命令粘贴过来的. 1.基础知识简介 yum: 全称"Yellow dog Upd ...

最新文章

  1. uber_这就是我本可以免费骑Uber的方式
  2. CodeForces 689B Mike and Shortcuts (bfs or 最短路)
  3. ALVのイベントを取得する方法
  4. swoole+redis(websocket聊天室demo)
  5. .NET 时间轴:从出生到巨人
  6. nginx_keepalived配置(转载保存)
  7. 嵌套查询和连接查询的效率_Elasticsearch 7.x Nested 嵌套类型查询 | ES 干货
  8. iText中输出 中文
  9. 1.登录mysql数据库_MySql使用全记录1 -----使用命令登录数据库
  10. qt 正则 html,Qt 正则表达式 (一)
  11. 51nod 1099 任务执行顺序
  12. 计算机桌面隐喻,计算机英语词汇隐喻分析论文
  13. 基于EEMD和樽海鞘算法优化SVM的滚动轴承故障诊断python
  14. 【货位优化】基于遗传算法实现仓库货位优化问题含Matlab源码
  15. 三维全景技术的基本原理,三维全景虚拟现实图片应用
  16. 三菱PLC GX Work2学习笔记
  17. docker制作镜像的方法
  18. 【camera】【摄像头模组】摄像头模组简单介绍
  19. Head First java 上的报错!
  20. cfa的pv怎么用计算机算,怎么用金融计算器算pv(金融计算器怎么用)

热门文章

  1. java如何拷贝复制对象和集合
  2. 搜狗起诉360,“因爱生恨”引发的恋爱悲剧
  3. 北京最新建筑施工八大员之(安全员)考试真题及答案解析
  4. 医院药品管理系统开源项目-03 【后台主体 供应商管理】
  5. html发送post请求,如何发出HTTP POST Web请求
  6. 【Android】Android 8 WiFi的自由控制:静态STATIC连接 + 动态DHCP连接
  7. chrome close js 关闭当前页面
  8. 过年了,如何同老板谈加薪汇总贴
  9. 樱花源代码_查看“完全墨染的樱花”的源代码
  10. 深入浅出matplotlib(35):设置坐标轴个性化显示标签