CentOS7 内网服务器yum修改

1、首先确定的内网服务器是有yum源代理服务器的

2、修改 /etc/yum.conf 配置文件,增加代理ip和端口号

proxy=http://ip.ip.ip.ip:port

3、备份源是文件

bash 复制代码
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

4、修改配置文件 vi CentOS-Base.repo,之后保存

bash 复制代码
# CentOS-Base.repo
# 替换为阿里云镜像源后的配置

[base]
name=CentOS-7 - Base - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/7/os/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
# 已禁用mirrorlist机制
# mirrorlist=http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=$infra

[updates]
name=CentOS-7 - Updates - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/7/updates/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
# 已禁用mirrorlist机制
# mirrorlist=http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=$infra

[extras]
name=CentOS-7 - Extras - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/7/extras/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
# 已禁用mirrorlist机制
# mirrorlist=http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=$infra

[centosplus]
name=CentOS-7 - Plus - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/7/centosplus/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
# 已禁用mirrorlist机制
# mirrorlist=http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=centosplus&infra=$infra

5、执行命令清理并重建缓存

bash 复制代码
sudo yum clean all
sudo yum makecache

6、验证配置

bash 复制代码
yum repolist

输出内容包含baseurl中的地址"mirrors.aliyun.com",标识成功

相关推荐
专注API从业者6 分钟前
Python/Java 代码示例:手把手教程调用 1688 API 获取商品详情实时数据
java·linux·数据库·python
Ribou39 分钟前
Ubuntu 24.04.2安装k8s 1.33.4 配置cilium
linux·ubuntu·kubernetes
tan180°1 小时前
Boost搜索引擎 网络库与前端(4)
linux·网络·c++·搜索引擎
小小菜鸡ing2 小时前
pymysql
java·服务器·数据库
Mr. Cao code2 小时前
Docker:颠覆传统虚拟化的轻量级革命
linux·运维·ubuntu·docker·容器
抓饼先生2 小时前
Linux control group笔记
linux·笔记·bash
挺6的还3 小时前
25.线程概念和控制(二)
linux
wanhengidc3 小时前
云手机运行流畅,秒开不卡顿
运维·网络·科技·游戏·智能手机
您的通讯录好友3 小时前
conda环境导出
linux·windows·conda
笨小孩@GF 知行合一4 小时前
OSPF实验:外部路由引入
运维·网络·hcip·数通·ospf