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",标识成功

相关推荐
计算机安禾1 分钟前
【Linux从入门到精通】第12篇:进程的前后台切换与信号控制
linux·运维·算法
Cyan_RA98 分钟前
如何利用 Paddle-OCR 丝滑进行复杂版面 PDF 的批量化OCR处理?
java·linux·python·ocr·conda·paddle·surya
AC赳赳老秦10 分钟前
OpenClaw与Notion联动:自动同步工作任务、整理笔记,实现高效管理
运维·人工智能·python·数学建模·自动化·deepseek·openclaw
上海云盾安全满满11 分钟前
服务器带宽一直跑高,是什么情况
运维·服务器
.柒宇.12 分钟前
信创实战:银河麒麟 V10 服务器安装、网络配置与 Docker 环境搭建
linux·运维·docker·国产信创·麒麟操作系统
瀚高PG实验室14 分钟前
PostgreSQL pg_dump对象名称中有换行符时可导致psql客户端及恢复目标服务器执行任意恶意代码HGVE-2025-E008
服务器·数据库·postgresql·瀚高数据库
云动课堂15 分钟前
【运维实战】企业级SFTP 文件服务 · 一键自动化部署方案 (适配AnolisOS /openEuler /CentOS)
运维·centos·自动化
杨浦老苏15 分钟前
Docker容器管理面板Dockhand
运维·docker·群晖
特长腿特长19 分钟前
LVS的DR模式和NET模式的基础案例
服务器·php·lvs
diygwcom21 分钟前
jeecg验证码在centos报错
linux·运维·centos