文章目录
前言
紧接上一篇PVE的安装,接下来我将进行pve的基础配置之一更换国内源,并关闭无效订阅
一、为什么要更换成国内源
因为Proxmox 默认的软件源服务器位于国外,国内用户直接访问时可能因物理距离远、国际带宽限制等原因,导致下载速度缓慢。而更换为阿里云、清华大学、中科大等国内镜像源后,软件包和更新的下载速度会显著提升,减少等待时间。
二、换源具体操作
1.更换Debian源
(1)确认Debian版本代号(11-Bullseys/12-Bookworm)
在shell中输入以下指令
cat /etc/*-release #查阅Debian版本代号
可以看到我这里显示的是bookworm说明我的是Debian12版本的我们要去找12版本的国内源这里推荐大家直接去清华大学开源软件镜像站复制粘贴到对应文件下即可(后续更换更新其他源也能在里面找到对应版本)
(2)进行换Debian源
用nano指令进入sources.list文件将原有的源进行注释掉或者删除
注释即在最前加上 #
nano /etc/apt/sources.list
将前面的清华源复制粘贴到这个文件里即可
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
以上操作完成后,按下Ctrl+O回车保存,Ctrl+X退出即可
2.更换pve软件源
(1)更换ceph分布式源
大致操纵与更换Deian源一样,后续进行分布式存储时会具体介绍这里大家一键复制粘贴到shell即可使用(后续不再强调时就默认在shell里操作)
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription" > /etc/apt/sources.list.d/ceph.list
sed -i.bak "s#http://download.proxmox.com/debian#https://mirrors.ustc.edu.cn/proxmox/debian#g" /usr/share/perl5/PVE/CLI/pveceph.pm
(2)删除或者屏蔽默认企业源
为什么要进行这步操作呢?
企业源需要付费订阅Proxmox 企业源(enterprise.proxmox.com)仅对付费订阅用户开放,访问时会验证订阅密钥。
社区用户无权限如果未购买订阅,服务器会返回 401 Unauthorized 错误(如你遇到的报错),导致无法下载任何软件包。
rm -rf /etc/apt/sources.list.d/pve-enterprise.list
# 删除企业源
mv /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources.list.d/pve-enterprise.list.bak
#屏蔽企业源
(3)修复https证书并更新软件源
apt update && apt-get install -y apt-transport-https ca-certificates --fix-missing
(4)更新索引并升级安装软件包
apt update && apt dist-upgrade
(5)更新LXC容器仓库源
sed -i.bak "s#http://download.proxmox.com/images#https://mirrors.ustc.edu.cn/proxmox/images#g" /usr/share/perl5/PVE/APLInfo.pm
systemctl restart pvedaemon
# 重启PVE核心配置,手动刷新页面
3.删除无效订阅
sed -Ezi.bak "s/(Ext.Msg.show\(\{\s+title: gettext\('No valid sub)/void\(\{ \/\/\1/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js && systemctl restart pveproxy.service
# 重启pveproxy.service完成后,需注销PVE登录后, 重新启动浏览器
总结
换源是pve开始的重要的一步,对后期的下载速度以及各种安装操作有着极大的帮助。
注意问题:
1.一定要确认好自己的pve是Debian多少的版本,不然换源换错会频频报满红
2.没有订阅企业版的要把企业源删掉,不然会一直有401之类的报错困扰