一、使用网络yum源
1、百度搜索网易mirror;
2、找到Centos帮助文档;
3、备份默认yum源;
4、复制repo文件源地址;
5、Centos中使用wget命令下载repo文件;
6、清除yum源缓存;
# yum clean all
7、生成新的yum源缓存;
# yum makecache
二、搭建本地yum源
1、配置本地yum源——本地挂载光盘等镜像文件
(1)部署步骤
虚拟机添加光盘——挂载——配置yum源——测试。
(2)部署
① 虚拟机添加光盘
② 添加挂载
# mount -r /dev/cdrom /mnt/CentOS7
# echo "/dev/sr0 /mnt/CentOS-cdrom iso9660 defaults 0 0" >> /etc/fstable
# mount -t iso9660 -o rw /opt/CentOS-7-x86_64-Minimal-1908.iso /mnt/CentOS7
# mount -t iso9660 -o loop /opt/CentOS-7-x86_64-Minimal-1908.iso /mnt/CentOS7
③ 配置yum源
[local]
name=local
baseurl=file:///mnt/CentOS7
enabled=1
gpgcheck=0
④ 测试
# yum clean all
# yum makecache
# yum repolist
# yum install wget
2、配置yum源服务器——输出yum源给其他主机使用
(1)部署
主机 | IP地址 | 组件 |
---|---|---|
Server | 192.168.1.3 | nginx |
Agent | 192.168.1.41 |
(2)配置
1) 服务端
① nginx安装
② 虚拟主机配置
server {
listen 8080;
server_name localhost'
location ^~ /CentOS7 {
root /mnt;
}
}
2) 客户端
① yum源配置
# cat /etc/yum.repo.d/Centos7.repo
[local]
name=network
baseurl=http://192.168.1.3:8080/CentOS7
enabled=1
gpgcheck=0
(3)测试
# yum clean all
# yum makecache
# yum install wget
目录