跳到主要内容

ProxmoxVE(PVE) 配置国内软件源并删除订阅弹窗

概述

ProxmoxVE是一个开源的虚拟化平台,基于Debian系统。在国内使用时,由于网络原因,默认的软件源下载速度较慢。同时,免费版本会显示订阅弹窗提醒。本文档将介绍如何配置国内软件源并删除订阅弹窗。

1. 配置国内软件源

1.1 备份原有源文件

cp /etc/apt/sources.list /etc/apt/sources.list.backup
cp /etc/apt/sources.list.d/pve-enterprise.list /etc/apt/sources.list.d/pve-enterprise.list.backup

1.2 修改系统软件源

编辑 /etc/apt/sources.list 文件:

nano /etc/apt/sources.list

将内容替换为:

# 阿里云镜像源
deb https://mirrors.aliyun.com/debian/ bullseye main contrib non-free
deb https://mirrors.aliyun.com/debian/ bullseye-updates main contrib non-free
deb https://mirrors.aliyun.com/debian/ bullseye-backports main contrib non-free
deb https://mirrors.aliyun.com/debian-security bullseye-security main contrib non-free

1.3 配置PVE软件源

编辑 /etc/apt/sources.list.d/pve-enterprise.list 文件:

nano /etc/apt/sources.list.d/pve-enterprise.list

将内容替换为:

# PVE免费软件源
deb https://mirrors.aliyun.com/proxmox/debian bullseye pve-no-subscription

1.4 更新软件包列表

apt update

2. 删除订阅弹窗

2.1 方法一:修改JavaScript文件(推荐)

找到并编辑订阅弹窗的JavaScript文件:

nano /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js

在文件中搜索 Ext.Msg.show,找到类似以下代码:

Ext.Msg.show({
title: gettext('No valid subscription'),
message: gettext('You do not have a valid Proxmox VE subscription.'),
buttons: Ext.Msg.OK,
icon: Ext.Msg.WARNING
});

将其注释掉或删除。

2.2 方法二:修改CSS文件

编辑CSS文件来隐藏弹窗:

nano /usr/share/pve-manager/css/ext6-custom.css

添加以下内容:

.x-message-box {
display: none !important;
}

2.3 方法三:使用sed命令快速修改

sed -i.bak "s/data.status !== 'Active'/false/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js

3. 重启服务

修改完成后,重启相关服务:

systemctl restart pveproxy
systemctl restart pvedaemon

4. 验证配置

4.1 检查软件源

apt update
apt list --upgradable

4.2 检查Web界面

打开浏览器访问PVE管理界面,确认:

  • 不再显示订阅弹窗
  • 软件包可以正常更新

5. 其他优化建议

5.1 配置NTP时间同步

apt install ntp
systemctl enable ntp
systemctl start ntp

5.2 优化网络配置

编辑 /etc/sysctl.conf

# 网络优化
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216

应用配置:

sysctl -p

5.3 配置防火墙

# 允许PVE管理端口
ufw allow 8006/tcp
ufw allow 22/tcp
ufw enable

6. 故障排除

6.1 软件源更新失败

如果更新失败,可以尝试:

# 清理缓存
apt clean
apt autoclean

# 重新配置软件包
dpkg --configure -a
apt install -f

6.2 弹窗仍然出现

如果弹窗仍然出现,可以:

  1. 清除浏览器缓存
  2. 检查文件修改是否正确
  3. 重启PVE服务
systemctl restart pveproxy
systemctl restart pvedaemon
systemctl restart pvestatd

7. 注意事项

  1. 备份重要数据:在进行任何修改前,请备份重要数据
  2. 版本兼容性:不同版本的PVE可能文件路径略有不同
  3. 定期更新:建议定期更新系统以获得安全补丁
  4. 监控系统:定期检查系统性能和日志

8. 常用命令

# 查看PVE版本
pveversion -v

# 查看系统状态
pvesm status

# 查看虚拟机列表
qm list

# 查看存储信息
pvesm status

# 查看网络配置
cat /etc/network/interfaces

通过以上配置,您的ProxmoxVE将使用国内软件源,下载速度更快,同时不再显示订阅弹窗提醒。