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

相关推荐
wanhengidc1 分钟前
云手机 无限畅玩手游 巨 椰
运维·服务器·网络·游戏·智能手机
Sylvia@88813 分钟前
19.管理基本存储
linux·运维·1024程序员节
文火冰糖的硅基工坊14 分钟前
[嵌入式系统-150]:智能机器人(具身智能)内部的嵌入式系统以及各自的功能、硬件架构、操作系统、软件架构
android·linux·算法·ubuntu·机器人·硬件架构
susu108301891132 分钟前
ubuntu 查看文件夹占了多大
linux·运维·ubuntu
小涵42 分钟前
第 01 天:Linux 是什么?内核、发行版及其生态系统
linux·运维·devops·1024程序员节·sre
hhhh明1 小时前
Google Drive 超大文件下载到服务器
服务器·网络·google drive
小小的木头人1 小时前
APT 安装方式(适合生产环境)Zabbix 6.4 LTS
运维·zabbix
IvanCodes1 小时前
十六、Linux网络配置
linux·运维·网络
j_xxx404_1 小时前
Linux:权限(完结)|权限管理|修改权限chmod chown charp|文件类型|拓展
linux·运维·服务器
板鸭〈小号〉1 小时前
应用层自定义协议与序列化
运维·服务器·网络·1024程序员节