一.本地yum源的安装
1.第一步挂载本地ISO文件
mount /dev/cdrom /media
mount [需要挂载的设备] [挂载点]
linux使用外部设备都需要挂载到media或者mnt目录下
2.第二步新建repo文件
cd /etc/yum.repos.d
touch local.repo
.repo 后缀的文件记录yum源的信息
名字最好是挂载的文件的名字,方便以后的查看
3.编辑repo文件
vi /etc/yum.repos.d/local.repo
[local] //yum仓库的名称
name=local //描述
baseurl=file:///media //本地文件系统位置叙述
#ftp
#http://
gpgcheck=0 //时候进行检验 0不进行
enabled=1 //时候生效 0不生效
baseusrl还有其他两种方式
file://表示本地文件系统 / 表示根目录
4.加载repo文件
yum clean all //清除缓存
yum repolist //加载显示yum源文件
repo id //yum库名
repo name //yum库描述
status //rpm包的数量
二.网络yum源的安装
这个东西有一堆nginx,centos.org ,aliyun
这里就用aliyund的
这里不多说直接上有自带的教程
https://developer.aliyun.com/mirror/centos.
Centos7—其他版本这个网址里有
阿里云
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
网易
wget -O /etc/yum.repos.d/CentOS7-Base-163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
清华
[base]
name=CentOS-
r
e
l
e
a
s
e
v
e
r
−
B
a
s
e
b
a
s
e
u
r
l
=
h
t
t
p
s
:
/
/
m
i
r
r
o
r
s
.
t
u
n
a
.
t
s
i
n
g
h
u
a
.
e
d
u
.
c
n
/
c
e
n
t
o
s
/
releasever - Base baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/
releasever−Basebaseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/releasever/os/KaTeX parse error: Expected 'EOF', got '#' at position 11: basearch/ #̲mirrorlist=http…releasever&arch=$basearch&repo=os
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7
#released updates
[updates]
name=CentOS-
r
e
l
e
a
s
e
v
e
r
−
U
p
d
a
t
e
s
b
a
s
e
u
r
l
=
h
t
t
p
s
:
/
/
m
i
r
r
o
r
s
.
t
u
n
a
.
t
s
i
n
g
h
u
a
.
e
d
u
.
c
n
/
c
e
n
t
o
s
/
releasever - Updates baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/
releasever−Updatesbaseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/releasever/updates/KaTeX parse error: Expected 'EOF', got '#' at position 11: basearch/ #̲mirrorlist=http…releasever&arch=$basearch&repo=updates
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7
#additional packages that may be useful
[extras]
name=CentOS-
r
e
l
e
a
s
e
v
e
r
−
E
x
t
r
a
s
b
a
s
e
u
r
l
=
h
t
t
p
s
:
/
/
m
i
r
r
o
r
s
.
t
u
n
a
.
t
s
i
n
g
h
u
a
.
e
d
u
.
c
n
/
c
e
n
t
o
s
/
releasever - Extras baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/
releasever−Extrasbaseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/releasever/extras/KaTeX parse error: Expected 'EOF', got '#' at position 11: basearch/ #̲mirrorlist=http…releasever&arch=$basearch&repo=extras
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-
r
e
l
e
a
s
e
v
e
r
−
P
l
u
s
b
a
s
e
u
r
l
=
h
t
t
p
s
:
/
/
m
i
r
r
o
r
s
.
t
u
n
a
.
t
s
i
n
g
h
u
a
.
e
d
u
.
c
n
/
c
e
n
t
o
s
/
releasever - Plus baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/
releasever−Plusbaseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/releasever/centosplus/KaTeX parse error: Expected 'EOF', got '#' at position 11: basearch/ #̲mirrorlist=http…releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7
yum makecache就是把服务器的包信息下载到本地电脑缓存起来,makecache建立一个缓存,以后用install时就在缓存中搜索,提高了速度。
不用上网检索就能查找软件信息
配合yum -C search xxx使用
yum源出问题了,先打一套
看虚拟机cd有没有连接,内部有没有挂载
yum clean all
yum repolist