Redhat 本地云源配置

来源:互联网 发布:全美国际教育协会 知乎 编辑:程序博客网 时间:2024/05/29 08:06

后面的列子帮助可能更大,大家看到的如果有什么想问的,或者有什么觉得难配的环境,可以告诉我,大家一起研究下。
这个特别适用没有网络或者网络条件不好的情况。
放入redhat的镜像(这个是指在vm上挂载镜像)

新建/media/cdrom

[root@localhost /]# mkdir /media/cdrom

挂载镜像到文件到/media/cdrom

[root@localhost /]# mount /dev/cdrom  /media/cdrom[root@localhost /]# cd /etc/yum.repos.d/

备份*.repo文件

[root@localhost yum.repos.d]# lsrhel-source.repo[root@localhost yum.repos.d]# cp rhel-source.repo local.repo[root@localhost yum.repos.d]# lslocal.repo  rhel-source.repo[root@localhost yum.repos.d]# mv rhel-source.repo  rhel-source.repo.bak[root@localhost yum.repos.d]# lslocal.repo  rhel-source.repo.bak

编辑 local.repo文件

[root@localhost yum.repos.d]# vim local.repo

插入如下内容

[rhel-source]name=This is a local repobaseurl=file:///media/cdrom/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

清除缓存

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

建立新缓存

[root@localhost yum.repos.d]# yum makecache

测试

[root@localhost yum.repos.d]#  yum install –y sendmail

另一种配置方式

df -humount /media/系统名mount /dev/cdrom /mnt cd /etc/yum.repos.d/vim rhel-source.repo
[rhel-source]name=Red Hat Enterprise Linux $releasever - $basearch - Sourcebaseurl=file:///mntenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

简单例子:

[root@localhost /]# mkdir /media/cdrom[root@localhost /]# lsbin   dev  home  lib64       media  opt   root  selinux  sys  usrboot  etc  lib   lost+found  mnt    proc  sbin  srv      tmp  var[root@localhost /]# mount /dev/cdrom  /media/cdrommount: block device /dev/sr1 is write-protected, mounting read-only[root@localhost /]# cd /etc/yum.repos.d/[root@localhost yum.repos.d]# lsrhel-source.repo[root@localhost yum.repos.d]# cp rhel-source.repo local.repo[root@localhost yum.repos.d]# lslocal.repo  rhel-source.repo[root@localhost yum.repos.d]# mv rhel-source.repo  rhel-source.repo.bak[root@localhost yum.repos.d]# lslocal.repo  rhel-source.repo.bak[root@localhost yum.repos.d]# vim local.repo[root@localhost yum.repos.d]#  yum clean allLoaded plugins: product-id, refresh-packagekit, security, subscription-managerThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.Cleaning repos: rhel-sourceCleaning up Everything[root@localhost yum.repos.d]# um makecache-bash: um: command not found[root@localhost yum.repos.d]# yum makecacheLoaded plugins: product-id, refresh-packagekit, security, subscription-managerThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.rhel-source                                              | 3.9 kB     00:00 ...rhel-source/group_gz                                     | 204 kB     00:00 ...rhel-source/filelists_db                                 | 3.7 MB     00:00 ...rhel-source/primary_db                                   | 3.1 MB     00:00 ...rhel-source/other_db                                     | 1.5 MB     00:00 ...Metadata Cache Created[root@localhost yum.repos.d]#  yuminstall –y sendmail-bash: yuminstall: command not found[root@localhost yum.repos.d]#  yum install –y sendmailLoaded plugins: product-id, refresh-packagekit, security, subscription-managerThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.Setting up Install ProcessResolving Dependencies--> Running transaction check---> Package sendmail.x86_64 0:8.14.4-8.el6 will be installed--> Processing Dependency: procmail for package: sendmail-8.14.4-8.el6.x86_64--> Processing Dependency: libhesiod.so.0()(64bit) for package: sendmail-8.14.4-8.el6.x86_64--> Running transaction check---> Package hesiod.x86_64 0:3.1.0-19.el6 will be installed---> Package procmail.x86_64 0:3.22-25.1.el6 will be installed--> Finished Dependency ResolutionDependencies Resolved================================================================================ Package         Arch          Version                 Repository          Size================================================================================Installing: sendmail        x86_64        8.14.4-8.el6            rhel-source        717 kInstalling for dependencies: hesiod          x86_64        3.1.0-19.el6            rhel-source         20 k procmail        x86_64        3.22-25.1.el6           rhel-source        163 kTransaction Summary================================================================================Install       3 Package(s)Total download size: 900 kInstalled size: 1.9 MIs this ok [y/N]: nExiting on user Command[root@localhost yum.repos.d]#
0 0