CENTOS 7基于ISO文件进行安装新软件

众所周知,YUM是CENTOS7的安装程序。

普通情况下,连网之后 ,用yum install 就可以安装。

但当网络环境经常出现连接失败的情况,默认情况下的行为就走不通了。

为解决这个问题,可以考虑如下三个方案

方案一:YUM从其他镜像网络安装

这个方案需要修改安装源为其他镜像源,例如淘宝阿里云或163.

方案二:YUM从本地U盘安装

这个方案要求把安装盘插到CENTOS上。

方案三:YUM从ISO上直接安装

这个方案只需要把ISO下载,然后上传CENTOS服务器,再MOUNT到系统,修改安装源指向本地路径

步骤1:MOUNT ISO到本地目录

[root@localhost ~]# cd /mnt

[root@localhost mnt]# ls

[root@localhost mnt]# cd /

[root@localhost /]# mount -o loop /home/XXXX/CentOS-7-x86_64-DVD-2207-02.iso /mnt

mount: /dev/loop0 写保护,将以只读方式挂载

[root@localhost /]# ls /mnt

CentOS_BuildTag EFI EULA GPL images isolinux LiveOS Packages repodata RPM-GPG-KEY-CentOS-7 RPM-GPG-KEY-CentOS-Testing-7 TRANS.TBL

[root@localhost /]#

步骤2:修改安装源指向本地路径/mnt

1). 备份原文件

为避免原来的源选择过程中影响速度,把原文件备份后删除

