生产环境中,我们总是会遇到服务器无法连接外网的情况,这样,如果想安装某个应用,而这个应用依赖的其他类库又特别多,就很痛苦了。这个时候,就需要自己制作个本地的yum库,进行本地安装。本文将以Docker本地安装为例,详细介绍如何制作本地yum库。

  1、首先,在能够上网的、与不能上网服务器的Linux发行版本相同的服务器上,执行安装命令,得到安装所需的各种依赖包,如下:

[root@localhost ~]# yum install libdevmapper* docker
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
* base: mirrors.btte.net
* extras: mirrors.zju.edu.cn
* updates: mirrors.skyshe.cn
updates//x86_64/primary_db
Resolving Dependencies
--> Running transaction check
---> Package device-mapper-event-libs.x86_64 :1.02.-.el7 will be updated
--> Processing Dependency: device-mapper-event-libs = :1.02.-.el7 for package: :device-mapper-event-
---> Package device-mapper-event-libs.x86_64 :1.02.-.el7_2. will be an update
---> Package device-mapper-libs.x86_64 :1.02.-.el7 will be updated
--> Processing Dependency: device-mapper-libs = :1.02.-.el7 for package: :device-mapper-1.02.-.el
---> Package device-mapper-libs.x86_64 :1.02.-.el7_2. will be an update
---> Package docker.x86_64 :1.9.-.el7.centos will be installed
--> Processing Dependency: docker-forward-journald = 1.9.-.el7.centos for package: docker-1.9.-.el7
--> Processing Dependency: docker-selinux >= 1.9.-.el7.centos for package: docker-1.9.-.el7.centos.
--> Processing Dependency: libsystemd.so.(LIBSYSTEMD_209)(64bit) for package: docker-1.9.-.el7.centos
--> Processing Dependency: libsystemd.so.()(64bit) for package: docker-1.9.-.el7.centos.x86_64
---> Package lvm2-libs.x86_64 :2.02.-.el7 will be updated
--> Processing Dependency: lvm2-libs = :2.02.-.el7 for package: :lvm2-2.02.-.el7.x86_64
---> Package lvm2-libs.x86_64 :2.02.-.el7_2. will be an update
--> Running transaction check
---> Package device-mapper.x86_64 :1.02.-.el7 will be updated
---> Package device-mapper.x86_64 :1.02.-.el7_2. will be an update
---> Package device-mapper-event.x86_64 :1.02.-.el7 will be updated
---> Package device-mapper-event.x86_64 :1.02.-.el7_2. will be an update
---> Package docker-forward-journald.x86_64 :1.9.-.el7.centos will be installed
---> Package docker-selinux.x86_64 :1.9.-.el7.centos will be installed
---> Package lvm2.x86_64 :2.02.-.el7 will be updated
---> Package lvm2.x86_64 :2.02.-.el7_2. will be an update
--> Processing Dependency: device-mapper-persistent-data >= 0.5.- for package: :lvm2-2.02.-.el7_2.
---> Package systemd-libs.x86_64 :-.el7_1. will be updated
--> Processing Dependency: systemd-libs = -.el7_1. for package: systemd--.el7_1..x86_64
---> Package systemd-libs.x86_64 :-.el7_2. will be an update
--> Running transaction check
---> Package device-mapper-persistent-data.x86_64 :0.4.-.el7 will be updated
---> Package device-mapper-persistent-data.x86_64 :0.5.-.el7 will be an update
---> Package systemd.x86_64 :-.el7_1. will be updated
--> Processing Dependency: systemd = -.el7_1. for package: systemd-python--.el7_1..x86_64
--> Processing Dependency: systemd = -.el7_1. for package: systemd-sysv--.el7_1..x86_64
--> Processing Dependency: systemd = -.el7_1. for package: libgudev1--.el7_1..x86_64
---> Package systemd.x86_64 :-.el7_2. will be an update
--> Processing Dependency: kmod >= - for package: systemd--.el7_2..x86_64
--> Running transaction check
---> Package kmod.x86_64 :-.el7 will be updated
---> Package kmod.x86_64 :-.el7 will be an update
---> Package libgudev1.x86_64 :-.el7_1. will be updated
---> Package libgudev1.x86_64 :-.el7_2. will be an update
---> Package systemd-python.x86_64 :-.el7_1. will be updated
---> Package systemd-python.x86_64 :-.el7_2. will be an update
---> Package systemd-sysv.x86_64 :-.el7_1. will be updated
---> Package systemd-sysv.x86_64 :-.el7_2. will be an update
--> Processing Conflict: systemd--.el7_2..x86_64 conflicts initscripts < 9.49.-
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package initscripts.x86_64 :9.49.-.el7 will be updated
---> Package initscripts.x86_64 :9.49.-.el7_2. will be an update
--> Processing Conflict: systemd--.el7_2..x86_64 conflicts dracut < -
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package dracut.x86_64 :-.el7_1. will be updated
--> Processing Dependency: dracut = -.el7_1. for package: dracut-network--.el7_1..x86_64
--> Processing Dependency: dracut = -.el7_1. for package: dracut-config-rescue--.el7_1..x86
---> Package dracut.x86_64 :-.el7_2 will be an update
--> Running transaction check
---> Package dracut-config-rescue.x86_64 :-.el7_1. will be updated
---> Package dracut-config-rescue.x86_64 :-.el7_2 will be an update
---> Package dracut-network.x86_64 :-.el7_1. will be updated
---> Package dracut-network.x86_64 :-.el7_2 will be an update
--> Finished Dependency Resolution Dependencies Resolved =========================================================================================================
Package Arch Ver
=========================================================================================================
Installing:
docker x86_64 1.9
Updating:
device-mapper-event-libs x86_64 :
device-mapper-libs x86_64 :
dracut x86_64
initscripts x86_64 9.4
lvm2-libs x86_64 :
Installing for dependencies:
docker-forward-journald x86_64 1.9
docker-selinux x86_64 1.9
Updating for dependencies:
device-mapper x86_64 :
device-mapper-event x86_64 :
device-mapper-persistent-data x86_64 0.5
dracut-config-rescue x86_64
dracut-network x86_64
kmod x86_64 -
libgudev1 x86_64
lvm2 x86_64 :
systemd x86_64
systemd-libs x86_64
systemd-python x86_64
systemd-sysv x86_64 Transaction Summary
=========================================================================================================
Install Package (+ Dependent packages)
Upgrade Packages (+ Dependent packages) Total download size: M
Is this ok [y/d/N]: n
Exiting on user command
Your transaction was saved, rerun it with:
yum load-transaction /tmp/yum_save_tx.--06.10-.56BPrh.yumtx
[root@localhost ~]# yum install libdevmapper* docker
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* extras: mirrors.zju.edu.cn
* updates: mirrors.skyshe.cn
Resolving Dependencies
--> Running transaction check
---> Package device-mapper-event-libs.x86_64 :1.02.-.el7 will be updated
--> Processing Dependency: device-mapper-event-libs = :1.02.-.el7 for package: :device-mapper-event-1.02.-.el7.x86_64
---> Package device-mapper-event-libs.x86_64 :1.02.-.el7_2. will be an update
---> Package device-mapper-libs.x86_64 :1.02.-.el7 will be updated
--> Processing Dependency: device-mapper-libs = :1.02.-.el7 for package: :device-mapper-1.02.-.el7.x86_64
---> Package device-mapper-libs.x86_64 :1.02.-.el7_2. will be an update
---> Package docker.x86_64 :1.9.-.el7.centos will be installed
--> Processing Dependency: docker-forward-journald = 1.9.-.el7.centos for package: docker-1.9.-.el7.centos.x86_64
--> Processing Dependency: docker-selinux >= 1.9.-.el7.centos for package: docker-1.9.-.el7.centos.x86_64
--> Processing Dependency: libsystemd.so.(LIBSYSTEMD_209)(64bit) for package: docker-1.9.-.el7.centos.x86_64
--> Processing Dependency: libsystemd.so.()(64bit) for package: docker-1.9.-.el7.centos.x86_64
---> Package lvm2-libs.x86_64 :2.02.-.el7 will be updated
--> Processing Dependency: lvm2-libs = :2.02.-.el7 for package: :lvm2-2.02.-.el7.x86_64
---> Package lvm2-libs.x86_64 :2.02.-.el7_2. will be an update
--> Running transaction check
---> Package device-mapper.x86_64 :1.02.-.el7 will be updated
---> Package device-mapper.x86_64 :1.02.-.el7_2. will be an update
---> Package device-mapper-event.x86_64 :1.02.-.el7 will be updated
---> Package device-mapper-event.x86_64 :1.02.-.el7_2. will be an update
---> Package docker-forward-journald.x86_64 :1.9.-.el7.centos will be installed
---> Package docker-selinux.x86_64 :1.9.-.el7.centos will be installed
---> Package lvm2.x86_64 :2.02.-.el7 will be updated
---> Package lvm2.x86_64 :2.02.-.el7_2. will be an update
--> Processing Dependency: device-mapper-persistent-data >= 0.5.- for package: :lvm2-2.02.-.el7_2..x86_64
---> Package systemd-libs.x86_64 :-.el7_1. will be updated
--> Processing Dependency: systemd-libs = -.el7_1. for package: systemd--.el7_1..x86_64
---> Package systemd-libs.x86_64 :-.el7_2. will be an update
--> Running transaction check
---> Package device-mapper-persistent-data.x86_64 :0.4.-.el7 will be updated
---> Package device-mapper-persistent-data.x86_64 :0.5.-.el7 will be an update
---> Package systemd.x86_64 :-.el7_1. will be updated
--> Processing Dependency: systemd = -.el7_1. for package: systemd-python--.el7_1..x86_64
--> Processing Dependency: systemd = -.el7_1. for package: systemd-sysv--.el7_1..x86_64
--> Processing Dependency: systemd = -.el7_1. for package: libgudev1--.el7_1..x86_64
---> Package systemd.x86_64 :-.el7_2. will be an update
--> Processing Dependency: kmod >= - for package: systemd--.el7_2..x86_64
--> Running transaction check
---> Package kmod.x86_64 :-.el7 will be updated
---> Package kmod.x86_64 :-.el7 will be an update
---> Package libgudev1.x86_64 :-.el7_1. will be updated
---> Package libgudev1.x86_64 :-.el7_2. will be an update
---> Package systemd-python.x86_64 :-.el7_1. will be updated
---> Package systemd-python.x86_64 :-.el7_2. will be an update
---> Package systemd-sysv.x86_64 :-.el7_1. will be updated
---> Package systemd-sysv.x86_64 :-.el7_2. will be an update
--> Processing Conflict: systemd--.el7_2..x86_64 conflicts initscripts < 9.49.-
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package initscripts.x86_64 :9.49.-.el7 will be updated
---> Package initscripts.x86_64 :9.49.-.el7_2. will be an update
--> Processing Conflict: systemd--.el7_2..x86_64 conflicts dracut < -
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package dracut.x86_64 :-.el7_1. will be updated
--> Processing Dependency: dracut = -.el7_1. for package: dracut-network--.el7_1..x86_64
--> Processing Dependency: dracut = -.el7_1. for package: dracut-config-rescue--.el7_1..x86_64
---> Package dracut.x86_64 :-.el7_2 will be an update
--> Running transaction check
---> Package dracut-config-rescue.x86_64 :-.el7_1. will be updated
---> Package dracut-config-rescue.x86_64 :-.el7_2 will be an update
---> Package dracut-network.x86_64 :-.el7_1. will be updated
---> Package dracut-network.x86_64 :-.el7_2 will be an update
--> Finished Dependency Resolution Dependencies Resolved =========================================================================================================
Package Arch Version Repository Size
=========================================================================================================
Installing:
docker x86_64 1.9.-.el7.centos extras M
Updating:
device-mapper-event-libs x86_64 :1.02.-.el7_2. updates k
device-mapper-libs x86_64 :1.02.-.el7_2. updates k
dracut x86_64 -.el7_2 updates k
initscripts x86_64 9.49.-.el7_2. updates k
lvm2-libs x86_64 :2.02.-.el7_2. updates k
Installing for dependencies:
docker-forward-journald x86_64 1.9.-.el7.centos extras k
docker-selinux x86_64 1.9.-.el7.centos extras k
Updating for dependencies:
device-mapper x86_64 :1.02.-.el7_2. updates k
device-mapper-event x86_64 :1.02.-.el7_2. updates k
device-mapper-persistent-data x86_64 0.5.-.el7 base k
dracut-config-rescue x86_64 -.el7_2 updates k
dracut-network x86_64 -.el7_2 updates k
kmod x86_64 -.el7 base k
libgudev1 x86_64 -.el7_2. updates k
lvm2 x86_64 :2.02.-.el7_2. updates 1.0 M
systemd x86_64 -.el7_2. updates 5.1 M
systemd-libs x86_64 -.el7_2. updates k
systemd-python x86_64 -.el7_2. updates k
systemd-sysv x86_64 -.el7_2. updates k Transaction Summary
=========================================================================================================
Install Package (+ Dependent packages)
Upgrade Packages (+ Dependent packages) Total download size: M
Is this ok [y/d/N]:

  2、下载对应版本的rpm包,网址:

