PVE开源虚拟化管理平台
PVE-开源虚拟化管理平台
[TOC]
环境准备
- 使用官方的iso镜像部署三个PVE节点
- 部署1个Backup server
- 尽量使用==相同类型的cpu==
部署PVE节点
- 默认下一步
- CPU:共4个核心 运行内存 8G



- 别忘记勾选虚拟化

- 每个虚拟机六张网卡,一张nat,五张桥接
- 每个节点5块硬盘
- 一块硬盘装系统
- 三块硬盘作为osd —> ceph集群
- 一块硬盘备用
- 三块网卡给不同的MAC地址!

- 拍一次快照

图形化安装





📌 安装页面到底在配什么?
Proxmox 安装程序 → 「管理网络」页面 │ │ 你填的 IP、掩码、网关、DNS │ ▼ 自动写入 /etc/network/interfaces → vmbr0 的配置 │ ▼ 安装完成后,这个 IP 就是 Web UI 的访问地址===============================================💡 这个页面本质上就是一个'图形化的网络配置向导'✅️ PVE Web UI (pveproxy) → 监听 0.0.0.0:8006(所有网卡)⭐节点规划
g2-host1.pve.com — PVE 节点 + Ceph 节点
| 项目 | 配置 |
|---|---|
| 网络 | nic0(NAT):10.0.0.211(DHCP),网关 10.0.0.2 nic1(桥接):10.2.1.101 — PVE 管理网络 nic2(桥接):10.2.2.101 — PVE 集群网络 nic3(桥接):10.2.3.101 — OSD Public nic4(桥接):10.2.4.101 — OSD Cluster nic5(桥接):10.2.5.101 — OVS 网桥 vmbr1 |
| 磁盘 | sda:系统盘 sdb–sdd:Ceph OSD(共 3 块) sde:本地目录存储 |
g2-host2.pve.com — PVE 节点 + Ceph 节点
| 项目 | 配置 |
|---|---|
| 网络 | nic0(NAT):10.0.0.222(DHCP),网关 10.0.0.2 nic1(桥接):10.2.1.102 — PVE 管理网络 nic2(桥接):10.2.2.102 — PVE 集群网络 nic3(桥接):10.2.3.102 — OSD Public nic4(桥接):10.2.4.102 — OSD Cluster nic5(桥接):10.2.5.102 — 额外网桥 vmbr1 |
| 磁盘 | sda:系统盘 sdb–sdd:Ceph OSD(共 3 块) sde:本地 ZFS 存储 |
g2-host3.pve.com — PVE 节点 + Ceph 节点
| 项目 | 配置 |
|---|---|
| 网络 | nic0(NAT):10.0.0.233(DHCP),网关 10.0.0.2 nic1(桥接):10.2.1.103 — PVE 管理网络 nic2(桥接):10.2.2.103 — PVE 集群网络 nic3(桥接):10.2.3.103 — OSD Public nic4(桥接):10.2.4.103 — OSD Cluster nic5(桥接):10.2.5.103 — OVS 网桥 vmbr1 |
| 磁盘 | sda:系统盘 sdb–sdd:Ceph OSD(共 3 块) sde:本地 LVM_Thin 存储 ⚠️ sdf:本地 ZFS 存储 |
g2-pbs.pve.com — Proxmox Backup Server 节点
| 项目 | 配置 |
|---|---|
| 网络 | nic0(NAT):10.0.0.244(DHCP),网关 10.0.0.2 nic1(桥接):10.2.1.104 — PVE 管理网络 |
| 磁盘 | sda:系统盘 sdb:备份存储磁盘 |
gX-node.pve.com — 管理操作节点
| 项目 | 配置 |
|---|---|
| 网络 | nic0(NAT):10.0.0.210(DHCP),网关 10.0.0.2 nic1(桥接):10.2.1.105 — PVE 管理网络 |
| 磁盘 | nvme0n1:系统盘 + 数据盘 |
| 用途 | 浏览器访问 WebUI、配置 NFS/Samba 共享、上传镜像 |
Vir-02 --> '另一台Rocky虚拟机'# 添加一张桥接网卡,和它处于同一网段
root@Vir-02:~# vim /etc/NetworkManager/system-connections/eth1.nmconnection'10.2.1.105'root@Vir-02:~# nmcli connection reloadroot@Vir-02:~# nmcli con up eth1Connection successfully activated[root@Vir-02 ~]# ip a s eth1 | grep inet | head -1 inet 10.2.1.105/24 brd 10.11.0.255 scope global noprefixroute eth1root@Vir-02:~# ping 10.2.1.101PING 10.2.1.101 (10.2.1.101) 56(84) bytes of data.64 bytes from 10.2.1.101: icmp_seq=1 ttl=64 time=0.502 ms64 bytes from 10.2.1.101: icmp_seq=2 ttl=64 time=0.303 ms🌰 '远程登录管理'root@Vir-02:~# ssh root@10.2.1.101Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extentpermitted by applicable law.root@pve:~#实操
1)备份软件源root@pve:~# mkdir /sourcebakroot@pve:~# cp -p /etc/apt/sources.list.d/* /sourcebak
2)更改默认的软件源=========================# 修改文件默认没有vim命令Debian 预装的 vim-tiny 为了兼容老式 vi,默认开启了一个“兼容模式”(compatible)所以一些现代编辑器的习惯就不起作用了📝执行:set nocompatible,关闭兼容模式========================='我们改用cat进行修改'root@pve:~# cat > /etc/apt/sources.list.d/debian.sources <<'EOF'Types: debURIs: http://mirrors.aliyun.com/debian/Suites: trixie trixie-updatesComponents: main contrib non-free-firmwareSigned-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: debURIs: http://mirrors.aliyun.com/debian-security/Suites: trixie-securityComponents: main contrib non-free-firmwareSigned-By: /usr/share/keyrings/debian-archive-keyring.gpgEOF
3)更换pve企业源root@pve:~# rm -rf /etc/apt/sources.list.d/pve-enterprise.sourcesroot@pve:~# cat > /etc/apt/sources.list.d/proxmox.sources <<'EOF'Types: debURIs: http://download.proxmox.com/debian/pveSuites: trixieComponents: pve-no-subscriptionSigned-By: /usr/share/keyrings/proxmox-archive-keyring.gpgEOF
4)更换ceph源root@pve:~# cat > /etc/apt/sources.list.d/ceph.sources <<'EOF'Types: debURIs: http://download.proxmox.com/debian/ceph-tentacleSuites: trixieComponents: no-subscriptionSigned-By: /usr/share/keyrings/proxmox-archive-keyring.gpgEOF
5)配置网络配置root@pve:~# cat > /etc/network/interfaces <<'EOF'auto loiface lo inet loopback
iface nic1 inet manual# pve管理网络
auto nic0# 物理网卡(NAT)-->用来上网iface nic0 inet static address 10.0.0.101/24 gateway 10.0.0.2
auto nic2# pve集群网络iface nic2 inet static address 10.2.2.101/24
auto nic3# ceph集群公网iface nic3 inet static address 10.2.3.101/24
auto nic4# ceph集群内网iface nic4 inet static address 10.2.4.101/24
auto nic5# 备用桥接网卡iface nic5 inet static address 10.2.5.101/24
auto vmbr0# pve管理网络# 物理网卡 nic1(作为 vmbr0 的桥接端口)# 这里物理网卡是桥接的那张网卡iface vmbr0 inet static address 10.2.1.101/24 bridge-ports nic1 bridge-stp off bridge-fd 0
source /etc/network/interfaces.d/*EOF💡 '语法要点:'auto vmbr0# pve管理网络# 物理网卡 nic1(作为 vmbr0 的桥接端口)# 这里物理网卡是桥接的那张网卡iface vmbr0 inet static address 10.2.1.101/24 bridge-ports nic1 bridge-stp off bridge-fd 0| 配置行 | 含义 |
|---|---|
auto vmbr0 | 开机自动启动这个 bridge |
iface vmbr0 inet static | 静态 IP(不是 DHCP) |
address 10.2.1.101/24 | IP 地址 + 子网掩码(/24) |
bridge-ports nic1 | 把 nic1 插到这个 bridge 上 |
bridge-stp off | 关闭生成树协议(单链路上不需要,省资源) |
bridge-fd 0 | 转发延迟设为 0(立即转发,不等待) |
没有 gateway | 不上网,不需要网关! |
📌 问题:vmbr0 到底是什么?它和物理网卡关系?
🧱 物理网卡 (eth0) vs Linux Bridge (vmbr)
🧱 vmbr0 到底是什么?
通俗类比:把物理网卡 eth0 想象成一根”网线”,vmbr0 就是这根网线另一头插的那个 ==虚拟交换机==
- eth0 只负责收发数据帧,自己不拿 IP(你看
ip a里 eth0 只有 MAC 地址,没有inet)- vmbr0 是 Linux 内核创建的虚拟交换机,它拿 IP 地址,它才是通信的”身份”
bridge-ports eth0的意思是:把 eth0 这根网线插到 vmbr0 这个交换机上
inet manual的意思是:“这张网卡本身不拿 IP,它只是给上面的 bridge 当物理出口”就像交换机的端口不需要 IP 一样,eth 作为物理口也不需要 IP,IP 配在 vmbr 上
📌 一句话总结:
eth 是物理网线,vmbr 是插网线的交换机,IP 配在交换机上,不配在网线上
⚠️ 注意:vmbr0 的 MAC 地址 = eth0 的 MAC 地址,因为它们是一对”交换机-上联口”
6)重启网络让配置生效root@pve:~# systemctl restart networkingroot@pve:~# cat /etc/resolv.confsearch localhostnameserver 223.6.6.6root@pve:~# ping -W2 -c2 www.baidu.comPING www.a.shifen.com (180.101.49.44) 56(84) bytes of data.64 bytes from 180.101.49.44: icmp_seq=1 ttl=128 time=24.8 ms64 bytes from 180.101.49.44: icmp_seq=2 ttl=128 time=24.4 ms
--- www.a.shifen.com ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 1001msrtt min/avg/max/mdev = 24.384/24.603/24.823/0.219 ms
7)升级软件源 & 安装必要软件root@pve:~# apt-get updateroot@pve:~# apt-get install -y vim tree wget bash-completion lrzsz net-tools sysstat iotop iftop htop unzip netcat-openbsd nmap telnet bc psmisc apache2-utils dnsutils nethogs sshpass expect cowsay sl
8)PS1 变量root@pve:~# cat >> ~/.bashrc <<EOF# 我的PS1变量PS1='\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\]\[\e[31;1m\] \W\[\e[0m\]\\$ 'EOFroot@pve:~# source ~/.bashrc
9)娱乐时间⌚️===============在 Debian/Ubuntu 系统中,sl、cowsay、fortune 等娱乐性质的程序传统上被归类为 "games",安装路径是 /usr/games/ 而不是常规的 /usr/bin/而 root 用户的默认 $PATH 有时并不包含 /usr/games✅ 永久解决方法将 /usr/games 添加到 root 用户的 PATH 中:===============root@pve ~# echo 'export PATH=$PATH:/usr/games' >> ~/.bashrcroot@pve ~# source ~/.bashrcroot@pve ~# cowsay "Hello" _______< Hello > ------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||root@pve ~# rm -f /etc/update-motd.d/10-unameroot@pve ~# cat > /etc/update-motd.d/99-local << 'SCRIPT'#!/bin/bashcat << 'EOF' (@) * (@) * (@) : * (@) * (@) * .; (@) * (@) * (@) * (@) * ; * ; (@) * ; * : ;\ \ \ \| / / /; \\ \ Y/ / / `_\ |/ _' ' / \\Y// \ ( ,-}={-, ) \_//((\_/ //))(\ (/ )) (/EOFSCRIPTroot@pve ~# chmod +x /etc/update-motd.d/99-localroot@pve ~# > /etc/issue && > /etc/issue.net
10)其他优化root@pve ~# cat >>/etc/ssh/sshd_config<<EOFUseDNS no# 相当于网络命令的-n选项,这个就是说不解析为主机名,直接成IP地址.GSSAPIAuthentication no# 关闭GSS认证.EOFroot@pve ~# systemctl restart ssh.service
11)系统盘挂载'UUID挂载'root@host01 ~# blkid/dev/mapper/pve-root: UUID="b2666a2a-a057-4de1-9aa6-cdb1211809a5"/dev/mapper/pve-swap: UUID="aba324d1-3307-4d83-88e2-5e9698138e20"root@host01 ~# vim /etc/fstabUUID="b2666a2a-a057-4de1-9aa6-cdb1211809a5" / ext4 errors=remount-ro 0 1UUID="aba324d1-3307-4d83-88e2-5e9698138e20" none swap sw 0 0浏览器测试访问https://10.11.0.111:8006'👆是我们桥接这张网卡' <-- Rocky中的火狐浏览器可以正常访问=============================https://10.0.0.211:8006'👆是我们NAT这张网卡' <-- Windows中的edge浏览器可以正常访问

backup
'两块硬盘' --> 系统盘 & 备份存储磁盘'两张网卡' --> 额外添加一张桥接# 10.2.1.104'主机名' --> g2-pbs.pve.com
'访问web UI'删除网关,添加IP配置(NAT)
'替换源'cat > /etc/apt/sources.list.d/debian.sources <<'EOF'Types: debURIs: http://mirrors.aliyun.com/debian/Suites: trixie trixie-updatesComponents: main contrib non-free-firmwareSigned-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: debURIs: http://mirrors.aliyun.com/debian-security/Suites: trixie-securityComponents: main contrib non-free-firmwareSigned-By: /usr/share/keyrings/debian-archive-keyring.gpgEOF
==========================
cat > /etc/apt/sources.list.d/pbs-enterprise.sources <<'EOF'Types: debURIs: http://download.proxmox.com/debian/pbsSuites: trixieComponents: pbs-no-subscriptionSigned-By: /usr/share/keyrings/proxmox-archive-keyring.gpgEOF
==========================
apt-get update
apt-get install -y vim tree wget bash-completion lrzsz net-tools sysstat iotop iftop htop unzip netcat-openbsd nmap telnet bc psmisc apache2-utils dnsutils nethogs sshpass expect cowsay sl
cat >> ~/.bashrc <<EOF# 我的PS1变量PS1='\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\]\[\e[31;1m\] \W\[\e[0m\]\\$ 'EOF
echo 'export PATH=$PATH:/usr/games' >> ~/.bashrc
source ~/.bashrc
cat > /etc/update-motd.d/99-local << 'SCRIPT'#!/bin/bashcat << 'EOF' (@) * (@) * (@) : * (@) * (@) * .; (@) * (@) * (@) * (@) * ; * ; (@) * ; * : ;\ \ \ \| / / /; \\ \ Y/ / / `_\ |/ _' ' / \\Y// \ ( ,-}={-, ) \_//((\_/ //))(\ (/ )) (/EOFSCRIPT
chmod +x /etc/update-motd.d/99-local
> /etc/issue && > /etc/issue.net
cat >>/etc/ssh/sshd_config<<EOFUseDNS no# 相当于网络命令的-n选项,这个就是说不解析为主机名,直接成IP地址.GSSAPIAuthentication no# 关闭GSS认证.EOF
systemctl restart ssh.service- 关机拍快照
加入集群


- 加入集群

集群状态 —> 断开连接 —> 另外两台重新登录
任务二
在 PVE 集群上部署 Ceph Tentacle,创建 OSD 并配置 CephFS 和 RBD 共享存储
- 在 WebUI 中点击 Datacenter → g2-host1 → Ceph,进行安装
- 在 WebUI 中点击 Datacenter → g2-host2 → Ceph,进行安装
- 在 WebUI 中点击 Datacenter → g2-host3 → Ceph,进行安装
- 等待安装完成

- 无订阅

'另外两台'同样也是需要添加Ceph集群# 只需要安装即可! 配置已经在Host1中配置选择过了 公网 & 私网
- 现在的状态是”不健康”❌️ —> 先不管它
添加mon & mgr
创建mon
- 点击 g2-host1 → Ceph → Monitor
- 点击 Monitor → Create
- 重复操作,分别在 host2、host3 上创建 Monitor
- 等待所有 Monitor 启动完成
创建mgr
- 点击 g2-host1 → Ceph → Monitor
- 点击 Manager → Create
- 在 host2、host3 也创建一个(用于高可用)

把另外两台都添加上去!

添加 OSD 硬盘
在每个节点上创建 3 个 OSD(sdb、sdc、sdd),共 9 个



这次再添加完 mon & mgr & OSD磁盘就行健康了💚✅️
创建RBD池 & CephFS

创建完之后, 就可以在==左上角==创建cephFS了



查看器群状态健康✅️
任务三






任务四
在三台 PVE 节点上分别使用 sde 磁盘创建不同类型的本地存储





任务五
在管理操作节点(node)上部署 NFS 和 Samba 服务,并将共享目录添加到 PVE 集群
1)nfs下载安装[root@node-200 ~]# dnf -y install nfs-utils[root@node-200 ~]# mkdir -p /srv/nfs/share[root@node-200 ~]# echo '/srv/nfs/share 10.11.0.0/24(rw,sync,no_subtree_check,no_root_squash)' >> /etc/exports[root@node-200 ~]# systemctl enable --now nfs-serverCreated symlink '/etc/systemd/system/multi-user.target.wants/nfs-server.service' → '/usr/lib/systemd/system/nfs-server.service'[root@node-200 ~]# showmount -e 10.11.0.128Export list for 10.11.0.128:/srv/nfs/share 10.11.0.0/24
node节点接着安装samba
'下载samb'[root@node-200 ~]# yum -y install samba[root@node-200 ~]# mkdir -p /srv/samba/share[root@node-200 ~]# groupadd -g 888 smbuser[root@node-200 ~]# useradd -g 888 -u 888 smbuser[root@node-200 ~]# pdbedit -a smbuserNew password:Retype new password:[root@node-200 ~]# chown smbuser:smbuser /srv/samba/share/[root@node-200 ~]# cat >> /etc/samba/smb.conf <<'EOF'[samba-share] path = /srv/samba/share write list = smbuser valid users = smbuserEOF[root@node-200 ~]# getenforceDisabled[root@node-200 ~]# systemctl is-active firewalld.serviceinactive[root@node-200 ~]# systemctl enable --now smb nmb

任务六
在三台 PVE 节点上使用 nic5 创建 Open vSwitch 网桥 vmbr1
'安装 Open vSwitch'root@host01 ~# apt -y install openvswitch-switchroot@host02 ~# apt -y install openvswitch-switchroot@host03 ~# apt -y install openvswitch-switch
最后别忘记了应用配置


把原来nic5里面的IP地址可以清除掉!
- 三台都清理掉



- 关机拍快照
- 先启动node & backup
- 在启动host
任务7



这个子网最后并没有用到 —> 后面我们用的==静态的==(非DHCP) —> 手动指定172.17.2.xxx

任务八

✅️ 上传两个镜像到node节点的根目录下/root# 用Xshell上传
[root@node-200 ~]# ls /root/ | grep RockyRocky-10.2-x86_64-minimal.isoRocky-10-GenericCloud-Base.latest.x86_64.qcow2上传至 —> CephFS存储
- 在一个节点(hots1)上传后, 别的节点在cephfs也可以看到!

- 上传完毕后, 等一会

任务九
'node节点操作'[root@node-200 ~]# dnf -y install guestfs-tools[root@node-200 ~]# dnf -y install qemu-kvm libvirt virt-install virt-viewer[root@node-200 ~]# for drv in qemu network nodedev nwfilter secret storage interface; do \ systemctl enable --now virt${drv}d.socket; \done[root@node-200 ~]# systemctl daemon-reload[root@node-200 ~]# for drv in qemu network nodedev nwfilter secret storage interface; do \ systemctl enable --now virt${drv}d.socket; \done[root@node-200 ~]# systemctl list-units --type=socket | grep virt virtinterfaced.socket loaded active listening libvirt virtnetworkd.socket loaded active listening libvirt virtnodedevd.socket loaded active listening libvirt virtnwfilterd.socket loaded active listening libvirt virtqemud.socket loaded active listening libvirt virtsecretd.socket loaded active listening libvirt virtstoraged.socket loaded active listening libvirt[root@node-200 ~]# guestfish -i --network -a /root/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2⚠️ 我的镜像在/root目录下[root@node-200 ~]# ls -lhd /rootdr-xr-x---. 15 root root 4.0K Jun 6 10:44 /root✅️ 它的这个目录/root权限有点特殊,我们移动到别的地方![root@node-200 ~]# cp /root/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2 /var/lib/libvirt/images/[root@node-200 ~]# chown root:qemu /var/lib/libvirt/images/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2[root@node-200 ~]# chmod 644 /var/lib/libvirt/images/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2[root@node-200 ~]# guestfish -i --network -a /var/lib/libvirt/images/Rocky-10-GenericCloud-Base.latest.x86_64.qcow2Welcome to guestfishType: ‘help’ for help on commands ‘man’ to read the manual ‘quit’ to quit the shell
Operating system: Rocky Linux 10.2 (Red Quartz)/dev/sda4 mounted on //dev/sda3 mounted on /boot/dev/sda2 mounted on /boot/efi
><fs> command "yum -y install httpd"...........Complete!
><fs> touch /var/www/html/index.html><fs> write /var/www/html/index.html "rocky-index"><fs> cat /var/www/html/index.htmlrocky-index><fs> command "systemctl enable httpd"
><fs> command "systemctl is-enabled httpd"enabled><fs> selinux-relabel /etc/selinux/targeted/contexts/files/file_contexts /><fs> exit- 把这个 qcow2镜像 拷贝出来
- 拷贝到桌面 —> 添加上去
- 这个镜像里面预装了 ==httpd服务==
- ⚠️ 一定不要上传错误
- 拷贝到桌面 —> 添加上去




任务十
使用 Rocky Linux 10 ISO 安装虚拟机 vm1,安装 qemu-guest-agent 后转换为 PVE 模板





- 让虚拟机 CPU 尽量匹配宿主机
- 将 “类型” 改为:
kvm64(最推荐!通用、安全、兼容性强,自动适配宿主机能力)
| 场景 | CPU 类型 |
|---|---|
| 宿主机真实 CPU | AMD Ryzen 5 5600H |
- 内存、网络都默认即可

'host1节点'1)查看配置文件信息root@host01 ~# cat /etc/pve/qemu-server/100.conf✅️ 这里面装的是配置文件boot: order=scsi0;ide2;net0cores: 2cpu: kvm64
2)过滤CPU信息root@host01 ~# cat /etc/pve/qemu-server/100.conf | grep -E '^cpu:'cpu: kvm64
3)启动虚拟机root@host01 ~# qm start 100start failed: QEMU exited with code 1❌️ '最后依旧是起不来'既然 PVE 的原生 cpu: 参数走不通,我们必须绕过 PVE 的解析器
直接使用底层的 args: 参数向 QEMU 传递完整的 CPU 定义
🎯 终极解决方案:纯 args 透传法
✅ 步骤 1:清理配置文件中的 cpu 和 argsroot@host01 ~# vim /etc/pve/qemu-server/100.conf 删除 所有的 cpu: ... 行 删除 所有的 args: ... 行
✅ 步骤 2:添加精准的 QEMU 底层参数'在配置文件中添加以下唯一一行 args'# 整行复制,不要换行args: -cpu host,+invtsc,-pcid,-cmp-legacy,-perfctr-core,-amd-stibp,-xsaveerptr
✅ 步骤 3:重启虚拟机qm stop 100qm start 100kvm: warning: ...xxxkvm: warning: ...xxx'警告⚠️信息不用管'

[C:\~]$ ssh root@172.31.31.159'可以从Xshell中成功登录进来!'Connecting to 172.31.31.159:22...Connection established.=======================Last login: Sat Jun 6 13:46:18 2026
1)安装并启动[root@jiuzhao ~]# dnf -y install qemu-guest-agent[root@jiuzhao ~]# systemctl enable --now qemu-guest-agent'卡住了!'^C[root@jiuzhao ~]# reboot'重启一下!'

手动启动后,再重启一下虚拟机

关机 —> 更多 —> 装换模版 —> 是


任务十一
右上更多 —> 克隆



必须关机做快照
- 快照名称必须得是英文

开机 —> 删除用户

关机 —> 恢复快照 —> 验证用户


任务十二
- 这次是在host02节点上创建虚拟机





内存 & 网络都==默认==就行
修改硬件









- 依旧是Cpu架构选的有问题!
- ==host2==
root@host02 ~# cd /etc/pve/qemu-server/root@host02 qemu-server# ls102.confroot@host02 qemu-server# cdroot@host02 ~# vim /etc/pve/qemu-server/102.conf'把CPU行删除了 --> 行尾加上这个'args: -cpu host,+invtsc,-pcid,-cmp-legacy,-perfctr-core,-amd-stibp,-xsaveerptrroot@host02 ~# qm stop 102root@host02 ~# qm start 102generating cloud-init ISO✅️ 现在就能够启动起来了
- 它和上面 vm1-clone 在同一网段!
- 启动
vm1-clone
- 启动




任务十三
在 PVE 中下载 LXC 容器模板和 OCI 标准容器镜像



引用: docker.m.daocloud.io/busybox标签: latest文件名: busybox_latest


任务十四
基于 LXC 模板创建两个容器 c1 和 c2,部署在不同主机,使用 OVS 网桥 vmbr1,VLAN Tag = 200



Cpu & 内存都默认下一步




静态IP & vlan

========================================'下面这两个都是vmbr0🌐' <-- Rocky Linux 10❗ 没有Vlan========================================1)vm1-clone[root@jiuzhao ~]# nmcli con modify ens18 ipv4.method manual ipv4.addresses 172.17.2.101/24'没法补全只能手打' ✅️ 注意后面/24 <-- 子网掩码⚠️ method √ ⚠️ methon × ⚠️[root@jiuzhao ~]# nmcli con up ens18Connection successfully activated
2)vm2[root@vm2 ~]# nmcli con showNAME UUID TYPE DEVICEWired connection 1 caa7d4xxx ethernet ens18lo ad4c71xxx loopback lo⚠️ 'Wired connection 1' <-- 单引号括起来[root@vm2 ~]# nmcli con modify 'Wired connection 1' ipv4.method manual ipv4.address 172.17.2.102/24[root@vm2 ~]# nmcli con up 'Wired connection 1'Connection successfully activated[root@vm2 ~]# ping -W2 -c2 172.17.2.101PING 172.17.2.101 (172.17.2.101) 56(84) bytes of data.64 bytes from 172.17.2.101: icmp_seq=1 ttl=64 time=1.09 ms64 bytes from 172.17.2.101: icmp_seq=2 ttl=64 time=0.640 ms
--- 172.17.2.101 ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 1000msrtt min/avg/max/mdev = 0.640/0.862/1.085/0.222 ms'✅️ 可以成功ping通'========================================'下面两个容器都是vmbr1🌐' <-- Alpin-3.23❗ Vlan200 ❗========================================3)修改c1网络(静态) --> 172.17.2.103✅️ c1创建在host1中, 'c2创建在host2中'
4)创建c2的同时'指定Vlan200'⚠️ 依旧是Alpine镜像
alpin —> 磁盘(默认下一步) —> … —> ==网络==

DNS —> 确认
- 👆 默认下一步!
c2:~# ip a1: lo: xxx inet 127.0.0.1/8 scope host lo2: eth0@if35: xxx link/ether bc:24:11:9c:c7:ce brd ff:ff:ff:ff:ff:ff inet 172.17.2.104/24 scope global eth0=========================①测试和vm1-clone联通性 ❌️c2:~# ping -W2 -c2 172.17.2.101PING 172.17.2.101 (172.17.2.101): 56 data bytes
--- 172.17.2.101 ping statistics ---2 packets transmitted, 0 packets received, 100% packet loss ❌️=========================②测试和c1的联通性 ✅️c2:~# ping -W2 -c2 172.17.2.103PING 172.17.2.103 (172.17.2.103): 56 data bytes64 bytes from 172.17.2.103: seq=0 ttl=64 time=4.449 ms64 bytes from 172.17.2.103: seq=1 ttl=64 time=0.373 ms
--- 172.17.2.103 ping statistics ---2 packets transmitted, 2 packets received, 0% packet loss ✅️round-trip min/avg/max = 0.373/2.411/4.449 ms任务十五
基于 OCI 容器镜像创建 c3 和 c4,使用 VXLAN 网络(VNI 100),部署在不同节点

- 等一会就行了

========================================'下面两个容器都是mynet🌐' <-- busybox⚠️ Vlan100 ⚠️ c3 & c4========================================root@host01 ~# ip -d link show | grep vxlan100: vxlan_myvnet: xxx vxlan id 100 srcport 0 0 dstport 4789 ttl auto ageing
5)c3创建# 172.17.2.105✅️ 我们这次在host2创建 --> C3busybox --> 172.17.2.105/24(mynet)'无需vlan已经设置过了'
⚠️ 控制台由 console —> shell

~ # ip a1: lo: xxx inet 127.0.0.1/8 scope host lo2: eth0@if44: xxx link/ether bc:24:11:af:fd:83 brd ff:ff:ff:ff:ff:ff inet 172.17.2.105/24 brd 172.17.2.255 scope global eth0===================~ # ping -W2 -c2 172.17.2.1PING 172.17.2.1 (172.17.2.1): 56 data bytes
--- 172.17.2.1 ping statistics ---2 packets transmitted, 0 packets received, 100% packet loss===================~ # ping -W2 -c2 172.17.2.3PING 172.17.2.3 (172.17.2.3): 56 data bytes
--- 172.17.2.3 ping statistics ---2 packets transmitted, 0 packets received, 100% packet loss6)'c4创建'# 172.17.2.106✅️ 我们这次在host3创建 --> C4busybox --> 172.17.2.106/24(mynet)'无需vlan已经设置过了'
⚠️ 控制台由 console —> shell
~ # ip a1: lo: xxx link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo2: eth0@if17: xxx link/ether bc:24:11:c7:f4:1e brd ff:ff:ff:ff:ff:ff inet 172.17.2.106/24 brd 172.17.2.255 scope global eth0===================~ # ping -W2 -c3 172.17.2.101PING 172.17.2.101 (172.17.2.101): 56 data bytes
--- 172.17.2.101 ping statistics ---3 packets transmitted, 0 packets received, 100% packet loss===================~ # ping -W2 -c3 172.17.2.103PING 172.17.2.103 (172.17.2.103): 56 data bytes
--- 172.17.2.103 ping statistics ---3 packets transmitted, 0 packets received, 100% packet loss===================~ # ping -W2 -c3 172.17.2.105PING 172.17.2.105 (172.17.2.105): 56 data bytes64 bytes from 172.17.2.105: seq=0 ttl=64 time=0.522 ms64 bytes from 172.17.2.105: seq=1 ttl=64 time=0.431 ms64 bytes from 172.17.2.105: seq=2 ttl=64 time=0.307 ms
--- 172.17.2.105 ping statistics ---3 packets transmitted, 3 packets received, 0% packet lossround-trip min/avg/max = 0.307/0.420/0.522 ms任务十六
配置 PVE 安全组,控制 vm1 的端口访问(允许 HTTP/SSH,拒绝其他)
vm2(qcow2云镜像) —> 里面有httpd服务
那么这些防火墙的规则就是最终要在vm2上面生效
- 上面的实验我们已经把vm1-clone和vm2放在了同一个网段(172.17.2.xxx/24)
- 为了我用Xshell连接方便,我们给==vm1-clone==再添加一张网卡(桥接)
- 我们在vm1里面验证防火墙是否生效


[C:\~]$ ssh root@172.31.31.91
Connecting to 172.31.31.91:22...Connection established.[root@jiuzhao ~]# hostname -I172.17.2.101 172.31.31.91'两个IP地址!'===================[root@jiuzhao ~]# ping -W2 -c3 172.17.2.102PING 172.17.2.102 (172.17.2.102) 56(84) 字节的数据。64 字节,来自 172.17.2.102: icmp_seq=1 ttl=64 时间=5.16 毫秒64 字节,来自 172.17.2.102: icmp_seq=2 ttl=64 时间=0.688 毫秒64 字节,来自 172.17.2.102: icmp_seq=3 ttl=64 时间=0.598 毫秒
--- 172.17.2.102 ping 统计 ---已发送 3 个包, 已接收 3 个包, 0% packet loss, time 2060msrtt min/avg/max/mdev = 0.598/2.147/5.155/2.127 ms===================[root@jiuzhao ~]# ping -W2 -c3 172.17.2.104PING 172.17.2.104 (172.17.2.104) 56(84) 字节的数据。来自 172.17.2.101 icmp_seq=1 目标主机不可达来自 172.17.2.101 icmp_seq=2 目标主机不可达来自 172.17.2.101 icmp_seq=3 目标主机不可达
--- 172.17.2.104 ping 统计 ---已发送 3 个包, 已接收 0 个包, +3 错误, 100% packet loss, time 2063mspipe 3===================[root@jiuzhao ~]# ping -W2 -c3 172.17.2.106PING 172.17.2.106 (172.17.2.106) 56(84) 字节的数据。来自 172.17.2.101 icmp_seq=1 目标主机不可达来自 172.17.2.101 icmp_seq=2 目标主机不可达来自 172.17.2.101 icmp_seq=3 目标主机不可达
--- 172.17.2.106 ping 统计 ---已发送 3 个包, 已接收 0 个包, +3 错误, 100% packet loss, time 2082ms===================[root@jiuzhao ~]# ssh root@172.17.2.102root@172.17.2.102: Permission denied ❌️[root@jiuzhao ~]# ssh-keygen[root@jiuzhao ~]# ssh-copy-id root@172.17.2.102'因为这个vm2云镜像默认禁止密码登录'# 所以我们没有办法通过这种方式拷贝公钥✅️ 手动查看公钥[root@jiuzhao ~]# cat /root/.ssh/id_ed25519.pubssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEUfzvfEr7ANkqmxNMQnQzjw3stC6WC40B4ubOxRc6Fj 'root@jiuzhao'⚠️ 后面的 'root@..' 不复制ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEUfzvfEr7ANkqmxNMQnQzjw3stC6WC40B4ubOxRc6Fj✅️ 只能手动在vm2中添加公钥
添加完成之后重启一下虚拟机
[root@jiuzhao ~]# ssh root@172.17.2.102@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ WARNING: REMOTE HOST IDENTIFICATIO@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@[root@jiuzhao ~]# > /root/.ssh/known_hosts'再次尝试登录'[root@jiuzhao ~]# ssh root@172.17.2.102Web console: https://vm2:9090/
Last login: Sat Jun 6 11:30:07 2026[root@vm2 ~]# hostname -I172.17.2.102[root@vm2 ~]# curl localhostrocky-index✅️ 里面有httpd服务[root@vm2 ~]# exit'ssh退出vm2后, 依旧可以通过IP访问服务'[root@jiuzhao ~]# curl 172.17.2.102rocky-index✅️ 此时'数据中心'防火墙没有生效
创建安全群组
root@host01 ~# systemctl stop pve-firewallroot@host02 ~# systemctl stop pve-firewallroot@host03 ~# systemctl stop pve-firewall我这里只要把数据中心的防火墙开启, 我的web页面就连不上了! Xshell也连不上了!
- 所以先手动把它们的防火墙关了

- 我们这里先默认拒绝所有
- 目的IP 172.17.2.102

- 启动数据中心的防火墙
- 插入安全组 —> vm2
- 启动vm2的防火墙




root@host02 ~# systemctl start pve-firewall===================[root@jiuzhao ~]# curl 172.17.2.102curl: (7) Failed to connect to 172.17.2.102 port 80===================[root@jiuzhao ~]# ping -W2 -c2 172.17.2.102PING 172.17.2.102 (172.17.2.102) 56(84) 字节的数据。
--- 172.17.2.102 ping 统计 ---已发送 2 个包, 已接收 0 个包, 100% packet loss, time 1007ms===================root@host02 ~# systemctl stop pve-firewall

把80和22端口添加进去!

root@host02 ~# systemctl start pve-firewall'需要手动重启一下ssh服务'===================[root@jiuzhao ~]# ssh root@172.17.2.102Web console: https://vm2:9090/
Last login: Sun Jun 7 03:16:38 2026 from 172.17.2.101[root@vm2 ~]# exitlogoutConnection to 172.17.2.102 closed.===================[root@jiuzhao ~]# curl 172.17.2.102rocky-index===================[root@jiuzhao ~]# ping -W2 -c2 172.17.2.102PING 172.17.2.102 (172.17.2.102) 56(84) 字节的数据。
--- 172.17.2.102 ping 统计 ---已发送 2 个包, 已接收 0 个包, 100% packet loss, time 1001ms===================root@host02 ~# systemctl stop pve-firewallping不通 ---> ICMP协议

root@host02 ~# systemctl start pve-firewall===================[root@jiuzhao ~]# ping -W2 -c2 172.17.2.102PING 172.17.2.102 (172.17.2.102) 56(84) 字节的数据。64 字节,来自 172.17.2.102: icmp_seq=1 ttl=64 时间=1.41 毫秒64 字节,来自 172.17.2.102: icmp_seq=2 ttl=64 时间=0.587 毫秒
--- 172.17.2.102 ping 统计 ---已发送 2 个包, 已接收 2 个包, 0% packet loss, time 1002msrtt min/avg/max/mdev = 0.587/0.998/1.410/0.411 ms✅️ 现在就能ping通了!===================root@host02 ~# systemctl stop pve-firewall任务十七
迁移vm2 —> host3中
- 我们得 ==在线迁移==(热迁移)

‘TASK ERROR: migration problems’ ❌️ 第一次迁移失败,因为CPU标志会阻止热迁移!
那我们关机 —> 试试冷迁移

- 我们开机试一试

我们==新建==C7容器 **热迁移 **
✅️ 新建的目的是为了有共享存储
- 从host1 —> host3
- 在线迁移


- rbd 共享存储池


启动C2 <— host2
- Alpine vmbr1 vlan200
- 172.17.2.104/24
c7:~# ip a1: lo: xxx inet 127.0.0.1/8 scope host lo2: eth0@if19: xxx link/ether bc:24:11:7f:02:60 brd inet 172.17.2.107/24 scope global eth0===================c7:~# ping -W2 -c2 172.17.2.104PING 172.17.2.104 (172.17.2.104): 56 data bytes64 bytes from 172.17.2.104: seq=0 ttl=64 time=2.678 ms64 bytes from 172.17.2.104: seq=1 ttl=64 time=0.306 ms
--- 172.17.2.104 ping statistics ---2 packets transmitted, 2 packets received, 0% packet lossround-trip min/avg/max = 0.306/1.492/2.678 ms


c7:~# ip a2: eth0@if19: xxx link/ether bc:24:11:7f:02:60 brd inet 172.17.2.107/24===================c7:~# ping -W2 -c2 172.17.2.104PING 172.17.2.104 (172.17.2.104): 56 data bytes64 bytes from 172.17.2.104: seq=0 ttl=64 time=2.678 ms✅️ 迁移后依旧可以ping通任务十八
将容器 c7 配置为 HA 模式,模拟节点故障测试自动恢复


手动==暂停(关机)==host3节点


任务十九
在 PVE 集群中配置存储复制,将虚拟机/容器存储定期复制到目标节点
- 只有ZFS才可以复制!
- 在 hsots3 添加一块磁盘



- 重启生效

创建zfs存储(此zfs的命名要跟移动容器所在的zfs的命名一样)


- 我自己做的时候, 添加错了 —> 名字一样才行!
- 有的用的是后面作业的文档📄
把c2 —> 从host2 复制到 hosts3

- 启动c2容器
过 三分钟 —> 复制到host03

- 过一会就有信息了!

任务二十
创建 PVE 到 PBS 的备份任务,执行备份和恢复测试




文章分享
如果这篇文章对你有帮助,欢迎分享给更多人!




