小编给大家分享一下RHEL6如何配置本地YUM源,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

yum,全称“Yellow dog Updater, Modified”,是一个专门为了解决包的依赖关系而存在的软件包管理器。就好像 Windows 系统上可以通过 360 软件管家实现软件的一键安装、升级和卸载,Linux 系统也提供有这样的工具,就是 yum。

一:挂载本地光盘到系统

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

方法1:光驱挂载镜像

[root@getlnx06~]#mkdir/mnt/cdrom[root@getlnx06~]#mount-tiso9660/dev/cdrom/mnt/cdrommount:blockdevice/dev/sr0iswrite-protected,mountingread-only[root@getlnx06~]#方式2:复制光盘文件

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

[root@localhost~]#mkdir/mnt/cdrom/[root@localhost~]tarzxvf/tmp/rehl6.tar.gz-C/mnt/cdrom/二:配置本地YUM源

[root@localhost~]#cd/etc/yum.repos.d/[root@localhostyum.repos.d]#lsredhat.reporhel-source.repo[root@localhostyum.repos.d]touchrhel-media.repo[root@localhostyum.repos.d]#virhel-media.repo[media]name=RedHatEnterpriseLinux6.6baseurl=file:///mnt/cdromenabled=1gpgcheck=1gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release清除原有缓存

[root@localhost~]#yumcleanallLoadedplugins:product-id,security,subscription-managerThissystemisnotregisteredtoRedHatSubscriptionManagement.Youcanusesubscription-managertoregister.Cleaningrepos:mediaCleaningupEverything获取yum列表

验证yum配置是否成功

[root@localhost~]#yummakecacheLoadedplugins:product-id,refresh-packagekit,security,subscription-managerThissystemisnotregisteredtoRedHatSubscriptionManagement.Youcanusesubscription-managertoregister.media|4.1kB00:00...media/group_gz|211kB00:00...media/filelists_db|3.3MB00:00...media/primary_db|3.1MB00:00...media/other_db|1.4MB00:00...MetadataCacheCreated[root@localhost~]#验证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"

以上是“RHEL6如何配置本地YUM源”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!