本地yum源光盘配置
1.
查看本地源
1.
使⽤光盘作为
yum
源仓库
1.
在
vmware
中装载
centos7.6
光盘镜像
Loading mirror speeds from cached hostfile
repolist:
0
#
所有的
yum
都已经被删除了
2.
把光盘挂载到指定⽬录下
1.
删除
/mnt
⽬录下所有的⽂件
2.lsblk
3.mount -o ro /dev/sr0 /mnt
选项
-o
表示挂载⽅式
ro=readonly
rw=read and write
[root@localhost ~]
# mount /dev/sr0 /mnt/ -o ro
您在
/var/spool/mail/root
中有新邮件
[root@localhost ~]
# ls /mnt/
CentOS_BuildTag EULA images LiveOS repodata RPM
GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7
TRANS.TBL
4.
解除挂载
4.
将挂载添加到开机启动⽂件中
chmod +x /etc/rc.local
添加权限
echo 'mount -o ro /dev/sr0 /mnt' >> /etc/rc.local
向⽂件中添加⼀⾏
#
查看磁盘挂载情况
[root@localhost ~]
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda
8
:0
0
20G
0
disk
"#sda1
8
:1
0
1G
0
part /boot
$#sda2
8
:2
0
19G
0
part
"#centos-root
253
:0
0
17G
0
lvm /
$#centos-swap
253
:1
0
2G
0
lvm [SWAP]
sr0
11
:0
1 8
.8G
0
rom /mnt
您在
/var/spool/mail/root
中有新邮件
[root@localhost ~]
# umount /mnt
您在
/var/spool/mail/root
中有新邮件
[root@localhost ~]
# ls /mnt/
[root@localhost ~]
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda
8
:0
0
20G
0
disk
"#sda1
8
:1
0
1G
0
part /boot
$#sda2
8
:2
0
19G
0
part
"#centos-root
253
:0
0
17G
0
lvm /
$#centos-swap
253
:1
0
2G
0
lvm [SWAP]
sr0
11
:0
1 8
.8G
0
rom
5.
编写本地
repo
⽂件
1.
创建⼀个
repo
⽂件
2.
编辑内容
yum
仓库的格式
[root@localhost ~]# vim /etc/rc.local
[root@localhost ~]# echo 'mount -o or /dev/sr0 /mnt' >> /etc/rc.local
[root@localhost ~]# vim /etc/rc.local
[root@localhost ~]# vim /etc/rc.local
[root@localhost ~]# ls -l /etc/rc.local
lrwxrwxrwx. 1 root root 13 6
⽉
16 20:18 /etc/rc.local -> rc.d/rc.local
编号
属性
1
[
仓库名称
]
可以有多个仓库
2
name=
仓库名称
3
baseurl=
仓库的路径,⽀持多种格式
file:// ftp:// http/s://
4
gpgcheck= gpg
秘钥检测
0
不检测,
1
检测,如果需要配置秘钥链接
5
enable= 0|1
是否启⽤当前仓库
6,
清理缓存,查看源列表
[root@localhost ~]
# ls /etc/yum.repos.d/
repo.tar.gz
[root@localhost ~]
# vim /etc/yum.repos.d/20240714001.repo
[local]
[local]
name
=
local0
baseurl
=
file
:
///mnt
gpgcheck
=
0
enable
=
1
#
清理缓存
[root@localhost ~]
# yum clear all
已加载插件:
fastestmirror
没有该命令:
clear
。请使⽤
/usr/bin/yum
--help
#
创建缓存
[root@localhost ~]
# yum makecache
已加载插件:
fastestmirror
Loading mirror speeds from cached hostfile
local
|
3
.6 kB
00
:00:00
(1/2): local/other_db
|
2
.5 MB
00
:00:00
7.
测试
yum
(2/2): local/filelists_db
|
6
.9 MB
00
:00:00
元数据缓存已建⽴
您在
/var/spool/mail/root
中有新邮件
#
查看源仓库列表
[root@localhost ~]
# yum repolist
已加载插件:
fastestmirror
Loading mirror speeds from cached hostfile
源标识 源名称
状态
local local0
9
,911
repolist:
9
,911
[root@localhost ~]
# yum repolist all
已加载插件:
fastestmirror
Loading mirror speeds from cached hostfile
源标识
源名称
状态
local local0
启⽤
:
9
,911
#
软件数量
repolist:
9
,911
#
查看是否安装
httpd
[root@localhost ~]
# rpm -q httpd
httpd-2.4.6-99.el7.centos.1.x86_64
#
卸载
httpd
[root@localhost ~]
# yum remove httpd
已加载插件:
fastestmirror
正在解决依赖关系
--
>
正在检查事务
---
>
软件包
httpd.x86_64.0.2.4.6-99.el7.centos.1
将被 删除
--
>
解决依赖关系完成
依赖关系解决
=======================================================================
=========================================
Package
架构
版本
源 ⼤⼩
=======================================================================
=========================================
正在删除
:
httpd x86_64
2
.4.6-99.el7.centos.1
@updates
9
.4 M
事务概要
=======================================================================
=========================================
移除
1
软件包
安装⼤⼩:
9.4 M
是否继续?
[y/N]
:
y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在删除
: httpd-2.4.6-99.el7.centos.1.x86_64
1
/1
验证中
: httpd-2.4.6-99.el7.centos.1.x86_64
1
/1
删除
:
httpd.x86_64
0
:2.4.6-99.el7.centos.1
完毕!
#
再次查看是否安装
httpd
[root@localhost ~]
# rpm -q httpd
未安装软件包
httpd
[root@localhost ~]
# yum -y install httpd
已加载插件:
fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--
>
正在检查事务
---
>
软件包
httpd.x86_64.0.2.4.6-80.el7.centos
将被 安装
--
>
正在处理依赖关系
httpd-tools =
2
.4.6-80.el7.centos
,它被软件包
httpd-
2.4.6-80.el7.centos.x86_64
需要
--
>
解决依赖关系完成
错误:软件包:
httpd-2.4.6-80.el7.centos.x86_64 (local)
需要:
httpd-tools =
2
.4.6-80.el7.centos
已安装
: httpd-tools-2.4.6-99.el7.centos.1.x86_64 (@updates)
httpd-tools =
2
.4.6-99.el7.centos.1
可⽤
: httpd-tools-2.4.6-80.el7.centos.x86_64 (local)
httpd-tools =
2
.4.6-80.el7.centos
您可以尝试添加
--skip-broken
选项来解决该问题
您可以尝试执⾏:
rpm
-Va --nofiles --nodigest
您在
/var/spool/mail/root
中有新邮件
[root@localhost ~]
# rpm -q httpd
未安装软件包
httpd
#
缺少依赖,安装失败
2.
下载软件,使⽤软件包,作为
yum
源仓库
⽹络yum源的分离
1.
知名站点
1.
搜索阿⾥镜像源
2.
根据官⽅提示配置
yum
源
https://developer.aliyun.com/mirror/centos
#
复制阿⾥云提供的
url
,下载⽂件
[root@localhost yum.repos.d]
# wget -O /etc/yum.repos.d/CentOS-Base.repo
https://mirrors.aliyun.com/repo/Centos-7.repo
--2024-07-14
20
:00:04-- https://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机
mirrors.aliyun.com (mirrors.aliyun.com)...
117
.23.49.221,
117
.23.49.224,
58
.222.47.210, ...
正在连接
mirrors.aliyun.com (mirrors.aliyun.com)|117.23.49.221|:443...
已
连接。
已发出
HTTP
请求,正在等待回应
...
200
OK
⻓度:
2523 (2.5K) [application/octet-stream]
正在保存⾄
: “/etc/yum.repos.d/CentOS-Base.repo”
100
%
[======================================================================
>]
2
,523
--
.-K/s
⽤时
0s
2024
-07-14
20
:00:04 (469 MB/s)
-
已保存
“/etc/yum.repos.d/CentOS
Base.repo” [2523/2523])
#
查看下载的⽂件
[root@localhost yum.repos.d]
# ls
20240714001
.repo CentOS-Base.repo repo.tar.gz
[root@localhost yum.repos.d]
#
3.
运⾏
yum makecache
⽣成缓存
yum clear
4.
查看源
[root@localhost yum.repos.d]
# yum repolist all
已加载插件:
fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
源标识
源名称
状态
base/7/x86_64 CentOS-7
-
Base
-
mirrors.aliyun.com
启⽤
:
10
,072
centosplus/7/x86_64 CentOS-7
-
Plus
-
mirrors.aliyun.com
禁⽤
contrib/7/x86_64 CentOS-7
-
Contrib
-
mirrors.aliyun.com
禁⽤
extras/7/x86_64 CentOS-7
-
Extras
-
mirrors.aliyun.com
启⽤
:
526
local local0
启⽤
:
9
,911
updates/7/x86_64 CentOS-7
-
Updates
-
mirrors.aliyun.com
启⽤
:
6
,173
repolist:
26
,682
5.
再次安装
httpd
[root@localhost yum.repos.d]# yum -y install httpd
已加载插件:
fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
-->
正在检查事务
--->
软件包
httpd.x86_64.0.2.4.6-99.el7.centos.1
将被 安装
-->
解决依赖关系完成
依赖关系解决
=======================================================================
=========================================
Package
架构
版本
源
⼤⼩
=======================================================================
=========================================
正在安装
:
httpd x86_64 2.4.6-99.el7.centos.1
updates 2.7 M
事务概要
=======================================================================
=========================================
安装
1
软件包
总下载量:
2.7 M
安装⼤⼩:
9.4 M
Downloading packages:
httpd-2.4.6-99.el7.centos.1.x86_64.rpm
| 2.7 MB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装
: httpd-2.4.6-99.el7.centos.1.x86_64
1/1
验证中
: httpd-2.4.6-99.el7.centos.1.x86_64
1/1
已安装
:
httpd.x86_64 0:2.4.6-99.el7.centos.1
完毕!
[root@localhost yum.repos.d]#
2.
特定软件
nginx mysql