PVE安装及配置
1、安装PVE
PVE是Proxmox VE的简称,是一个基于KVM和LXC的虚拟化平台,可以用来创建、管理和部署虚拟机。
1.1、下载安装包
访问 https://www.proxmox.com/en/downloads 下载PVE安装包。
1.2、安装PVE
按照提示一步一步安装即可。
2、Debian 软件源修改
2.1、添加pve-no-subscription
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bookworm pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list
# pve9.1.0版本
cat > /etc/apt/sources.list.d/proxmox.sources <<EOF
Types: deb
URIs: https://mirrors.ustc.edu.cn/proxmox/debian/pve
Suites: trixie
Components: pve-no-subscription
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
EOF
2.2、修改Debian软件源
sed -i 's|^deb http://ftp.debian.org|deb https://mirrors.ustc.edu.cn|g' /etc/apt/sources.list
sed -i 's|^deb http://security.debian.org|deb https://mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list
# pve9.1.0版本
sed -i 's|^URIs: http://deb.debian.org/debian/|URIs: https://mirrors.ustc.edu.cn/debian/|g' /etc/apt/sources.list.d/debian.sources
sed -i 's|^URIs: http://security.debian.org/debian-security/|URIs: https://mirrors.ustc.edu.cn/debian-security/|g' /etc/apt/sources.list.d/debian.sources
2.3、修改Ceph 仓库源
if [ -f /etc/apt/sources.list.d/ceph.list ]; then
CEPH_CODENAME=`ceph -v | grep ceph | awk '{print $(NF-1)}'`
source /etc/os-release
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-$CEPH_CODENAME $VERSION_CODENAME no-subscription" > /etc/apt/sources.list.d/ceph.list
fi
# pve9.1.0版本
sed -i 's|^URIs: https://enterprise.proxmox.com/debian/ceph-squid|URIs: https://mirrors.ustc.edu.cn/proxmox/debian/ceph-squid|g' /etc/apt/sources.list.d/ceph.sources
2.4、修改CT模板软件源
APLInfo.pm 文件属于 pve-manager 软件包,该软件包升级后,需要重新替换 URL。
sed -i.bak 's|http://download.proxmox.com|https://mirrors.ustc.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm
sed -i.bak 's|https://releases.turnkeylinux.org|https://mirrors.ustc.edu.cn/turnkeylinux/metadata|g' /usr/share/perl5/PVE/APLInfo.pm
systemctl restart pvedaemon
# 更新模板列表
pveam update
然而,TurnKey Linux 提供的 aplinfo.dat 中的 URL 不是相对路径,因此还需要修改其内容。
mkdir -p /etc/systemd/system/pve-daily-update.service.d/
cat > /etc/systemd/system/pve-daily-update.service.d/update-turnkey-releases.conf <<EOF
[Service]
ExecStopPost=/bin/sed -i 's|http://mirror.turnkeylinux.org|https://mirrors.ustc.edu.cn|' /var/lib/pve-manager/apl-info/releases.turnkeylinux.org
EOF
systemctl daemon-reload
systemctl start pve-daily-update.service
2.5、移除登陆后提示:无有效订阅
cp /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js.back
# 编辑proxmoxlib.js文件,搜索/nodes/localhost/subscription,修改本方法内容
Proxmox.Utils.API2Request({
url: '/nodes/localhost/subscription',
method: 'GET',
failure: function(response, opts) {
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
},
success: function(response, opts) {
let res = response.result;
res.data.status = 'active';
if (res === null || res === undefined || !res || res.data.status.toLowerCase() !== 'active') {
Ext.Msg.show({
title: gettext('No valid subscription'),
icon: Ext.Msg.WARNING,
message: Proxmox.Utils.getNoSubKeyHtml(res.data.url),
buttons: Ext.Msg.OK,
callback: function(btn) {
if (btn !== 'ok') {
return;
}
orig_cmd();
},
});
} else {
orig_cmd();
}
}
});
2.6、修改 chrony 时间同步配置
# 用nano编辑(新手友好,按Ctrl+O保存,Ctrl+X退出):
nano /etc/chrony/chrony.conf
# 注释原有默认源(加#号)
# pool 2.debian.pool.ntp.org iburst
# 添加国内NTP服务器(阿里云或内网ntp服务器)
# iburst参数:启动时快速同步时间,建议保留。
server ntp.aliyun.com iburst
server 192.168.10.1 iburst
# 重启chrony服务
systemctl restart chronyd
# 查看 NTP 服务器连接状态
chronyc sources -v