Proxmox VE安装后的一些优化
经过多方比对 Proxmox VE、VMware、VirtualBox、Hyper-V 等虚拟化平台,最终选定 Proxmox VE 开源虚拟化平台,它不但可以运行虚拟机还支持 LXC 容器,也可以应用在企业生产环境中,在个人测试学习情况下可免费使用,并且其安装上手使用相对于 VMware vSphere 更加容易。
------
1. 配置登录PVE禁止弹出订阅提示
每次使用浏览器登录到PVE的web控制台,总是会弹出订阅提示框,比较折磨人,因此可以配置禁用此项目。没有洁癖的童鞋,可以跳过此步骤。
1.1. 通过修改 JavaScript 文件
- 通过 SSH 或节点控制台登录:使用 SSH 客户端(如 PuTTY)登录到 Proxmox 服务器,或者通过 PVE Web 界面中的节点控制台进入2。
- 进入工作目录并备份文件2:
- 执行命令cd /usr/share/javascript/proxmox-widget-toolkit进入工作目录。
- 运行cp proxmoxlib.js proxmoxlib.js.bak命令,对proxmoxlib.js文件进行备份。
- 编辑文件:使用文本编辑器(如nano或vim)打开proxmoxlib.js文件。在nano中,可以使用ctrl-w搜索 "no valid subscription" 找到相关代码行。将ext.msg.show替换为void,或者将判断条件修改为data.status.toLowerCase() == 'active'(原来是!= 'active')。
- 保存并退出:在nano中使用ctrl-o保存文件,ctrl-x退出。如果使用vim,则按Esc键,输入:wq保存并退出。
- 重启 Proxmox 服务:执行systemctl restart pveproxy.service命令,重启 Proxmox 代理服务。
修改文件的方法可能在 Proxmox 升级后失效,若失效可再次进行修改。
2. 配置更新PVE主机的软件源
由于 Promox VE 默认采用 Debian 系列发行版系统,更新源在国内访问速度较慢,因此需要修改为国内镜像源,删除付费企业源,添加清华开源订阅。
2.1. 更改系统软件源
Promox VE 8.3 平台宿主操作系统版本查看:
配置 PVE 8.3 虚拟平台 Debian 12 操作字体主机源为清华大学的debian源。
cd /etc/apt/
# 备份文件
cp sources.list sources.list.bak
# 清华大学Debian源
sed -i 's#ftp.debian.org/debian#mirrors.tuna.tsinghua.edu.cn/debian#g' /etc/apt/sources.list
sed -i "s#security.debian.org#mirrors.tuna.tsinghua.edu.cn/debian-security#g" /etc/apt/sources.list
# 阿里Debian源
sed -i "s#ftp.debian.org/debian#mirrors.aliyun.com/debian#g" /etc/apt/sources.list
sed -i "s#security.debian.org#mirrors.aliyun.com/debian-security#g" /etc/apt/sources.list
配置 PVE 8.3 虚拟平台国内开源订阅源
cp /etc/apt/sources.list.d/pve-enterprise.list{,.bak}
rm -rf /etc/apt/sources.list.d/pve-enterprise.list
wget https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/proxmox-release-bookworm.gpg -O /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg
echo "deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/pve bookworm pve-no-subscription" >/etc/apt/sources.list.d/pve-no-subscription.list
配置PVE8.3 ceph为国内开源订阅源
cp /etc/apt/sources.list.d/ceph.list{,.bak}
echo "deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription" > /etc/apt/sources.list.d/ceph.list
配置PVE 8.3 虚拟平台 LXC仓库源更换
# 清华大学开源镜像站
cp /usr/share/perl5/PVE/APLInfo.pm /usr/share/perl5/PVE/APLInfo.pm_back
sed -i 's|http://download.proxmox.com|https://mirrors.tuna.tsinghua.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm
wget -O /var/lib/pve-manager/apl-info/mirrors.tuna.tsinghua.edu.cn https://mirrors.tuna.tsinghua.edu.cn/proxmox/images/aplinfo-pve-7.dat
# 重启服务
systemctl restart pvedaemon
3. 修改PVE主机IP地址
cat /etc/network/interfaces
auto lo
iface lo inet loopback
iface ens33 inet manual
auto vmbr0
iface vmbr0 inet static
address 192.168.174.92/24 #调整这里
gateway 192.168.174.2
bridge-ports ens33
bridge-stp off
bridge-fd 0
source /etc/network/interfaces.d/*
# 调整完成后,重启网络服务
sudo systemctl restart networking
PS: 这里注意,在修改完成后,我们需要同步修改/etc/hosts配置文件。
cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.174.92 pvenode2.localdomain pvenode2 # 这里也需要同步修改为host的IP地址,不然加入集群会报错。
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts