配置网络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
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
步骤四:测试安装
1)
[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 testTransaction 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 完毕!