RedHat Linux RHEL6配置本地YUM源

简介:

YUM是Yellow dog Updater Modified的简称,起初是由yellow dog这一发行版的开发者Terra Soft研发,用python写成,那时还叫做yup(yellow dog updater),后经杜克大学的Linux@Duke开发团队进行改进,遂有此名。yum的宗旨是自动化地升级,安装/移除rpm包,收集rpm包的相 关信息,检查依赖性并自动提示用户解决。yum的关键之处是要有可靠的repository,顾名思义,这是软件的仓库,它可以是http或ftp站点, 也可以是本地软件池,但必须包含rpm的header, header包括了rpm包的各种信息,包括描述,功能,提供的文件,依赖性等.正是收集了这些 header并加以分析,才能自动化地完成余下的任务。

如 果体验过rpm安装痛苦的人,我相信其肯定百分之百选择yum替代rpm。使用yum非常方便。如果要使用rpm则必须配置repository(软件仓 库),由于RHEL的yum在线更新是收费的,如果没有注册的话不能使用,如果要使用yum安装一些包,则需要配置本地的YUM源。下面介绍一下如何配 置,下文以Red Hat Enterprise Linux Server release 6.6为实验场景。可能不同版本的Linux稍有差别。

一:挂载本地光盘到系统

如 果服务器是虚拟机,可以通过vSphere Client进入控制平台,在“编辑设置”——>“硬件”——>“CD/DVD驱动器”里指定操作系统的ISO镜像文件。如果是物理机,则需 要进入机房找到服务器,在光驱里面放入安装光盘。这个相对而言比较麻烦,所以一般最好复制光盘文件到本地硬盘。

 

方法1:光驱挂载镜像

[root@getlnx06 ~]# mkdir /mnt/cdrom
[root@getlnx06 ~]# mount -t iso9660 /dev/cdrom  /mnt/cdrom
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@getlnx06 ~]# 

方式2:复制光盘文件

文件/tmp/rehl6.tar.gz是从光盘打包复制过来的,顺便解压到到指定目录/mnt/cdrom

[root@localhost ~]# mkdir /mnt/cdrom/
[root@localhost ~]tar zxvf /tmp/rehl6.tar.gz -C /mnt/cdrom/

二:配置本地YUM源

[root@localhost ~]#  cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
redhat.repo   rhel-source.repo
[root@localhost yum.repos.d]touch rhel-media.repo
[root@localhost yum.repos.d]# vi rhel-media.repo 
[media]
name=Red Hat Enterprise Linux 6.6                                
baseurl=file:///mnt/cdrom                                         
enabled=1                                                         
gpgcheck=1                                                        
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release  

清除原有缓存

[root@localhost ~]# yum clean all
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: media
Cleaning up Everything

获取yum列表

验证yum配置是否成功

[root@localhost ~]# yum makecache
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.
media                                                                    | 4.1 kB     00:00 ... 
media/group_gz                                                           | 211 kB     00:00 ... 
media/filelists_db                                                       | 3.3 MB     00:00 ... 
media/primary_db                                                         | 3.1 MB     00:00 ... 
media/other_db                                                           | 1.4 MB     00:00 ... 
Metadata Cache Created
[root@localhost ~]# 

image

 

验证yum配置是否成功
[root@localhost ~]# yum grouplist | grep Server
   Network Infrastructure Server
   Server Platform
   Web Server
   Backup Server
   Directory Server
   Identity Management Server
   Network Storage Server
   Print Server
   Server Platform Development

 

小问题:

在yum配置文件里,如果忘记添加添加yum源的名字,则有可能报下面错误。

[root@getlnx06 yum.repos.d]# yum clean all

Loaded plugins: product-id, security, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Error: File contains no section headers.

file: file:///etc/yum.repos.d/rhel-media.repo, line: 1

'name=Red Hat Enterprise Linux 6.6 \n'

clip_image001

相关文章
|
9天前
|
Linux C语言
linux yum安装ffmpeg 图文详解
linux yum安装ffmpeg 图文详解
28 0
|
9天前
|
Linux
linux yum 安装rar和unrar
linux yum 安装rar和unrar
34 0
|
10天前
|
安全 Ubuntu Java
Linux配置使用篇
Linux配置使用篇
|
22天前
|
存储 负载均衡 索引
linux7安装elasticsearch-7.4.0集群配置
linux7安装elasticsearch-7.4.0集群配置
109 0
|
27天前
|
监控 Linux Shell
【Shell 命令集合 网络通讯 】Linux 配置和管理网络流量的形状 shapecfg命令 使用指南
【Shell 命令集合 网络通讯 】Linux 配置和管理网络流量的形状 shapecfg命令 使用指南
38 0
|
27天前
|
网络协议 Shell Linux
【Shell 命令集合 网络通讯 】Linux 设置和配置PPP pppsetup命令 使用教程
【Shell 命令集合 网络通讯 】Linux 设置和配置PPP pppsetup命令 使用教程
36 0
|
28天前
|
缓存 网络协议 Linux
【Shell 命令集合 网络通讯 】Linux 配置DNS dnsconf 命令 使用教程
【Shell 命令集合 网络通讯 】Linux 配置DNS dnsconf 命令 使用教程
38 0
|
12天前
|
Ubuntu Linux 编译器
【Linux】4. 开发工具的使用(yum/vim)
【Linux】4. 开发工具的使用(yum/vim)
42 2
|
27天前
|
域名解析 网络协议 Linux
【Shell 命令集合 网络通讯 】Linux 设置和管理网络接口配置信息 netconfig命令 使用指南
【Shell 命令集合 网络通讯 】Linux 设置和管理网络接口配置信息 netconfig命令 使用指南
49 1
|
27天前
|
存储 Shell Linux
【Shell 命令集合 系统管理 】Linux 修改用户的属性和配置 usermod命令 使用指南
【Shell 命令集合 系统管理 】Linux 修改用户的属性和配置 usermod命令 使用指南
30 1