自行制作yum源仓库

背景

客户服务器为内网机器,centos7系统,且无法与外网连接。需要部署对应的LANMP环境及其它软件

解决思路

1.在阿里云服务器,利用阿里云的yum源仓库,下载对应软件及关联软件。

2.在客户机上面自建yum仓库,然后通过yum安装,解决依赖问题

下载软件

[root@compute1 tmp]# mkdir -pv /tmp/soft
cd /tmp/soft
[root@compute1 soft]# ll /tmp/soft
total 0
[root@compute1 soft]# yum install nginx --downloadonly --downloaddir=/tmp/soft
[root@compute1 soft]# ll /tmp/soft
total 0
-rw-r--r-- 1 root root 0 Jul 13 14:13 fontconfig-2.10.95-10.el7.x86_64.rpm
-rw-r--r-- 1 root root 0 Jul 13 14:13 fontpackages-filesystem-1.44-8.el7.noarch.rpm
-rw-r--r-- 1 root root 0 Jul 13 14:13 gd-2.0.35-26.el7.x86_64.rpm
-rw-r--r-- 1 root root 0 Jul 13 14:13 GeoIP-1.5.0-11.el7.x86_64.rpm
-rw-r--r-- 1 root root 0 Jul 13 14:13 libXpm-3.5.11-3.el7.x86_64.rpm
-rw-r--r-- 1 root root 0 Jul 13 14:13 nginx-1.10.2-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 0 Jul 13 14:13 nginx-all-modules-1.10.2-1.el7.noarch.rpm
-rw-r--r-- 1 root root 0 Jul 13 14:13 nginx-filesystem-1.10.2-1.el7.noarch.rpm
-rw-r--r-- 1 root root 0 Jul 13 14:13 nginx-mod-http-geoip-1.10.2-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 0 Jul 13 14:13 nginx-mod-http-image-filter-1.10.2-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 0 Jul 13 14:13 nginx-mod-http-perl-1.10.2-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 0 Jul 13 14:13 nginx-mod-http-xslt-filter-1.10.2-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 0 Jul 13 14:13 nginx-mod-mail-1.10.2-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 0 Jul 13 14:13 nginx-mod-stream-1.10.2-1.el7.x86_64.rpm

提示不能使用--downloadonly的请先安装yum-utils软件

[root@compute1 soft]# yum -y install yum-utils

利用yum的参数,进行只下载,不安装,同时会下载对应依赖的软件

自建仓库

将上述app复制到客户内网机器,假设目录为/usr/app

[root@iZ25vh2zuf2Z ~]# cd /usr/app
[root@iZ25vh2zuf2Z app]# createrepo .

createrepo命令不存在的,可以yum install createrepo进行安装

这样自行仓库就建立完成,然后/etc/yum.repos.d/添加对应的配置文件

[root@iZ25vh2zuf2Z yum.repos.d]# cat localself.repo
[self]
name=local
baseurl=file:///usr/app
gpgcheck=0

[root@iZ25vh2zuf2Z yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: self
Cleaning up everything
[root@iZ25vh2zuf2Z yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id                          repo name                 status
self                             local                     245
repolist: 245


可以看到自行存放的245个app已经出现在仓库列表中

然后可以通过yum安装自行解决对应的依赖关系,而不是手动安装

posted @ 2017-08-03 10:31  marility  阅读(4634)  评论(0编辑  收藏  举报