记一次redhat6.5网络yum源配置

  还记得初学时搜索了好多网络/本地yum源的配置,本地yum基本上按照大部分文档都可以配置,但是网络yum配置各不相同!!有人说redhat的yum是收费的需要将系统中的yum卸载掉再去下载什么centos的安装包然后各种报错几乎崩溃!!!

  好了不废话上干货!!很简单什么都不需要安装你只需要配置好的你的yum配置文件rhel的yum好用的很!!!

  我是用的是rhel6.5镜像最小化安装可以请参考https://www.cnblogs.com/lch1990/p/10310304.html

  首先要做的就是联网已经联网的小伙伴请跳过往下看

    看一下虚拟机的配置是否正确,如果是按照我之前帖子进行安装的可以不用修改,为了严禁吧还是上一张图大家自己对比吧

  启动虚拟机配置网络

    

输入命令service network restart将网络服务重启

输入命令ifconfig查看网络配置

  上图所示我这台虚拟机的IP是192.168.106.129(因vm的配置不同你们的可能不一样所以按我标记的自己找吧)

  接下来我们就可以使用xshell工具连接我们的虚拟机了

输入root账户的密码

 

恭喜连接成功了

关闭防火墙开机启动命令:chkconfig iptables off

 

下面开始yum的配置吧

  我们都知道yum的配置文件路径在/etc/yum.report.d/下

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
rhel-source.repo
  这里的rhel-source.repo是系统默认的,没啥用这里我就删掉了

[root@localhost yum.repos.d]# rm -rf rhel-source.repo

  然后我这里提供一个已经配置好的配置文件我也忘了是从哪里下载的反正挺好用的

https://pan.baidu.com/s/1S_z2TgIqDGqjW3bD6k2hAw

  

  将这个文件下载下来放到/etc/yum.report.d/下,然后开始最重要的一步就是修改这个配置文件,这个文件是通用的,需要根据你自己系统的版本来替换对应的$releasever

  

[root@localhost yum.repos.d]# pwd
/etc/yum.repos.d
[root@localhost yum.repos.d]# vi CentOS-Base.repo

  接下来使用全文替换功能将文件中所有的$releasever替换成你自己系统的版本(我这里用的是rhel6.5所以这里只需要替换成6)

:%s /$releasever/6/g

  输入以上命令全部替换(别告诉我你不会替换!!好吧不会的话去问问度娘我就不写了!!实在不行你直接复制粘贴敲回车!!)

  回车后你会发现最下面一行告诉你成功替换了多少个

15 substitutions on 15 lines

  大功搞成保存退出

:wq

  接下来我们就可以尽情的使用yum了,那我们就尝试一下使用yum来安装gcc吧

[root@localhost yum.repos.d]# yum -y install gcc
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
extras | 3.4 kB 00:00
extras/primary_db | 27 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 3.0 MB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-23.el6 will be installed
--> Processing Dependency: libgomp = 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.x86_64
--> Processing Dependency: cpp = 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.x86_64
--> Processing Dependency: libgcc >= 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.x86_64
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-23.el6.x86_64
--> Running transaction check
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-23.el6 will be installed
--> Processing Dependency: libmpfr.so.1()(64bit) for package: cpp-4.4.7-23.el6.x86_64
---> Package libgcc.x86_64 0:4.4.7-4.el6 will be updated
---> Package libgcc.x86_64 0:4.4.7-23.el6 will be an update
---> Package libgomp.x86_64 0:4.4.7-4.el6 will be updated
---> Package libgomp.x86_64 0:4.4.7-23.el6 will be an update
--> Running transaction check
---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================
Package Arch Version Repository Size
==============================================================================
Installing:
gcc x86_64 4.4.7-23.el6 base 10 M
Installing for dependencies:
cloog-ppl x86_64 0.15.7-1.2.el6 base 93 k
cpp x86_64 4.4.7-23.el6 base 3.7 M
mpfr x86_64 2.4.1-6.el6 base 157 k
ppl x86_64 0.10.2-11.el6 base 1.3 M
Updating for dependencies:
libgcc x86_64 4.4.7-23.el6 base 104 k
libgomp x86_64 4.4.7-23.el6 base 135 k

Transaction Summary
==============================================================================
Install 5 Package(s)
Upgrade 2 Package(s)

Total download size: 16 M
Downloading Packages:
(1/7): cloog-ppl-0.15.7-1.2.el6.x86_64.rpm | 93 kB 00:00
(2/7): cpp-4.4.7-23.el6.x86_64.rpm | 3.7 MB 00:00
(3/7): gcc-4.4.7-23.el6.x86_64.rpm | 10 MB 00:01
(4/7): libgcc-4.4.7-23.el6.x86_64.rpm | 104 kB 00:00
(5/7): libgomp-4.4.7-23.el6.x86_64.rpm | 135 kB 00:00
(6/7): mpfr-2.4.1-6.el6.x86_64.rpm | 157 kB 00:00
(7/7): ppl-0.10.2-11.el6.x86_64.rpm | 1.3 MB 00:00
------------------------------------------------------------------------------
Total 4.5 MB/s | 16 MB 00:03
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid: "CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>"
From : http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : libgcc-4.4.7-23.el6.x86_64 1/9
Installing : ppl-0.10.2-11.el6.x86_64 2/9
Installing : cloog-ppl-0.15.7-1.2.el6.x86_64 3/9
Installing : mpfr-2.4.1-6.el6.x86_64 4/9
Installing : cpp-4.4.7-23.el6.x86_64 5/9
Updating : libgomp-4.4.7-23.el6.x86_64 6/9
Installing : gcc-4.4.7-23.el6.x86_64 7/9
Cleanup : libgcc-4.4.7-4.el6.x86_64 8/9
Cleanup : libgomp-4.4.7-4.el6.x86_64 9/9
Verifying : libgomp-4.4.7-23.el6.x86_64 1/9
Verifying : gcc-4.4.7-23.el6.x86_64 2/9
Verifying : mpfr-2.4.1-6.el6.x86_64 3/9
Verifying : cloog-ppl-0.15.7-1.2.el6.x86_64 4/9
Verifying : cpp-4.4.7-23.el6.x86_64 5/9
Verifying : ppl-0.10.2-11.el6.x86_64 6/9
Verifying : libgcc-4.4.7-23.el6.x86_64 7/9
Verifying : libgomp-4.4.7-4.el6.x86_64 8/9
Verifying : libgcc-4.4.7-4.el6.x86_64 9/9

Installed:
gcc.x86_64 0:4.4.7-23.el6

Dependency Installed:
cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-23.el6
mpfr.x86_64 0:2.4.1-6.el6 ppl.x86_64 0:0.10.2-11.el6

Dependency Updated:
libgcc.x86_64 0:4.4.7-23.el6 libgomp.x86_64 0:4.4.7-23.el6

Complete!
[root@localhost yum.repos.d]#

  那么大个Complete!!!表示已经成功安装了!!!希望能帮到你!!

原文地址:https://www.cnblogs.com/lch1990/p/10299714.html