Linux本地yum源配置

每次用rpm包安装软件是总有依赖包的出现,使用yum从光盘安装软件可以解决包的依赖关系:

  • 安装前准备:
    系统镜像,比如rhel-server-7.2-x86_64-dvd.iso,即系统安装时使用的的系统镜像
  • 挂载镜像
mkdir /mnt/cdrom 
mount -o loop /opt/rhel-server-5.7-x86_64-dvd.iso  /mnt/cdrom/
#看到下面类似的提示说明成功了
#mount: block device /dev/sr0 is write-protected, mounting read-only
#在/mnt/cdrom 目录下就有iso文件里的所有内容,而不是iso文件。需要时也可以加上参数iso9660
#mount -t iso9660 -o loop xxx.iso /some/path
  • 编辑yum源配置
# myself.repo 是自定义的名称,随便取
# vi /etc/yum.repos.d/myself.repo
[myself]
name=RedHat    # 名称,自定义
baseurl=file:///mnt/cdrom # yum 软件包路径
enabled=1 # 启用这个仓库
gpgckeck=0 # 不启用包检查
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release 
  • 测试仓库
[root@localhost ~]# yum clean all # 清除所有包
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: base
Cleaning up everything
Cleaning up list of fastest mirrors
[root@localhost ~]# yum repolist  # 列出仓库列表
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
base                                                                                                                                       | 4.1 kB  00:00:00     
(1/2): base/group_gz                                                                                                                       | 136 kB  00:00:00     
(2/2): base/primary_db                                                                                                                     | 3.6 MB  00:00:00     
Determining fastest mirrors
repo id                                                                       repo name                                                                     status
base                                                                          RedHat                                                                        4,620
# 在仓库列表里可以看到RedHat的源,说明源配置成功

参考博客:
RHEL7解决无法使用YUM源问题

你可能感兴趣的:(Linux本地yum源配置)