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

相关推荐
leoufung21 小时前
逆波兰表达式 LeetCode 题解及相关思路笔记
linux·笔记·leetcode
鸠摩智首席音效师1 天前
如何在 Linux 中使用 dd 命令 ?
linux·运维·服务器
一夜空中最亮的星一1 天前
【Linux】ubuntu24.04 安装docker
linux·docker·eureka
赖small强1 天前
【Linux 网络基础】libwebsockets 技术文档
linux·网络·https·tls·lib·websockets
q***51891 天前
ubuntu 安装 Redis
linux·redis·ubuntu
JuiceFS1 天前
JuiceFS sync 原理解析与性能优化,企业级数据同步利器
运维·后端
q***47181 天前
使用Canal将MySQL数据同步到ES(Linux)
linux·mysql·elasticsearch
Logan Lie1 天前
Web服务监听地址的取舍:0.0.0.0 vs 127.0.0.1
运维·后端
Y淑滢潇潇1 天前
RHCE 防火墙实验
linux·运维·rhce
wadesir1 天前
当前位置:首页 > 服务器技术 > 正文Linux网络HSRP协议(实现路由器热备份与高可用性的实用指南)
linux·服务器·网络