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 小时前
高速公路自动化安全监测主要内容
运维·物联网·安全·自动化
cpsvps1 小时前
香港服务器SSH安全加固方案与密钥认证实践
服务器·安全·ssh
运维开发王义杰1 小时前
告别手动迁移:使用 PowerShell 一键导出 IIS 配置,让服务器迁移更轻松
运维·服务器·windows
阿巴~阿巴~2 小时前
深入理解Linux文件操作:stdin/stdout/stderr与C语言文件函数全解析
linux·运维·服务器
阿巴~阿巴~2 小时前
深度解析Linux文件I/O三级缓冲体系:用户缓冲区→标准I/O→内核页缓存
linux·运维·服务器
tan77º2 小时前
【Linux网络编程】应用层协议 - HTTP
linux·服务器·网络·c++·http·https·tcp
2301_785251412 小时前
上网行为管理-web认证服务
运维·服务器·网络
帅帅气气的黑猫警长2 小时前
Ubuntu环境下的K3S集群搭建
服务器·ubuntu·k8s
楼田莉子3 小时前
Linux学习之认识Linux的基本指令
linux·运维·服务器·开发语言·学习
GIS数据转换器3 小时前
铁路基础设施无人机巡检技术及管理平台
运维·安全·microsoft·自动化·无人机