yum不安装只下载rpm包(含centos6,centos7)

这个个人感觉还是有必要进行记录一下的,为什么呢,主要吧是,小编发现这个还是经常要用的,比如说今天为了部署一个服务,大家也是懂的了,一般来说,生产系统都是内网环境,Yum源的配置那是一个字,真糟糕呀,而且还是机房独享的,这就出现了一个问题,那就是,咱们运维人员来进行部署的服务的时候,yum是基本上不能用的,今天就是这样的一个情况,但是不要着急,咱们运维有的是办法,接下来我就分享下如何使用Yum来将这些包给下载下来,然后上传到服务器进行安装部署

这个不是yum偷包哈,Yum偷包和这个目的是不一样的,yum偷包是为了部署搭建yum源,咱们现在要做的通过yum来下载下来咱们需要的rpm包,如果有需要可以看下小编的另一篇文章:运维利器之yum及yum偷包的实战

那么咱们开始哈

思路

yum不安装只下载rpm包(含centos6,centos7)_yum

开搞

安装插件

# yum install yum-plugin-downloadonly

下载rpm包到指定目录

例:下载 ntp 的软件包到 /opt/ntp 目录下

# yum install --downloadonly --downloaddir=/ntp ntp -y   其中/ntp是自己创建的哈,如果没有可以创建一个,那么我们所有的包就会下载到这个路径下面,包括所需要的依赖包

这里需要大家按照自己需要安装部署的服务来,我这边只是用了ntp来做个列子

这样的话在/opt/net下面就有了我们安装的所有的包了,然后再传到内网服务器上面,进行安装就可以了

内网环境的安装

方法(1)yum 本地安装

yum -y localinstall 源码.rpm,就可以安装了,如果提示有什么依赖,就在咱们的rpm包里面找下,安装就行了

方法(2)rpm来进行安装

rpm -ivh *.rpm --nodeps --force ,一定要在我们下载好的包路径里面哈,*就代表着所有的rpm包

其他问题

centos6的yum文件配置

如果遇见centos无法安装yum-plugin-downloadonly,可以用以下centos6的epel源配置

直接替换repo文件,yum就可以用了,这里也跟着记录一下

[root@localhost yum.repos.d]# cat CentOS-Base.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-vault-6.10 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
        http://mirrors.aliyuncs.com/centos-vault/6.10/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-vault-6.10 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
        http://mirrors.aliyuncs.com/centos-vault/6.10/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-vault-6.10 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
        http://mirrors.aliyuncs.com/centos-vault/6.10/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-vault-6.10 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos-vault/6.10/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-vault-6.10 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos-vault/6.10/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6