admin管理员组

文章数量:815885

RHEL6配置本地源

RHEL6配置本地源
 

备注:实际生产环境中或者开发环境中,如果没有购买RHEL但是想作为服务器使用,如果没有RHEL购买授权使用yum命令也无法安装软件。所以可以从官网下载i相应版本ISO镜像文件后,向RHEL操作系统添加本地源以供能够正常安装所需软件。ISO中包含的软件基本能够满足生产或者开发环境使用。如果所需软件并未包含在ISO镜像中,则可以通过其他形式下载后但另安装。同时一定注意,这样使用并不违反RHEL条约,只是如果使用过程过出现任何问题或者操作系统有任何BUG造成不良后果,需要自行承担造成的损失。所以建议要么购买RHEL服务,要么及时关注RHEL相关BUG自行进行补救。

1.创建挂载目录

[root@NC65 ~]# mkdir /mnt/RHEL_DVD

2.挂载光盘

[root@NC65 repodata]# mount /dev/sr0  /mnt/RHEL_DVD/

3.查看挂载状

[root@NC65 Packages]# df -h
文件系统              容量  已用  可用 已用%% 挂载点
/dev/sda1              60G  1.1G   56G   2% /
tmpfs                 6.0G     0  6.0G   0% /dev/shm
/dev/sda6             270G  191M  256G   1% /home
/dev/sda3              20G  172M   19G   1% /tmp
/dev/sda2              30G  198M   28G   1% /var
/dev/sr0              3.5G  3.5G     0 100% /mnt/RHEL_DVD

4.查看系统默认源文件

[root@NC65 /]# more /etc/yum.repos.d/rhel-source.repo 

内容如下

[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=/$releasever/en/os/SRPMS/	
enabled=0		# 1代表该yum仓库可用,0代表不可用
gpgcheck=1		#gpg校验 1代表启用,0代表不启用
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
#说明:即使配置了yum源地址,因为enabled=0,也会用不了![rhel-source-beta]
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Source
baseurl=/$releasever/en/os/SRPMS/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[root@NC65 /]# 

5.备份系统默认源

[root@NC65 /]# cp /etc/yum.repos.d/rhel-source.repo  /etc/yum.repos.d/rhel-source.repo.bak

6.修改yum源为本地源

[root@NC65 /]# vi /etc/yum.repos.d/rhel-source.repo

删除所有内容后添加以下内容

[RHEL6.3]	#自定义
name=RHEL63	#自定义
baseurl=file:///mnt/RHEL_DVD	#挂载路径
enabled=1	#如果不写代表启用
gpgcheck=0	#gpg校验,因为是官网下载的镜像,不需要校验了

清除缓存

[root@NC65 home]# yum clean all
Loaded plugins: product-id, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Cleaning repos: RHEL6.3
Cleaning up Everything
[root@NC65 home]# 

形成本地缓存

[root@NC65 home]# yum makecache
Loaded plugins: product-id, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
RHEL6.3                                                                                                                                                | 4.0 kB     00:00 ... 
RHEL6.3/filelists_db                                                                                                                                   | 3.7 MB     00:00 ... 
RHEL6.3/primary_db                                                                                                                                     | 3.1 MB     00:00 ... 
RHEL6.3/other_db                                                                                                                                       | 1.6 MB     00:00 ... 
RHEL6.3/group_gz                                                                                                                                       | 204 kB     00:00 ... 
Metadata Cache Created
[root@NC65 home]# 

测试安装

[root@NC65 home]# yum install vim
Loaded plugins: product-id, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.x86_64 2:7.2.411-1.8.el6 will be installed
--> Finished Dependency ResolutionDependencies Resolved==============================================================================================================================================================================Package                                    Arch                                 Version                                          Repository                             Size
==============================================================================================================================================================================
Installing:vim-enhanced                               x86_64                               2:7.2.411-1.8.el6                                RHEL6.3                               892 kTransaction Summary
==============================================================================================================================================================================
Install       1 Package(s)Total download size: 892 k
Installed size: 1.8 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running TransactionInstalling : 2:vim-enhanced-7.2.411-1.8.el6.x86_64                                                                                                                      1/1 
Installed products updated.Verifying  : 2:vim-enhanced-7.2.411-1.8.el6.x86_64                                                                                                                      1/1 Installed:vim-enhanced.x86_64 2:7.2.411-1.8.el6                                                                                                                                       Complete!
[root@NC65 home]# 

本文标签: RHEL6配置本地源