cp /etc/yum.repos.d/* ~/backup

rm /etc/yum.repos.d/*

2). 添加路径

[root@localhost ~]# yum-config-manager --add-repo="file:///mnt"

将会生成一个mnt.repo文件

[root@localhost yum.repos.d]# cat mnt.repo

[mnt]

name=added from: file:///mnt

baseurl=file:///mnt

enabled=1

3、makecache

yum makecache

已加载插件:fastestmirror, langpacks

Loading mirror speeds from cached hostfile

mnt | 3.6 kB 00:00:00

(1/4): mnt/group_gz | 153 kB 00:00:00

(2/4): mnt/primary_db | 3.3 MB 00:00:00

(3/4): mnt/filelists_db | 3.3 MB 00:00:00

(4/4): mnt/other_db | 1.3 MB 00:00:00

元数据缓存已建立

4、尝试安装

yum install gcc

已加载插件:fastestmirror, langpacks

您已启用软件包 GPG 签名检查,这样很好。不过您尚未安装任何 GPG 公钥。请下载您希望安装的软件签名公钥并安装。假设公钥已下载,安装命令是:

rpm --import public.gpg.key

或者,在软件源配置中,使用 'gpgkey' 选项指定软件源使用的公钥 URL,这样 yum 会自动安装它。

详情请联系发行版或软件包制作人。

问题源:mnt

原因是gpgcheck=1,选项没有修改.

5、修改选项

[root@localhost yum.repos.d]# vi mnt.repo

[mnt]

name=added from: file:///mnt

baseurl=file:///mnt

enabled=1

gpgcheck=0

6、再尝试安装gcc

[root@localhost yum.repos.d]# yum install gcc

已加载插件:fastestmirror, langpacks

Loading mirror speeds from cached hostfile

mnt | 3.6 kB 00:00:00

正在解决依赖关系

--> 正在检查事务

---> 软件包 gcc.x86_64.0.4.8.5-44.el7 将被 安装

--> 正在处理依赖关系 cpp = 4.8.5-44.el7,它被软件包 gcc-4.8.5-44.el7.x86_64 需要

--> 正在处理依赖关系 glibc-devel >= 2.2.90-12,它被软件包 gcc-4.8.5-44.el7.x86_64 需要

--> 正在检查事务

---> 软件包 cpp.x86_64.0.4.8.5-44.el7 将被 安装

---> 软件包 glibc-devel.x86_64.0.2.17-326.el7_9 将被 安装

--> 正在处理依赖关系 glibc-headers = 2.17-326.el7_9,它被软件包 glibc-devel-2.17-326.el7_9.x86_64 需要

--> 正在处理依赖关系 glibc-headers,它被软件包 glibc-devel-2.17-326.el7_9.x86_64 需要

--> 正在检查事务

---> 软件包 glibc-headers.x86_64.0.2.17-326.el7_9 将被 安装

--> 正在处理依赖关系 kernel-headers >= 2.2.1,它被软件包 glibc-headers-2.17-326.el7_9.x86_64 需要

--> 正在处理依赖关系 kernel-headers,它被软件包 glibc-headers-2.17-326.el7_9.x86_64 需要

--> 正在检查事务

---> 软件包 kernel-headers.x86_64.0.3.10.0-1160.71.1.el7 将被 安装

--> 解决依赖关系完成

依赖关系解决

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

Package 架构 版本 源 大小

正在安装:

gcc x86_64 4.8.5-44.el7 mnt 16 M

为依赖而安装:

cpp x86_64 4.8.5-44.el7 mnt 5.9 M

glibc-devel x86_64 2.17-326.el7_9 mnt 1.1 M

glibc-headers x86_64 2.17-326.el7_9 mnt 691 k

kernel-headers x86_64 3.10.0-1160.71.1.el7 mnt 9.1 M

事务概要

安装 1 软件包 (+4 依赖软件包)

总下载量:33 M

安装大小:59 M
Is this ok [y/d/N]: y
Downloading packages:

总计 269 MB/s | 33 MB 00:00:00

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

正在安装 : cpp-4.8.5-44.el7.x86_64 1/5

正在安装 : kernel-headers-3.10.0-1160.71.1.el7.x86_64 2/5

正在安装 : glibc-headers-2.17-326.el7_9.x86_64 3/5

正在安装 : glibc-devel-2.17-326.el7_9.x86_64 4/5

正在安装 : gcc-4.8.5-44.el7.x86_64 5/5

验证中 : glibc-headers-2.17-326.el7_9.x86_64 1/5

验证中 : gcc-4.8.5-44.el7.x86_64 2/5

验证中 : kernel-headers-3.10.0-1160.71.1.el7.x86_64 3/5

验证中 : glibc-devel-2.17-326.el7_9.x86_64 4/5

验证中 : cpp-4.8.5-44.el7.x86_64 5/5

已安装:

gcc.x86_64 0:4.8.5-44.el7

作为依赖被安装:

cpp.x86_64 0:4.8.5-44.el7 glibc-devel.x86_64 0:2.17-326.el7_9 glibc-headers.x86_64 0:2.17-326.el7_9 kernel-headers.x86_64 0:3.10.0-1160.71.1.el7

完毕!

[root@localhost yum.repos.d]# gcc

gcc: 致命错误:没有输入文件

编译中断。

[root@localhost yum.repos.d]# gcc --version

gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)

Copyright © 2015 Free Software Foundation, Inc.

本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;

包括没有适销性和某一专用目的下的适用性担保。

成功。

相关推荐
好记忆不如烂笔头abc11 天前
Cannot find a valid baseurl for repo: base/7/x86_64
yum
石輔寸20 天前
yum本地源配置
linux·yum
I'mAlex1 个月前
已解决centos7 yum报错:cannot find a valid baseurl for repo:base/7/x86_64的解决方案
linux·运维·服务器·centos·yum
shenghuiping20012 个月前
如何将CentOS的yum源更换为阿里云源
linux·阿里云·centos·yum
runing_an_min2 个月前
Centos 7 升级GCC时遇到 mirrorlist.centos.org; Unknown error“
linux·运维·centos·gcc·yum
sysin.org2 个月前
macOS Sonoma 14.6.1 (23G93) Boot ISO 原版可引导镜像下载
macos·iso·sonoma
ZZDICT2 个月前
Yum缓存包
缓存·yum·dnf
Mr.caesar3 个月前
CentOS7使用yum命令报错
yum·centos 7·yum命令报错
你疯了抱抱我3 个月前
【CentOS7.6】yum 报错:Could not retrieve mirrorlist http://mirrorlist.centos.org
linux·centos·yum
dibowei20694 个月前
ISO 19115-2:2019 附录C XML 模式实现
iso