linux部署YUM仓库服务
Posted 还行少年
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux部署YUM仓库服务相关的知识,希望对你有一定的参考价值。
1.更换YUM源为aliyun的源
可以直接复制执行
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all //清理缓存数据
yum makecache //重建元数据缓存
2.更换YUM源为本地源
2.1 准备软件仓库
[root@localhost ~]# mount /dev/sr0 /mnt //挂载光盘充当yum仓库
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# ls /mnt //查看挂载后的目录有哪些内容(Packages内为rpm软件包)
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
[root@localhost ~]#
2.2 配置软件仓库位置
[root@localhost ~]# vim /etc/yum.repos.d/local.repo //yum软件仓库载此目录下,在创建一个
[local] //表示仓库类别
name=local //仓库名称(说明)
baseurl=file:///mnt //访问路径
enable=1 //启用此仓库
gpgcheck=0 //不验证软件包的签名
2.3 清缓存,建立元数据缓存
[root@localhost ~]# yum clean all //清除缓存
已加载插件:fastestmirror, langpacks
正在清理软件源: FTP local
Cleaning up list of fastest mirrors
Other repos take up 401 M of disk space (use --verbose for details)
[root@localhost ~]# yum makecache //建立元数据缓存
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
FTP | 2.9 kB 00:00:00
local | 3.6 kB 00:00:00
(1/7): FTP/filelists_db | 3.2 MB 00:00:00
(2/7): FTP/primary_db | 3.2 MB 00:00:00
(3/7): local/group_gz | 166 kB 00:00:00
(4/7): FTP/other_db | 1.3 MB 00:00:00
(5/7): local/filelists_db | 3.2 MB 00:00:00
(6/7): local/primary_db | 3.1 MB 00:00:00
(7/7): local/other_db | 1.3 MB 00:00:00
元数据缓存已建立
[root@localhost ~]#
2.4 查看软件源
[root@localhost ~]# yum repolist
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
源标识 源名称 状态
local local 4,021
repolist: 4,021
[root@localhost ~]#
2.5 测试安装httpd
[root@localhost ~]# yum -y install httpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-88.el7.centos 将被 安装
--> 解决依赖关系完成
依赖关系解决
====================================================================================================================
Package 架构 版本 源 大小
====================================================================================================================
正在安装:
httpd x86_64 2.4.6-88.el7.centos local 2.7 M
事务概要
====================================================================================================================
安装 1 软件包
总下载量:2.7 M
安装大小:9.4 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : httpd-2.4.6-88.el7.centos.x86_64 1/1
验证中 : httpd-2.4.6-88.el7.centos.x86_64 1/1
已安装:
httpd.x86_64 0:2.4.6-88.el7.centos
完毕!
[root@localhost ~]#
3.更换源为内网FTP发布的YUM源
3.1 安装启用vsftpd服务
[root@localhost ~]# yum -y install vsftpd //下载安装
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
。。。
已安装:
vsftpd.x86_64 0:3.0.2-28.el7
完毕!
[root@localhost ~]# systemctl start vsftpd //启用vsftpd服务
3.2 配置软件仓库
[root@localhost ~]# mount /dev/sr0 /mnt //挂载光盘
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# mkdir /var/ftp/ftp //创建挂载目录
[root@localhost ~]# cp -a /mnt/* /var/ftp/ftp/ //将光盘内容复制到该文件夹,充当软件仓库
3.3 配置软件仓库位置(客户机)
[root@localhost ~]# vim /etc/yum.repos.d/ftp.repo
[root@localhost ~]# cat /etc/yum.repos.d/ftp.repo
[FTP] //标识仓库类别
name=FTP //仓库名称
baseurl=ftp://192.168.30.4/ftp //访问路径
enable=1 //启用此仓库
gpgcheck=0 //不验证软件包的签名
[root@localhost ~]#
3.4 清缓存,建立元数据缓存(客户机)
[root@localhost ~]# yum clean all //清除缓存
已加载插件:fastestmirror, langpacks
正在清理软件源: FTP
Cleaning up list of fastest mirrors
Other repos take up 401 M of disk space (use --verbose for details)
[root@localhost ~]# yum makecache //建立元数据缓存
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
FTP | 3.6 kB 00:00:00
(1/4): FTP/group_gz | 166 kB 00:00:00
(2/4): FTP/primary_db | 3.1 MB 00:00:00
(3/4): FTP/filelists_db | 3.2 MB 00:00:00
(4/4): FTP/other_db | 1.3 MB 00:00:00
元数据缓存已建立
[root@localhost ~]# yum repolist //显示软件源
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
源标识 源名称 状态
FTP FTP 4,021
repolist: 4,021
[root@localhost ~]#
3.5 测试安装httpd(客户机)
[root@localhost ~]# yum -y install httpd //安装httpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-88.el7.centos 将被 安装
--> 正在处理依赖关系 httpd-tools = 2.4.6-88.el7.centos,它被软件包 httpd-2.4.6-88.el7.centos.x86_64 需要
====================================================================================================================
Package 架构 版本 源 大小
====================================================================================================================
正在安装:
httpd x86_64 2.4.6-88.el7.centos FTP 2.7 M
为依赖而安装:
httpd-tools x86_64 2.4.6-88.el7.centos FTP 90 k
mailcap noarch 2.1.41-2.el7 FTP 31 k
。。。
已安装:
httpd.x86_64 0:2.4.6-88.el7.centos
作为依赖被安装:
httpd-tools.x86_64 0:2.4.6-88.el7.centos mailcap.noarch 0:2.1.41-2.el7
完毕!
[root@localhost ~]#
3.6 FTP软件仓库增加软件时,需更新yum源的元数据信息
[root@localhost data]# ls
nginx-1.16.1-3.el7.x86_64.rpm nginx-mod-http-xslt-filter-1.16.1-3.el7.x86_64.rpm
nginx-all-modules-1.16.1-3.el7.noarch.rpm nginx-mod-mail-1.16.1-3.el7.x86_64.rpm
nginx-filesystem-1.16.1-3.el7.noarch.rpm nginx-mod-stream-1.16.1-3.el7.x86_64.rpm
nginx-mod-http-image-filter-1.16.1-3.el7.x86_64.rpm openssl11-libs-1.1.1g-3.el7.x86_64.rpm
nginx-mod-http-perl-1.16.1-3.el7.x86_64.rpm
[root@localhost data]# cp * /var/ftp/ftp/Packages/ //将rpm包放到软件仓库中
[root@localhost data]# createrepo --update /var/ftp/ftp/Packages/ //手动更新依赖关系
Could not find valid repo at: /var/ftp/ftp/Packages/
Spawning worker 0 with 2015 pkgs
Spawning worker 1 with 2015 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost data]#
3.7 更新客户机软件仓库位置
[root@localhost ~]# vim /etc/yum.repos.d/ftp.repo
[FTP]
name=FTP
baseurl=ftp://192.168.30.4/ftp/Packages //手动更新Packages目录
enable=1
gpgcheck=0
3.8 查看可安装软件数量
[root@localhost ~]# yum repolist //4021没变化
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
源标识 源名称 状态
FTP FTP 4,021
repolist: 4,021
[root@localhost ~]#
3.9 清除缓存,重建元数据信息
[root@localhost ~]# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: FTP
Cleaning up list of fastest mirrors
Other repos take up 401 M of disk space (use --verbose for details)
[root@localhost ~]# yum makecache
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
FTP | 2.9 kB 00:00:00
(1/3): FTP/filelists_db | 3.2 MB 00:00:00
(2/3): FTP/other_db | 1.3 MB 00:00:00
(3/3): FTP/primary_db | 3.2 MB 00:00:00
元数据缓存已建立
[root@localhost ~]# yum repolist //变为4030
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
源标识 源名称 状态
FTP FTP 4,030
repolist: 4,030
[root@localhost ~]#
测试安装nginx(此前无此rpm包)
[root@localhost ~]# yum -y install nginx
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
。。。
====================================================================================================================
Package 架构 版本 源 大小
====================================================================================================================
正在安装:
nginx x86_64 1:1.16.1-3.el7 FTP 563 k
为依赖而安装:
nginx-all-modules noarch 1:1.16.1-3.el7 FTP 20 k
nginx-filesystem noarch 1:1.16.1-3.el7 FTP 21 k
nginx-mod-http-image-filter x86_64 1:1.16.1-3.el7 FTP 30 k
nginx-mod-http-perl x86_64 1:1.16.1-3.el7 FTP 39 k
nginx-mod-http-xslt-filter x86_64 1:1.16.1-3.el7 FTP 29 k
nginx-mod-mail x86_64 1:1.16.1-3.el7 FTP 57 k
nginx-mod-stream x86_64 1:1.16.1-3.el7 FTP 85 k
openssl11-libs x86_64 1:1.1.1g-3.el7 FTP 1.5 M
。。。。
已安装:
nginx.x86_64 1:1.16.1-3.el7
作为依赖被安装:
nginx-all-modules.noarch 1:1.16.1-3.el7 nginx-filesystem.noarch 1:1.16.1-3.el7
nginx-mod-http-image-filter.x86_64 1:1.16.1-3.el7 nginx-mod-http-perl.x86_64 1:1.16.1-3.el7
nginx-mod-http-xslt-filter.x86_64 1:1.16.1-3.el7 nginx-mod-mail.x86_64 1:1.16.1-3.el7
nginx-mod-stream.x86_64 1:1.16.1-3.el7 openssl11-libs.x86_64 1:1.1.1g-3.el7
完毕!
[root@localhost ~]#
以上是关于linux部署YUM仓库服务的主要内容,如果未能解决你的问题,请参考以下文章