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

相关文章
|
12月前
|
安全 Linux 数据安全/隐私保护
Red Hat Enterprise Linux 9.6 (x86_64, aarch64) - 红帽企业 Linux (RHEL)
Red Hat Enterprise Linux 9.6 (x86_64, aarch64) - 红帽企业 Linux (RHEL)
1378 36
Red Hat Enterprise Linux 9.6 (x86_64, aarch64) - 红帽企业 Linux (RHEL)
|
9月前
|
Ubuntu Linux 网络安全
Linux服务器之Ubuntu的安装与配置
Ubuntu Desktop是目前最成功、最流行的图形界面的Linux发行版;而Ubuntu Server也在服务器端市场占据了较大的份额。今天为大家详细介绍了Ubuntu Server的安装与配置,希望对你能有所帮助。关于VMware、VirtualBox等虚拟化软件的使用,朱哥还会在后续的文章中为大家详细介绍,敬请关注!
|
7月前
|
存储 Linux 开发工具
Linux环境下使用Buildroot配置软件包
使用Buildroot可以大大简化嵌入式Linux系统的开发和维护工作,但它需要对Linux系统和交叉编译有深入的理解。通过上述步骤,可以有效地配置和定制软件包,为特定的嵌入式应用构建高效、稳定的系统。
857 11
|
10月前
|
Kubernetes Linux 网络安全
Rocky Linux 8.9配置Kubernetes集群详解,适用于CentOS环境
初始化成功后,记录下显示的 `kubeadm join`命令。
711 0
|
关系型数据库 MySQL Java
安装和配置JDK、Tomcat、MySQL环境,以及如何在Linux下更改后端端口。
遵循这些步骤,你可以顺利完成JDK、Tomcat、MySQL环境的安装和配置,并在Linux下更改后端端口。祝你顺利!
653 11
|
12月前
|
人工智能 安全 Linux
Red Hat Enterprise Linux 10 正式版发布 - 红帽企业 Linux (RHEL)
Red Hat Enterprise Linux 10 正式版发布 - 红帽企业 Linux (RHEL)
1523 0
Red Hat Enterprise Linux 10 正式版发布 - 红帽企业 Linux (RHEL)
|
安全 Linux 网络安全
在Linux(CentOS和AWS)上安装更新的git2的方法并配置github-ssh
经过以上这些步骤,你现在就能在GitHub上顺利往返,如同海洋中的航海者自由驰骋。欢迎你加入码农的世界,享受这编程的乐趣吧!
548 10
|
11月前
|
Linux 网络安全 开发工具
在Linux下配置gitee与Github的远程仓库
注意,git push后,是输入你的账号与密码。这个步骤可以通过特殊设置省去,但是一开始还是不要太省。
566 0
|
11月前
|
NoSQL Linux 开发工具
Linux环境基础开发工具的使用(yum、vim、gcc、g++、gdb、make/Makefile)
本文介绍了yum 包管理工具、Vim 编辑器、gcc/g++ 编译器、gdb 调试器、编译原理及 Makefile 的使用,同时还配备了如何使用,以及图解。旨在帮助读者更好地理解和应用这些工具与技术。
562 0
|
人工智能 Kubernetes Ubuntu
linux配置IP
linux配置IP
4508 1