http://rpmfind.net/linux/rpm2html/search.php

  3、制作本地yum库。将全部的rpm包拷贝到一个文件夹中,例如docker_rpms,执行如下命令:

[root@localhost test]# ls
docker_rpms
[root@localhost test]# createrepo .
Spawning worker with pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost test]# ls
docker_rpms repodata

  4、编辑docker.repo文件

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
# [base]
name=CentOS-$releasever - Base
baseurl=file:///home/dockeryum
gpgcheck=
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 [update]
name=CentOS-$releasever - update
baseurl=file:///home/dockeryum
gpgcheck=
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

  5、将docker_rpms文件夹、repodata文件夹、docker.repo拷贝到/home/dockeryum(因为docker.repo文件中做的如此配置)文件夹下。执行如下操作:

[root@localhost home]# ls
dockeryum laizy
[root@localhost home]# cp -r /etc/yum.repos.d/ /etc/yum.repos.d.bak (备份原始yum源)
[root@localhost home]# rm -rf /etc/yum.repos.d/* (清空原始yum源)
[root@localhost home]# cp /home/dockeryum/docker.repo /etc/yum.repos.d/ (拷贝自己写的yum源)
[root@localhost home]# ll /etc/yum.repos.d/
total 4
-rw-r--r--. 1 root root 682 May 6 10:26 docker.repo
[root@localhost home]# yum install libdevmapper* docker (yum安装)
Loaded plugins: fastestmirror, langpacks
Existing lock /var/run/yum.pid: another copy is running as pid 13870.
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 48 M RSS (922 MB VSZ)
Started: Fri May 6 10:23:42 2016 - 04:13 ago
State : Sleeping, pid: 13870
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 48 M RSS (922 MB VSZ)
Started: Fri May 6 10:23:42 2016 - 04:15 ago
State : Running, pid: 13870
^C Exiting on user cancel.
[root@localhost home]# kill -9 13870
[root@localhost home]# yum install libdevmapper* docker
Loaded plugins: fastestmirror, langpacks
base | 2.9 kB 00:00:00
update | 2.9 kB 00:00:00
(1/2): base/primary_db | 23 kB 00:00:00
(2/2): update/primary_db | 23 kB 00:00:00
Loading mirror speeds from cached hostfile
Package 7:device-mapper-event-libs-1.02.93-3.el7.x86_64 already installed and latest version
Package 7:device-mapper-libs-1.02.93-3.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package docker.x86_64 0:1.8.2-7.el7.centos will be installed
--> Processing Dependency: docker-selinux >= 1.8.2-7.el7.centos for package: docker-1.8.2-7.el7.centos.x86_64
--> Running transaction check
---> Package docker-selinux.x86_64 0:1.8.2-7.el7.centos will be installed
--> Finished Dependency Resolution Dependencies Resolved =========================================================================================================
Package Arch Version Repository Size
=========================================================================================================
Installing:
docker x86_64 1.8.2-7.el7.centos base 8.7 M
Installing for dependencies:
docker-selinux x86_64 1.8.2-7.el7.centos base 61 k Transaction Summary
=========================================================================================================
Install 1 Package (+1 Dependent package) Total download size: 8.7 M
Installed size: 37 M
Is this ok [y/d/N]: y
Downloading packages:
---------------------------------------------------------------------------------------------------------
Total 160 MB/s | 8.7 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : docker-selinux-1.8.2-7.el7.centos.x86_64 1/2
restorecon: lstat(/var/lib/docker) failed: No such file or directory
warning: %post(docker-selinux-1.8.2-7.el7.centos.x86_64) scriptlet failed, exit status 255
Non-fatal POSTIN scriptlet failure in rpm package docker-selinux-1.8.2-7.el7.centos.x86_64
Installing : docker-1.8.2-7.el7.centos.x86_64 2/2
Verifying : docker-1.8.2-7.el7.centos.x86_64 1/2
Verifying : docker-selinux-1.8.2-7.el7.centos.x86_64 2/2 Installed:
docker.x86_64 0:1.8.2-7.el7.centos Dependency Installed:
docker-selinux.x86_64 0:1.8.2-7.el7.centos Complete!
[root@localhost home]# docker -v
Docker version 1.8.2, build bb472f0/1.8.2

  安装完成!

