搭建本地yum服务器

简介:

在内网环境下,服务器通常不联网,这时候如果要下载什么软件,搭建本地yum服务器的话就很方便了。

  1. 创建挂载目录:

[root@Herry ~]# mkdir -p /local/yum         

2.挂载你的光盘或者U盘到指定目录下,这里的/dev/cdrom可以是你的U盘,具体看你用什么了[root@Herry ~]# mount /dev/cdrom /local/yum

3.copy源yum的目录文件,我做实验需要还原的,这个不是必须

[root@Herry ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d.aak

4.删除源Yum目录下的所有文件,这个不是必须

[root@Herry ~]# rm -f /etc/yum.repos.d/*

5.修改配置文件,你也可以直接在/etc/yum.repos.d/CentOS-Base.repo下增加以下配置,不过在使用yum的时候,它会从上往下匹配,比较耗时,所以这里我就直接删除源yum文件了,新增了以下local_yum.repo:

[root@Herry ~]# vim /etc/yum.repos.d/local_yum.repo

[local_yum]

name=this is local yum

baseurl=file:///local/yum

enabled=1 (是否启用该yum源,0为禁用)

gpgcheck=0 (是否检查gpgkey,0为不检查)

#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6(gpgcheck=0时无需配置)

6.测试:卸载vim

[root@Herry ~]# yum remove -y vim

Loaded plugins: fastestmirror

Setting up Remove Process

Resolving Dependencies

There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.

The program yum-complete-transaction is found in the yum-utils package.

--> Running transaction check

---> Package vim-enhanced.x86_64 2:7.2.411-1.8.el6 will be erased

--> Finished Dependency Resolution

local_yum                                                                                          | 4.0 kB     00:00 ...

local_yum/primary_db                                                                               | 4.4 MB     00:00 ...


Dependencies Resolved


==========================================================================================================================

 Package               Arch            Version                    Repository                                         Size

==========================================================================================================================

Removing:

 vim-enhanced          x86_64          2:7.2.411-1.8.el6          @anaconda-CentOS-201311272149.x86_64/6.5          1.8 M


Transaction Summary

==========================================================================================================================

Remove        1 Package(s)


Installed size: 1.8 M

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Erasing    : 2:vim-enhanced-7.2.411-1.8.el6.x86_64                                                                  1/1

  Verifying  : 2:vim-enhanced-7.2.411-1.8.el6.x86_64                                                                  1/1


Removed:

  vim-enhanced.x86_64 2:7.2.411-1.8.el6


7.命令vim无法使用了:

[root@Herry ~]# !v

vim /etc/yum.repos.d/local_yum.repo

-bash: /usr/bin/vim: 没有那个文件或目录

8.安装回来vim:

[root@Herry ~]# yum install -y vim                 

Loaded plugins: fastestmirror

Determining fastest mirrors

Setting up Install Process

Resolving Dependencies

There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.

The program yum-complete-transaction is found in the yum-utils package.

--> Running transaction check

---> Package vim-enhanced.x86_64 2:7.2.411-1.8.el6 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


==========================================================================================================================

 Package                      Arch                   Version                              Repository                 Size

==========================================================================================================================

Installing:

 vim-enhanced                 x86_64                 2:7.2.411-1.8.el6                    local_yum                 892 k


Transaction Summary

==========================================================================================================================

Install       1 Package(s)


Total download size: 892 k

Installed size: 1.8 M

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : 2:vim-enhanced-7.2.411-1.8.el6.x86_64                                                                  1/1

  Verifying  : 2:vim-enhanced-7.2.411-1.8.el6.x86_64                                                                  1/1


Installed:

  vim-enhanced.x86_64 2:7.2.411-1.8.el6


9.可以使用vim了 :

[root@Herry ~]# !v

vim /etc/yum.repos.d/local_yum.repo


[local_yum]

name=this is local yum

baseurl=file:///local/yum

enabled=1

gpgcheck=0



至此本地yum搭建完成。

本文转自飞奔的小GUI博客51CTO博客,原文链接http://blog.51cto.com/9237101/1913071如需转载请自行联系原作者

ziwenzhou
相关文章
|
6月前
|
Linux 应用服务中间件 开发工具
Linux服务器搭建本地YUM源
对于一些单位通常都会对网络进行分区,处于内网区域的服务器是无法直接访问到互联网的,这时,如果部署一些需要在线下载服务的环境就显得异常麻烦,离线依赖包装的真的折磨人,那这时我们该怎么办呢?前半部分摘自CSDN博客:https://blog.csdn.net/qq_44895681/article/details/127617155,侵删,后半部分结合本人工作经验和实践完成。
Linux服务器搭建本地YUM源
|
11月前
|
缓存 Linux
【Linux网络服务】Centos7搭建yum服务器
【Linux网络服务】Centos7搭建yum服务器
|
缓存 弹性计算 Linux
ECS服务器修改yum源
由于Cent OS 所自带的yum源,速度不是很快,之前在玩树莓派的时候见识过阿里源的强大,所以决定将其更换为阿里源。
343 0
|
缓存 Linux 数据库
在linux云服务器下,使用yum工具出错提示Error: rpmdb open failed
yum工具在linux环境下都是事先预装好的,当我们使用时,会出现Error: rpmdb open failed。 那么,我们怎么解决呢?
三丰云”免费虚拟主机免费云服务器yum出错
三丰云”免费虚拟主机免费云服务器yum出错,怎么回事?
|
关系型数据库 MySQL Linux
CentOS环境 云服务器通过 YUM 安装软件
为提升我们在云服务器上的软件安装效率,减少下载和安装软件的成本,在 CentOS 环境下,我们可以通过 yum 命令快速安装软件。对于 YUM 下载源,我们不需要添加软件源,可以直接安装软件包。 从 CentOS 7 系统开始,MariaDB 成为 YUM 源中默认的数据库安装包。