Linux下对于软件包的管理使用rpm管理方式。直接使用rpm包管理工具来进行rpm包的安装,升级,卸载时,对于最让人头疼的莫过与包之间的依赖关系。yum作为一个rpm包前端管理工具,可以自动处理依赖性关系,一次安装所有依赖的软件包,并且支持在线下载、安装、卸载、升级rpm软件包。本文主要描述基于本机,本地yum服务器配置yum源,以及基于公网yum源配置本地客户端,供大家参考。

一、yum源实现的三个机制

1、需要有一个包含各种rpm安装文件的软件仓库(即yum源)
2、有软件仓库的仓库数据库(repodata),其中收集了软件仓库中所有rpm包的头部信息(每个rpm包的包头信息包含了该包的描述,功能,提供的文件,依赖关系等信息);
3、有软件仓库的地址等信息

二、配置本地yum源

创建rpm包文件存放目录及复制相关文件
# mkdir -pv /mnt/CentOS7_ISO
# cd /run/media/robin/CentOS\ 7\ x86_64/
# cp -R * /mnt/CentOS7_ISO/ 修改yum源repo文件配置
# cd /etc/yum.repos.d/
# mkdir old
# mv *.repo old 编辑repo配置文件
# vi /etc/yum.repos.d/local.repo
[local-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/CentOS7_ISO/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 清空yum缓存目录
[root@centos7-router yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: local-media
Cleaning up everything
Cleaning up list of fastest mirrors 生成yum元数据
[root@centos7-router yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks
local-media | 3.6 kB 00:00:00
(1/4): local-media/group_gz | 155 kB 00:00:00
(2/4): local-media/primary_db | 2.8 MB 00:00:00
(3/4): local-media/other_db | 1.2 MB 00:00:00
(4/4): local-media/filelists_db | 2.9 MB 00:00:00
Determining fastest mirrors
Metadata Cache Created ###提示元数据缓存创建成功 查看本机yum repo 仓库
[root@centos7-router ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id repo name status
local-media CentOS-7 - Media 3,723
repolist: 3,723

二、基于ftp方式配置本地yum发布源

为本机配置ftp服务器,将其发布供网络其它客户端作为yum源

安装vsftp
[root@centos7-router ~] # yum -y install vsftpd
[root@centos7-router ~] # vi /etc/selinux/config
SELINUX=disabled
[root@centos7-router ~] # setenforce 0 ###立即生效 修改ftp配置文件
[root@centos7-router ~] # vi /etc/vsftpd/vsftpd.conf
anon_root=/mnt/CentOS7_ISO 启动ftp
[root@centos7-router ~]# systemctl start vsftpd
[root@centos7-router ~]# systemctl enable vsftpd 测试ftp服务可用性
[root@centos7-router ~]# ftp localhost
Trying ::1...
Connected to localhost (::1).
220 (vsFTPd 3.0.2)
Name (localhost:root): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
229 Entering Extended Passive Mode (|||41973|).
150 Here comes the directory listing.
-r--r--r-- 1 0 0 14 Sep 14 09:06 CentOS_BuildTag
dr-xr-xr-x 3 0 0 33 Sep 14 09:06 EFI ### Author : Leshami
-r--r--r-- 1 0 0 215 Sep 14 09:06 EULA ### Blog : http://blog.csdn.net/leshami
-r--r--r-- 1 0 0 18009 Sep 14 09:06 GPL
dr-xr-xr-x 2 0 0 41 Sep 14 09:06 LiveOS
dr-xr-xr-x 2 0 0 200704 Sep 14 09:08 Packages
-r--r--r-- 1 0 0 1690 Sep 14 09:08 RPM-GPG-KEY-CentOS-7
-r--r--r-- 1 0 0 1690 Sep 14 09:08 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r-- 1 0 0 2883 Sep 14 09:08 TRANS.TBL
dr-xr-xr-x 3 0 0 54 Sep 14 09:06 images
dr-xr-xr-x 2 0 0 4096 Sep 14 09:06 isolinux
dr-xr-xr-x 2 0 0 4096 Sep 14 09:08 repodata
226 Directory send OK. 配置防火墙
[root@centos7-router ~]# firewall-cmd --add-service=ftp --permanent
[root@centos7-router ~]# firewall-cmd --add-service=ftp
[root@centos7-router ~]# systemctl reload firewalld.service

三、基于http方式配置本地yum发布源

除了支持ftp方式外,也可以通过http方式将其发布供网络其它客户端作为yum源

安装httpd
[root@centos7-router ~]# yum install httpd
[root@centos7-router ~]# systemctl enable httpd
[root@centos7-router ~]# systemctl start httpd 配置防火墙
[root@centos7-router ~]# firewall-cmd --add-service=http --permanent
[root@centos7-router ~]# firewall-cmd --add-service=http
[root@centos7-router ~]# systemctl reload firewalld.service 将CentOS 光盘文件copy到/var/www/html/repo
此处使用了链接方式,将其链接到已经在本地磁盘的/mnt/CentOS7_ISO
[root@centos7-router ~]# ln -sv /mnt/CentOS7_ISO /var/www/html/repo
‘/var/www/html/repo’ -> ‘/mnt/CentOS7_ISO’
[root@centos7-router ~]# ls /var/www/html/repo
CentOS_BuildTag EULA images LiveOS repo RPM-GPG-KEY-CentOS-7 TRANS.TBL
EFI GPL isolinux Packages repodata RPM-GPG-KEY-CentOS-Testing-7 通过浏览器校验,此时应该可以看到文件列表(此处略) http://192.168.1.175/repo

四、配置本地网络yum源客户端(ftp方式)

配置客户端
[root@centos7-web ~]# cd /etc/yum.repos.d/
[root@centos7-web ~]# mkdir old
[root@centos7-web ~]# mv *.repo old [root@centos7-web yum.repos.d]# vi /etc/yum.repos.d/intranet.repo
[intranet-media] #库名称
name=CentOS-$releasever - Media #名称描述
baseurl=ftp://172.24.8.254 #yum源目录,源地址
gpgcheck=0 #检查GPG-KEY,0为不检查,1为检查
enabled=1 #是否用该yum源,0为禁用,1为使用
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #gpgcheck=0时无需配置 [root@centos7-web yum.repos.d]# yum clean all
[root@centos7-web yum.repos.d]# yum makecache
[root@centos7-web yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id repo name status
intranet-media CentOS-7 - Media 3,723
repolist: 3,723 测试yum配置
[root@centos7-web yum.repos.d]# yum install ftp -y

四、配置本地网络yum源客户端(http方式)

配置客户端repo文件
[root@centos7-web ~]# mv /etc/yum.repos.d/intranet.repo /etc/yum.repos.d/old/
[root@centos7-web ~]# yum-config-manager --add-repo=http://192.168.1.175/repo
Loaded plugins: fastestmirror, langpacks
adding repo from: http://192.168.1.175/repo [192.168.1.175_repo]
name=added from: http://192.168.1.175/repo
baseurl=http://192.168.1.175/repo
enabled=1 [root@centos7-web ~]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: 192.168.1.175_repo
Cleaning up everything
Cleaning up list of fastest mirrors [root@centos7-web ~]# yum makecache
Loaded plugins: fastestmirror, langpacks
192.168.1.175_repo | 3.6 kB 00:00:00
(1/4): 192.168.1.175_repo/group_gz | 155 kB 00:00:00
(2/4): 192.168.1.175_repo/primary_db | 2.8 MB 00:00:00
(3/4): 192.168.1.175_repo/other_db | 1.2 MB 00:00:00
(4/4): 192.168.1.175_repo/filelists_db | 2.9 MB 00:00:01
Determining fastest mirrors
Metadata Cache Created [root@centos7-web ~]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id repo name status
192.168.1.175_repo added from: http://192.168.1.175/repo 3,723
repolist: 3,723

五、配置阿里云、epel yum源客户端

# wget -O /etc/yum.repos.d/aliyun.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# rpm -Uvh http://mirrors.kernel.org/fedora-epel/epel-release-latest-7.noarch.rpm
# yum makecache

六、虚拟机环境直接使用iso文件充当yum源(补充@20171110)

如下为光盘iso文件路径,可以直接将其配置到baseurl,最大的好处是,可以节省虚拟机磁盘空间占用。如下:
baseurl=”file:///run/media/robin/CentOS 7 x86_64”

centos 7 yum configuration; yum localinstall的更多相关文章

  1. CentOS 软件安装(yum 和 rpm)

    CentOS 软件安装方法 常用的分为两种, - yum install 安装包名 : 类似于 Debian 的 “ apt-get install 安装包名 “ - rpm -i rmp文件名 :类 ...

  2. centos 系统软件包管理 yum 本地yum配置 扩展源epel rpm 清除yum缓存 yum provides "*/vim" 第十节课

    centos  系统软件包管理  yum 本地yum配置  扩展源epel  rpm  清除yum缓存  yum provides "*/vim"   第十节课 你不能保证可逆化操 ...

  3. [转载]CentOS 7 创建本地YUM源

    本文中的"本地YUM源"包括三种类型:一是直接使用CentOS光盘作为本地yum源,优点是简单便捷,缺点是光盘软件包可能不完整(centos 7 Everything 总共才6.5 ...

  4. centos 7 升级后yum install出现Exiting on user cancel

    centos 7 升级后yum install出现Exiting on user cancel centos 7.x升级后用yum install进行安装时经常出现Exiting on user ca ...

  5. centos 用dvd创建yum 仓库

    环境:CentOS 6.0 默认的yum是以网络来安装的,在没有网络或者网速不佳的情况下,通过yum来安装软件是意见非常痛苦的事情.其实对于CentOS DVD来说,里面提供的软件就足以满足我们的需要 ...

  6. 为CentOS 6 配置本地YUM源

    在网上找了很多为CentOS 6配置本地YUM源的方法,其中有很多是与网络相关的,我只想配个自己用的,结果就发现这个方法比较简单实用,就转过来了. 环境:CentOS 6.0 默认的yum是以网络来安 ...

  7. 将CentOS配置成本地yum

    默认的yum是以网络来安装的,在没有网络或者网速不佳的情况下,通过yum来安装软件是意见非常痛苦的事情.其实对于CentOS DVD来说,里面提供的软件就足以满足我们的需要了,而且DVD里的软件版本都 ...

  8. RHEL/CentOS/Fedora常用的 CentOS 5/6/7 yum 源(EPEL、Remi、RPMForge、RPMFusion, ius,163,sohu,阿里云)配置

    RHEL以及他的衍生发行版如CentOS.Scientific Linux为了稳定,官方的rpm repository提供的rpm包往往是很滞后的,当然了,这样做这是无可厚非的,毕竟这是服务器版本,安 ...

  9. [转]CENTOS 6.5 配置YUM安装NGINX+服务器负载均衡

    原文连接: CENTOS 6.5 配置YUM安装NGINX  http://blog.sina.com.cn/s/blog_69f467b70102uyux.html 参考博文: Centos下安装. ...

随机推荐

  1. swift开发之--代理协议的使用

    swift代理的使用,和oc版本有区别,区别还是蛮大的,不过和oc一样都是用于反向传值: 实现如下: 1,声明两个类 2,实现流程,viewcontroller页面点击按钮进入firstVC页面,然后 ...

  2. 【代码审计】QYKCMS_v4.3.2 任意文件读取漏洞分析

      0x00 环境准备 QYKCMS官网:http://www.qykcms.com/ 网站源码版本:QYKCMS_v4.3.2(企业站主题) 程序源码下载:http://bbs.qingyunke. ...

  3. SpringBoot(六)-- 静态资源处理

    1.Spring Boot 的默认资源映射 其中默认配置的 /** 映射到 /static (或/public./resources./META-INF/resources), 其中默认配置的 /we ...

  4. Django SimpleCMDB WSGI

    一.WSGI 介绍 (1) 在前面的学习中,我们是通过 python manage.py runserver 0.0.0.0:8000 来启动并访问开发服务器的:(2) 但在实际中我们是通过直接访问 ...

  5. Linux命令之乐--wget

    常见参数: 参数 作用 -b 后台下载模式. -P 下载到指定目录. -t  最大尝试次数. -c  断点续传 -p 下载页面内所有资源,包括图片.视频等. -r 递归下载 实例1,下载本站的所有文章 ...

  6. N76E003之IO控制

    N76E003最多支持26个可位寻址的通用I/O引脚,分成4组 P0 到 P3 .每一个端口有它的端口控制寄存器(Px).端口控制寄存器的写和读有不同的意思.写端口控制寄存器设置输出锁存逻辑值,读端口 ...

  7. STL——仿函数(函数对象)

    一.仿函数(也叫函数对象)概观 仿函数的作用主要在哪里?从第6章可以看出,STL所提供的各种算法,往往有两个版本,其中一个版本表现出最常用(或最直观)的某种运算,第二个版本则表现出最泛化的演算流程,允 ...

  8. STL——heap结构及算法

    heap(隐式表述,implicit representation) 1. heap概述 : vector + heap算法 heap并不归属于STL容器组件,它是个幕后英雄,扮演priority q ...

  9. Servlet基本用法(一)基本配置

    一.前言 Java Servlet是一个基于Java技术的Web组件,运行在服务器端,由Servlet容器所管理,用于生成动态的内容.Servlet是平台独立的Java类,编写一个Servlet实际上 ...

  10. 如何安装win10和linux [ubuntu14]双系统

    https://jingyan.baidu.com/article/4d58d5411380dd9dd5e9c07e.html jpg 改 rar