本地yum库制作及本地安装Docker的更多相关文章

  1. yum_rpm(利用dvd建立本地yum库)

    #wget "http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os" 建立起了index.html ...

  2. 本地yum库的搭建

    1.建立yum服务器 yum服务器可以使用http或者ftp的方式,我们这里选择使用http的方式进行,需要先进行httpd的安装 # yum install httpd 在本地建立包目录 # mkd ...

  3. Linux软件源书写格式解析及本地yum源制作

    1.Debian类系统 配置文件:/etc/apt/sources.list 例子:deb https://mirrors.aliyun.com/kali kali-rolling main cont ...

  4. 本地YUM源制作

    YUM相关概念 什么是YUM YUM(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器.基于RPM包管 ...

  5. 【从零开始搭建K8S】【第一篇】CentOS7.6离线安装Docker(手动安装以及基于yum本地源安装)

    下载CentOS7.6以及最小化安装CentOS7.6版本.由于CentOS属于开源软件,在国内也有很多的mirror站点可供下载,我选择的是华为站点进行下载:http://mirrors.huawe ...

  6. Yum本地Rpm库设置

    http://blog.csdn.net/dc_726/article/details/8497188   1 Yum对光盘的支持 查看/etc/yum.repos.d/CentOS-Media.re ...

  7. Centos制作本地yum源

    本地YUM源制作 1. YUM相关概念 1.1. 什么是YUM YUM(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shel ...

  8. 制作本地yum源

    镜像源是centos当中下载相关软件的地址,我们可以通过制作我们自己的镜像源指定我们去哪里下载impala的rpm包,这里我们使用httpd这个软件来作为服务端,启动httpd的服务来作为我们镜像源的 ...

  9. CentOS 6.5本地yum源、局域网离线yum仓库(断网情况下轻松安装各种依赖包)

    在工作中, 公司的服务器大部分都禁止连接外网的,初始化系统,测试某些产品时,往往缺一些软件或依赖包,一个个上传到机器,如此浪费时间,浪费金钱,en...yum能够自动查找并解决rpm包之间的依赖关系, ...

随机推荐

  1. HTML静态网页 图片热点、框架、表单

    图片热点: 规划出图片上的一个区域,可以做出超链接,直接点击图片区域就可以完成跳转的效果. 示例: 网页划区: 在一个网页里,规划出一个区域用来展示另一个网页的内容. 示例: 框架: 1.frames ...

  2. 手机横屏竖屏css

    @media是css3中新定义的,功能非常强大,顾名思义PC是无法匹配横竖屏的,所以orientation只对移动设备起效. 1.头部声明 复制代码 代码如下: <meta name=" ...

  3. Uc爆破工具

    #coding:utf-8 import requests import sys from threading import Thread from Queue import Queue NUM=5 ...

  4. [读书]10g/11g编程艺术深入体现结构学习笔记(持续更新...)

    持续更新...) 第8章 1.在过程性循环中提交更新容易产生ora-01555:snapshot too old错误.P257 (这种情况我觉得应该是在高并发的情况下才会产生) 假设的一个场景是系统一 ...

  5. 使用JDBC批量保存数据(JdbcDaoSupport,JdbcTemplete)

    最近做的一个项目中用到了Hibernate的,然后数据库批量插入数据的时候就使用到了hibernate的批处理,但是效率比较低,看网上说还有一些限制,要禁止二级缓存,还要多一个batch_size的配 ...

  6. Linux下动态库(.so)和静态库(.a) 的区别

    静态库在程序编译时会被连接到目标代码中,程序运行时将不再需要该静态库.编译之后程序文件大,但加载快,隔离性也好.动态库在程序编译时并不会被连接到目标代码中,而是在程序运行是才被载入,因此在程序运行时还 ...

  7. vim正则表达式(转)

    Vim中的正则表达式功能很强大,如果能自由运用,则可以完成很多难以想象的操作. 如果你比较熟悉Perl的正规表达式,可以直接参照与Perl正则表达式的区别一节. 一.使用正则表达式的命令 使用正则表达 ...

  8. Yii源码阅读笔记(二十五)

    Module类中剩余部分代码,通过控制器ID实例化当前模块的控制器,当前模块的Action方法的前置和后置方法: /** * This method is invoked right before a ...

  9. NEC学习 ---- 模块 - tab[含标题]

    简要介绍, 默认居左, Tab不定宽,  “标题”和“更多”可删, 扩展类可以自由组合, 依赖于reset.css(之前的模块以及布局都依赖这个css) 那么这个效果是怎么实现的呢? CSS代码: . ...

  10. Fixing “WARNING: UNPROTECTED PRIVATE KEY FILE!” on Linux

    If you are getting this error then you probably reset the permissions on your hidden .ssh directory ...