树莓派4b安装pve开小机
目录
这篇文章介绍了如何在树莓派4b上安装pve
注意
注1、安装好后的web ui地址https://192.168.1.7:8006/
1 安装Debian官方系统
1.1 下载Debian镜像
国内可以在清华源下载Debian的arm64网络安装镜像
1.2 下载树莓派4b uefi固件
安装Debian官方镜像需要uefi引导可在Raspberry Pi 4 UEFI Firmware Images项目下载
1.3 安装Debian
首先用DiskGenius分区工具将准备安装系统的sd卡或u盘重新分区为GUID分区表,创建100m的esp分区,其余空间保持空白。将Raspberry Pi 4 UEFI Firmware解压,并放置到esp分区根目录。另一个u盘做镜像安装盘用ventoy制作一个启动盘,放置下载的Debian镜像,然后按正常流程安装Debian。
2 安装Proxmox VE
2.1 文档安装
目前pve官方只支持x86处理器,没有arm版本,梨儿方移植到了arm我们按照文档从Debian安装到pve,按照顺序做到配置静态ip一步由于我用的是WiFi,配置文件如下
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug wlan0
iface wlan0 inet static
wpa-ssid CU_REx3_5G
wpa-psk 6d54dx54
address 192.168.1.7/24
gateway 192.168.1.1
大家可结合实际修改。重启几次确认ifupdown2配置的网络没有问题在apt安装pve
2.2 安装完的网络配置
x86的官方pve在web ui进行配置就可以了,这个移植的pve网络那里的应用配置按键不起作用,我们要通过命令手动修改网络配置
sudo nano /etc/network/interfaces
放入如下配置文件
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug wlan0
iface wlan0 inet static
wpa-ssid CU_REx3_5G
wpa-psk 6d54dx54
address 192.168.1.7/24
gateway 192.168.1.1
auto vmbr0
iface vmbr0 inet static
address 10.0.0.1/24
bridge-ports none
bridge-stp off
bridge-fd 0
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '10.0.0.0/24' -o wlan0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '10.0.0.0/24' -o wlan0 -j MASQUERADE
# 192.168.1.7:13522 -> 10.0.0.13:22
post-up iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 13522 -j DNAT --to-destination 10.0.0.13:22
post-down iptables -t nat -D PREROUTING -i wlan0 -p tcp --dport 13522 -j DNAT --to-destination 10.0.0.13:22
# 192.168.1.7:9030 -> 10.0.0.13:9030
post-up iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 9030 -j DNAT --to-destination 10.0.0.13:9030
post-down iptables -t nat -D PREROUTING -i wlan0 -p tcp --dport 9030 -j DNAT --to-destination 10.0.0.13:9030
# 192.168.1.7:13622 -> 10.0.0.15:22
post-up iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 13622 -j DNAT --to-destination 10.0.0.15:22
post-down iptables -t nat -D PREROUTING -i wlan0 -p tcp --dport 13622 -j DNAT --to-destination 10.0.0.15:22
# 192.168.1.7:5666 -> 10.0.0.16:5666
post-up iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 5666 -j DNAT --to-destination 10.0.0.16:5666
post-down iptables -t nat -D PREROUTING -i wlan0 -p tcp --dport 5666 -j DNAT --to-destination 10.0.0.16:5666
重启网络
systemctl restart networking
配置网络时随时可能出现网络不可用,需要临时配置ip和网关
sudo ip addr add 192.168.1.7/24 dev wlan0 # 设置IP
sudo ip route add default via 192.168.1.1 dev wlan0 # 设置网关
这个网络配置是vmbr0作为内网10.0.0.0的nat网段桥接到wlan0
3 注意事项
3.1 临时配置代理
export http_proxy="http://127.0.0.1:28080"
3.2 重启设备可能出现网卡配置丢失
注意,web ui修改网络配置,重启可能出现网卡配置文件丢失问题,如无法ping通baidu.com可以查看,网络配置是否丢失了一部分,重新写入完整配置文件。
3.3 vm虚拟机网卡选择
vm虚拟机安装时需要选择e1000网卡兼容nat网络,安装完成后需要换回VirtIO
3.4 虚拟机重启概率性断网
虚拟机vm不能重启,要关机后启动,不然概率性断网。
3.5 可先创建alpine的lxc容器测试pve网络配置是否正常。
3.6 vps上部署pve网络配置文件
# network interface settings; autogenerated
# Please do NOT modify this file directly, unless you know what
# you're doing.
#
# If you want to manage parts of the network configuration manually,
# please utilize the 'source' or 'source-directory' directives to do
# so.
# PVE will preserve these directives, but will NOT read its network
# configuration from sourced files, so do not attempt to move any of
# the PVE managed interfaces into external files!
auto lo
iface lo inet loopback
iface eth0 inet manual
dns-nameservers 8.8.8.8 8.8.4.4
auto vmbr0
iface vmbr0 inet static
address 107.175.254.113/24
gateway 107.175.254.1
bridge-ports eth0
bridge-stp off
bridge-fd 0
auto vmbr1
iface vmbr1 inet static
address 10.0.0.1/24
bridge-ports none
bridge-stp off
bridge-fd 0
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '10.0.0.0/24' -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '10.0.0.0/24' -o vmbr0 -j MASQUERADE
# --- 新增的端口转发规则 ---
# 将公网 12522 转发到容器 10.0.0.10 的 22 端口
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 12522 -j DNAT --to-destination 10.0.0.10:22
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 12522 -j DNAT --to-destination 10.0.0.10:22
# 将公网 12322 转发到容器 10.0.0.11 的 22 端口
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 12322 -j DNAT --to-destination 10.0.0.11:22
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 12322 -j DNAT --to-destination 10.0.0.11:22
source /etc/network/interfaces.d/sdn