ITPub博客

首页 > Linux操作系统 > Linux操作系统 > RHEL6.5使用安装光盘搭建本地YUM

RHEL6.5使用安装光盘搭建本地YUM

原创 Linux操作系统 作者:stonebox1122 时间:2015-07-24 22:00:22 0 删除 编辑
1、挂载光盘
[root@linuxclient ~]# mount /dev/cdrom /media/
mount: block device /dev/sr0 is write-protected, mounting read-only

2、备份系统的repo文件
[root@linuxclient ~]# cd /etc/yum.repos.d/
[root@linuxclient yum.repos.d]# ls
CentOS6-Base-163.repo  rhel-source.repo
[root@linuxclient yum.repos.d]# mkdir bak
[root@linuxclient yum.repos.d]# mv *.repo bak/
[root@linuxclient yum.repos.d]# ls
bak

3、创建本地的repo文件
[root@linuxclient yum.repos.d]# vim local.repo
[root@linuxclient yum.repos.d]# cat local.repo
[Local]
baseurl=file:///media/Server
gpgcheck=1
enabled=1

4、导入密钥(如果上面的gpgcheck=0,这一步可以跳过)
[root@linuxclient yum.repos.d]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*

5、清除缓存
[root@linuxclient yum.repos.d]# yum clean all
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.
Repository 'Local' is missing name in configuration, using id
Cleaning repos: Local
Cleaning up Everything

6、重新生成缓存
[root@linuxclient yum.repos.d]# 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.
Repository 'Local' is missing name in configuration, using id
Local                                                                                                             | 3.9 kB     00:00 ...
Local/group_gz                                                                                                    | 204 kB     00:00 ...
Local/filelists_db                                                                                                | 3.8 MB     00:00 ...
Local/primary_db                                                                                                  | 3.1 MB     00:00 ...
Local/other_db                                                                                                    | 1.6 MB     00:00 ...
Metadata Cache Created

7、根据以上步骤编写脚本

[root@precise ~]# cat createlocalyum.sh

#!/bin/bash

cd /etc/yum.repos.d/

mkdir bak

mv *.repo bak/

cat << EOF > local.repo

[Local]

baseurl=file:///media/Server

gpgcheck=1

enabled=1

EOF

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*

yum clean all

yum makecache


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28536251/viewspace-1750096/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-12-13

  • 博文量
    204
  • 访问量
    1189979