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


相关推荐

  • ensp配置静态路由的步骤_2个路由器静态路由配置

    ensp配置静态路由的步骤_2个路由器静态路由配置eNSP配置静态路由目标配置目标:如下拓扑结构,从CLIENT1去pingCLIENT2,ping通拓扑结构路由配置配置各个路由表的核心思想是:只有这个路由表中有一个网段的网络号,才可以从这个路由器跳转到该网段,下面只展示R1的前往CLIENT2的路由配置,其他路由器及返回过程配置类似。CLIENT1配置CLIENT2配置R1配置[R1]int…

    2026年3月7日
    4
  • box-sizing:border-box的理解和作用

    box-sizing:border-box的理解和作用要想清楚这个属性的作用,首先要理解盒子模型盒子模型是指:外边距(margin)+border(边框)+内边距(padding)+content(内容)可以把每一个容器,比如div,都看做是一个盒子模型比如你给一个div设置宽高为500px,但实际你设置的只是content,之后你又设置了padding:10px;border:1pxsolidred;这时div的宽高就会变为544px(content500px+padding40px+border4px)相当于一个元素的实际宽高是由

    2025年7月17日
    7
  • 最全面的PLC学习网站[通俗易懂]

    最全面的PLC学习网站[通俗易懂]http://www.gkwo.net/wenku/list-13.htmPLC工控资料学习网

    2022年10月19日
    4
  • 分布式系统常见问题总结[通俗易懂]

    分布式系统常见问题总结[通俗易懂]秒杀系统架构优化思路一、秒杀业务为什么难做1)im系统,例如qq或者微博,每个人都读自己的数据(好友列表、群列表、个人信息);2)微博系统,每个人读你关注的人的数据,一个人读多个人的数据;3)秒杀系统,库存只有一份,所有人会在集中的时间读和写这些数据,多个人读一个数据。例如:小米手机每周二的秒杀,可能手机只有1万部,但瞬时进入的流量可能是几百几千万。又例如:12306抢票,…

    2022年5月20日
    40
  • 推荐8个特好用的小众APP,让人耳目一新

    推荐8个特好用的小众APP,让人耳目一新分享 8 个小众但是非常实用的手机 APP 1 白描白描 像猫一样灵动的 OCR 扫描识别神器 具备高准确度的文字识别 表格识别转 Excel 批量识别 识别后翻译 文件扫描等功能 白描的主要特点 文字识别识别准确度高 云端文字识别 识别结果翻译 批量处理高效快捷 自动识别文档边界自动生成扫描件 生成扫描件清晰 支持简体中文 日语 英语 韩语 法语 西班牙语 阿拉伯语 俄语 德语 葡萄牙语 意大利语 繁体中文 粤语 文言文的互译 2 智办事智办事是以 目标 事 为中心的企业数字化管理工具

    2026年3月16日
    2
  • shell IF语句的使用[通俗易懂]

    shell IF语句的使用[通俗易懂]目录条件语句(ifelse)的简单介绍if…fi语句if…else…fi语句if…elif…[else…]fi语句条件语句(ifelse)的简单介绍    如果你在用shell完成一些逻辑判断的时候,可能会用到if…else之类的条件语句。但是,shell中非同寻常的语法会让你每次都需要在网上重新查询确认。在shell中,即使是一些标点…

    2022年7月11日
    26

发表回复

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

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