Set up and Use Local Yum Repository

Just like the blogs I wrote before: Offline Package Installation I and Solve Conflicts in RPM installation, Use rpm or bare yum command to install downloaded rpm file works but I find somehow this will cause some maintenance problems, for example

Warning: RPMDB altered outside of yum.
** Found 51 pre-existing rpmdb problem(s), 'yum check' output follows:
bash-4.2.46-31.el7.x86_64 is a duplicate with bash-4.2.46-30.el7.x86_64
binutils-2.27-34.base.el7.x86_64 is a duplicate with binutils-2.27-28.base.el7_5.1.x86_64
coreutils-8.22-23.el7.x86_64 is a duplicate with coreutils-8.22-21.el7.x86_64
cryptsetup-libs-2.0.3-3.el7.x86_64 is a duplicate with cryptsetup-libs-1.7.4-4.el7.x86_64

I need to find a way that can automatically figure out the dependency chain, install the rpm required from download pool.

Create a yum repository

Install createrepo package:

yum install -y createrepo

Next, creates the necessary metadata for your Yum repository, as well as the sqlite database for speeding up yum operations. For example, /root/docker directory contains all rpms that install docker needs:

createrepo --database /root/docker

you will find it generates a folder called repodata that contains:

304457af78cd250275222993fa0da09256f64cc627c1e31fb3ec0848b28b28d8-primary.xml.gz
3d5ab2f5b706e5750e0ebe5802a278525da9cac4b9700634c51c2bfdf04a0d0e-primary.sqlite.bz2
421810a6b2d93e49bfe417404f937e17929f0d8c55953dbe8e96cbb19f40708d-filelists.sqlite.bz2
62c33f23a9485d74076d3db77064a9bdf606ce68d6702cd84fc5c6f1bcb48f01-other.sqlite.bz2
649e08cdba02219eb660f579b89e7a86cf805e4f989222cb1be556a8e0b82b5c-other.xml.gz
6cd1c3a2d6f385b1cbb878a88f86b8ef7e32d6e5c2c32c41a81f51464c3785c7-filelists.xml.gz
repomd.xml

Create yum repo file

To define a new repository, you can either add a [repository] section to the /etc/yum.conf file, or to a .repo file in the /etc/yum.repos.d/ directory. All files with the .repo file extension in this directory are read by yum, and it is recommended to define your repositories here instead of in /etc/yum.conf.

For example, create a docker-local.repo file in /etc/yum.repos.d/ directory, baseurl points to the folder that holds downloaded rpms:

[docker-local.repo]
name=docker-local
baseurl=file:///root/docker
enabled=1
gpgcheck=0

Then if you run yum repolist all, you will see this new added yum repository:

yum repolist all

Loaded plugins: product-id, search-disabled-repos
repo id                 repo name                          status
...
docker-local.repo       docker-local                       enabled:    134
...

Install using yum

Now you can install docker by running:

yum install -y docker-ce

yum will check local repository and launch dependencies for you.

Sometimes it‘s better to set enabled=0 in .repo file to disable it by default, so you can run:

yum --enablerepo=docker-local.repo install -y docker-ce

原文地址:https://www.cnblogs.com/chengdol/p/10483024.html

时间: 2024-11-09 18:05:44

Set up and Use Local Yum Repository的相关文章

YUM repository and package management: Complete Tutorial

Every operating system must have some or the other way to install a program. What's important is the fact that the user must not be given the responsibility of managing the overhead involved in the installation of the program. You would ask,what's th

使用Nexus配置Linux Yum Repository代理

一.使用场景 在生产环境中,我们不可能所有的服务器都能连接外网更新RPM包,比较理想的环境是:有一台Linux服务器可以连接外网,剩余的服务器通过这台YUM服务器更新.以前比较传统的做法是先把包下载到内网中的YUM服务器上,然后通过createrepo命令生成本地仓库,其余服务器通过HTTP访问这个链接,这种做法比较费时费事.有没有一种比较好的方式,让我们直接通过这台服务器代理连接到公网的163.阿里 YUM仓库呢,这就是本次介绍的Nexus代理.无论你的客户机是CentOS6还是CentOS7

如何使用 Yum Repository 安装指定版本的 MySQL

自从从使用 debian 系的 apt-get 转到使用 yum 工具之后一直不是很习惯,也没有去看过很多工具包安装的时候到底影响到了哪些文件等.这次借这次社区版 MySQL 安装来一并梳理一下. 首先我们前往 https://dev.mysql.com/downloads/repo/yum/ 下载对应的 yum repo 包. 这里可以看到 官方提供了4个 repo 包提供下载: 这里对应 3 个 linux 发行版.Red Hat Enterprise Linux 7 是红帽企业版7 后面是

CentOS7 Local yum的一次报错信息

说明:今天在火车上测试一个CentOS7下的一个服务,要用到yum配置,但是本机没有联网,所以考虑到配置本地yum,按照之前CentOS6下的常规方法,居然发现有报错.操作如下: 1)虚拟机下将CentOS7光盘加载到系统里面,然后挂载到本地的/localyum上 [[email protected] yum.repos.d]# mount /dev/cdrom /localyum 2)添加一个repo文件 [[email protected] ~]# cd /etc/yum.repos.d/

centos7增加local yum源

1.在/mnt下新建cdrom目录(createrepo /mnt 时要求目录可写) [[email protected] yum.repos.d]# mkdir /mnt/cdrom 2.修改文件 vi /etc/yum.repos.d/CentOS7-ISO.repo 内容如下: [cdrom]name=Local cdrom baseurl=file:///mnt/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-C

mount local yum source

system: CentOS 6.6 two steps: 1. mkdir /root/repo cp /etc/yum.repos.d/* /root/repo/ rm -rf /etc/yum.repos.d/* cp /root/repos/CentOS-Media.repo /etc/yum.repos.d/ vim Centos-Media.repo change it to baseurl=file:///media/CentOS/ gpgcheck=0 enabled=1 2.

change yum Repository

cd  /etc/yum.repos.d/ mv  CentOS-Base.repo CentOS-Base.repo.back wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/.repo yum makecache

Centos基于MySQL提供的Yum repository安装MySQL5.6

1.下载yum源 # wget http://dev.mysql.com/get/mysql57-community-release-el6-8.noarch.rpm 下载完成后,如下图所示: 2.安装yum包 2.1 查看此包要安装的文件 # rpm -qpl mysql80-community-release-el8-1.noarch.rpm 结果如下图所示: 2.2 安装 # rpm -ivh mysql80-community-release-el8-1.noarch.rpm 安装完成后

软件安装与管理--rpm、yum

一.rpm包管理器 1.介绍rpm 在linux系统中,服务是要通过程序来提供的,通过调用API接口编写好之后的源码包文件对于普通用户来说,安装起来较为繁琐.于是人们将源码在编译安装的环境下制作了更加高级的rpm包,它的最大特点是避免了对原软件包的编译安装,以更加简便的安装方式提供给用户.可以使用rpm(RedhatPackage Manager)管理器来进行安装. rpm包格式 2.rpm包管理器 <1>安装 rpm {-i|--install} [install-options] PACK