proxmox-admin
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseProxmox VE Administration
Proxmox VE 管理
Overview
概述
Proxmox VE is a server virtualization platform built on Debian. It manages KVM virtual machines and LXC containers through a web UI or CLI tools. This skill covers CLI-based administration using (VMs), (containers), and supporting utilities.
qmpctProxmox VE是基于Debian构建的服务器虚拟化平台,可通过Web UI或CLI工具管理KVM虚拟机和LXC容器。本技能涵盖使用(虚拟机)、(容器)及配套工具的CLI管理方式。
qmpctWhen to Use
适用场景
- Creating, configuring, or managing KVM virtual machines
- Spawning and administering LXC containers
- Managing Proxmox storage, networking, or clustering
- Automating VM/container provisioning via scripts
- Troubleshooting Proxmox host or guest issues
Not for: Web UI-only workflows (use the CLI equivalents below).
- 创建、配置或管理KVM虚拟机
- 创建和管理LXC容器
- 管理Proxmox的存储、网络或集群
- 通过脚本自动化虚拟机/容器置备
- 排查Proxmox主机或客户机问题
不适用: 仅使用Web UI的工作流(请使用下方对应的CLI操作)。
Quick Reference
速查参考
| Tool | Purpose |
|---|---|
| Manage KVM virtual machines |
| Manage LXC containers |
| Manage storage |
| Manage cluster |
| Manage appliance/template downloads |
| Access the Proxmox API from the shell |
| Benchmark host performance |
| 工具 | 用途 |
|---|---|
| 管理KVM虚拟机 |
| 管理LXC容器 |
| 管理存储 |
| 管理集群 |
| 管理应用/模板下载 |
| 从Shell访问Proxmox API |
| 基准测试主机性能 |
VM Management with qm
qm使用qm
管理虚拟机
qmCreating a VM
创建虚拟机
bash
undefinedbash
undefinedCreate a VM with ID 100
创建ID为100的虚拟机
qm create 100 --name my-vm --memory 2048 --cores 2 --sockets 1
--net0 virtio,bridge=vmbr0 --ostype l26
--net0 virtio,bridge=vmbr0 --ostype l26
qm create 100 --name my-vm --memory 2048 --cores 2 --sockets 1
--net0 virtio,bridge=vmbr0 --ostype l26
--net0 virtio,bridge=vmbr0 --ostype l26
Create with SCSI disk on local-lvm storage (32GB)
在local-lvm存储上创建带SCSI磁盘的虚拟机(32GB)
qm create 100 --name my-vm --memory 4096 --cores 4
--scsi0 local-lvm:32 --scsihw virtio-scsi-pci
--net0 virtio,bridge=vmbr0 --ostype l26
--scsi0 local-lvm:32 --scsihw virtio-scsi-pci
--net0 virtio,bridge=vmbr0 --ostype l26
qm create 100 --name my-vm --memory 4096 --cores 4
--scsi0 local-lvm:32 --scsihw virtio-scsi-pci
--net0 virtio,bridge=vmbr0 --ostype l26
--scsi0 local-lvm:32 --scsihw virtio-scsi-pci
--net0 virtio,bridge=vmbr0 --ostype l26
Attach an ISO for installation
挂载ISO镜像用于安装
qm set 100 --cdrom local:iso/ubuntu-22.04-server.iso --boot order=ide2
undefinedqm set 100 --cdrom local:iso/ubuntu-22.04-server.iso --boot order=ide2
undefinedVM Lifecycle
虚拟机生命周期管理
| Command | Purpose |
|---|---|
| Start a VM |
| Graceful ACPI shutdown |
| Force stop (like pulling power) |
| Reboot a VM |
| Hard reset |
| Suspend to RAM |
| Resume from suspend |
| Delete VM and its disks |
| Delete VM, disks, and all related jobs |
| 命令 | 用途 |
|---|---|
| 启动虚拟机 |
| 优雅ACPI关机 |
| 强制停止(类似拔电源) |
| 重启虚拟机 |
| 硬重置 |
| 挂起到内存 |
| 从挂起恢复 |
| 删除虚拟机及其磁盘 |
| 删除虚拟机、磁盘及所有相关任务 |
VM Configuration
虚拟机配置
bash
undefinedbash
undefinedShow current config
查看当前配置
qm config 100
qm config 100
Modify hardware
修改硬件配置
qm set 100 --memory 8192
qm set 100 --cores 4
qm set 100 --balloon 2048 # dynamic memory (min)
qm set 100 --cpu cputype=host # pass through host CPU features
qm set 100 --machine q35 # use Q35 chipset (for PCIe passthrough)
qm set 100 --memory 8192
qm set 100 --cores 4
qm set 100 --balloon 2048 # 动态内存(最小值)
qm set 100 --cpu cputype=host # 透传宿主机CPU特性
qm set 100 --machine q35 # 使用Q35芯片组(用于PCIe透传)
Add/resize disks
添加/扩容磁盘
qm set 100 --scsi1 local-lvm:50 # add 50GB disk
qm disk resize 100 scsi0 +20G # grow existing disk by 20GB
qm set 100 --scsi1 local-lvm:50 # 添加50GB磁盘
qm disk resize 100 scsi0 +20G # 现有磁盘扩容20GB
Networking
网络配置
qm set 100 --net0 virtio,bridge=vmbr0,tag=10 # VLAN tagged
qm set 100 --net1 virtio,bridge=vmbr1 # second NIC
qm set 100 --net0 virtio,bridge=vmbr0,tag=10 # VLAN标记
qm set 100 --net1 virtio,bridge=vmbr1 # 第二块网卡
Cloud-init (for automated provisioning)
Cloud-init(自动化置备)
qm set 100 --ide2 local-lvm:cloudinit
qm set 100 --ciuser admin --cipassword 'secret'
qm set 100 --ipconfig0 ip=10.0.0.50/24,gw=10.0.0.1
qm set 100 --sshkeys ~/.ssh/authorized_keys
qm set 100 --boot order=scsi0
qm set 100 --ide2 local-lvm:cloudinit
qm set 100 --ciuser admin --cipassword 'secret'
qm set 100 --ipconfig0 ip=10.0.0.50/24,gw=10.0.0.1
qm set 100 --sshkeys ~/.ssh/authorized_keys
qm set 100 --boot order=scsi0
EFI / UEFI boot
EFI / UEFI启动
qm set 100 --bios ovmf --efidisk0 local-lvm:1,efitype=4m,pre-enrolled-keys=1
qm set 100 --bios ovmf --efidisk0 local-lvm:1,efitype=4m,pre-enrolled-keys=1
Serial console (headless)
串行控制台(无图形界面)
qm set 100 --serial0 socket --vga serial0
qm set 100 --serial0 socket --vga serial0
PCI passthrough (GPU, NIC, etc.)
PCI透传(GPU、网卡等)
qm set 100 --hostpci0 0000:01:00.0,pcie=1
undefinedqm set 100 --hostpci0 0000:01:00.0,pcie=1
undefinedSnapshots and Cloning
快照与克隆
bash
undefinedbash
undefinedCreate a snapshot
创建快照
qm snapshot 100 before-upgrade --description "Before kernel upgrade"
qm snapshot 100 before-upgrade --description "Before kernel upgrade"
List snapshots
列出快照
qm listsnapshot 100
qm listsnapshot 100
Rollback to snapshot
回滚到快照
qm rollback 100 before-upgrade
qm rollback 100 before-upgrade
Delete a snapshot
删除快照
qm delsnapshot 100 before-upgrade
qm delsnapshot 100 before-upgrade
Clone a VM (full copy)
克隆虚拟机(完整复制)
qm clone 100 101 --name cloned-vm --full
qm clone 100 101 --name cloned-vm --full
Clone as linked clone (shares base disk, faster)
克隆为链接克隆(共享基础磁盘,速度更快)
qm clone 100 101 --name linked-vm
undefinedqm clone 100 101 --name linked-vm
undefinedTemplates
模板管理
bash
undefinedbash
undefinedConvert VM to template (irreversible)
将虚拟机转换为模板(不可逆)
qm template 100
qm template 100
Create VM from template (linked clone)
从模板创建虚拟机(链接克隆)
qm clone 100 200 --name from-template
qm clone 100 200 --name from-template
Create VM from template (full clone)
从模板创建虚拟机(完整克隆)
qm clone 100 200 --name from-template --full
undefinedqm clone 100 200 --name from-template --full
undefinedMigration
迁移
bash
undefinedbash
undefinedOnline migration to another node
在线迁移到其他节点
qm migrate 100 node2 --online
qm migrate 100 node2 --online
Offline migration
离线迁移
qm migrate 100 node2
undefinedqm migrate 100 node2
undefinedMonitoring
监控
bash
undefinedbash
undefinedVM status
虚拟机状态
qm status 100
qm status 100
List all VMs
列出所有虚拟机
qm list
qm list
Show running processes/agent info
查看运行进程/代理信息
qm agent 100 ping
qm agent 100 get-osinfo
qm agent 100 ping
qm agent 100 get-osinfo
Monitor interface (QEMU monitor)
监控接口(QEMU监视器)
qm monitor 100
undefinedqm monitor 100
undefinedContainer Management with pct
pct使用pct
管理容器
pctCreating a Container
创建容器
bash
undefinedbash
undefinedDownload a template first
先下载模板
pveam update
pveam available --section system
pveam download local debian-12-standard_12.2-1_amd64.tar.zst
pveam update
pveam available --section system
pveam download local debian-12-standard_12.2-1_amd64.tar.zst
Create container with ID 200
创建ID为200的容器
pct create 200 local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst
--hostname my-ct --memory 1024 --cores 2
--rootfs local-lvm:8
--net0 name=eth0,bridge=vmbr0,ip=dhcp
--password 'secret' --unprivileged 1
--hostname my-ct --memory 1024 --cores 2
--rootfs local-lvm:8
--net0 name=eth0,bridge=vmbr0,ip=dhcp
--password 'secret' --unprivileged 1
pct create 200 local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst
--hostname my-ct --memory 1024 --cores 2
--rootfs local-lvm:8
--net0 name=eth0,bridge=vmbr0,ip=dhcp
--password 'secret' --unprivileged 1
--hostname my-ct --memory 1024 --cores 2
--rootfs local-lvm:8
--net0 name=eth0,bridge=vmbr0,ip=dhcp
--password 'secret' --unprivileged 1
Create with static IP
创建带静态IP的容器
pct create 201 local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst
--hostname web-ct --memory 2048 --cores 2
--rootfs local-lvm:16
--net0 name=eth0,bridge=vmbr0,ip=10.0.0.51/24,gw=10.0.0.1
--nameserver 1.1.1.1 --unprivileged 1
--hostname web-ct --memory 2048 --cores 2
--rootfs local-lvm:16
--net0 name=eth0,bridge=vmbr0,ip=10.0.0.51/24,gw=10.0.0.1
--nameserver 1.1.1.1 --unprivileged 1
undefinedpct create 201 local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst
--hostname web-ct --memory 2048 --cores 2
--rootfs local-lvm:16
--net0 name=eth0,bridge=vmbr0,ip=10.0.0.51/24,gw=10.0.0.1
--nameserver 1.1.1.1 --unprivileged 1
--hostname web-ct --memory 2048 --cores 2
--rootfs local-lvm:16
--net0 name=eth0,bridge=vmbr0,ip=10.0.0.51/24,gw=10.0.0.1
--nameserver 1.1.1.1 --unprivileged 1
undefinedContainer Lifecycle
容器生命周期管理
| Command | Purpose |
|---|---|
| Start container |
| Graceful shutdown |
| Force stop |
| Reboot container |
| Delete container and its volumes |
| Open a shell inside the container |
| Run a command inside the container |
| Attach to container console |
| 命令 | 用途 |
|---|---|
| 启动容器 |
| 优雅关机 |
| 强制停止 |
| 重启容器 |
| 删除容器及其卷 |
| 在容器内打开Shell |
| 在容器内执行命令 |
| 连接到容器控制台 |
Container Configuration
容器配置
bash
undefinedbash
undefinedShow config
查看配置
pct config 200
pct config 200
Modify resources
修改资源配置
pct set 200 --memory 4096
pct set 200 --cores 4
pct set 200 --swap 1024
pct set 200 --memory 4096
pct set 200 --cores 4
pct set 200 --swap 1024
Add mount point (bind mount from host)
添加挂载点(从宿主机绑定挂载)
pct set 200 --mp0 /mnt/data,mp=/data
pct set 200 --mp0 /mnt/data,mp=/data
Add additional storage volume
添加额外存储卷
pct set 200 --mp1 local-lvm:50,mp=/var/lib/data
pct set 200 --mp1 local-lvm:50,mp=/var/lib/data
Networking
网络配置
pct set 200 --net0 name=eth0,bridge=vmbr0,ip=10.0.0.60/24,gw=10.0.0.1
pct set 200 --net1 name=eth1,bridge=vmbr1,ip=dhcp
pct set 200 --net0 name=eth0,bridge=vmbr0,ip=10.0.0.60/24,gw=10.0.0.1
pct set 200 --net1 name=eth1,bridge=vmbr1,ip=dhcp
Features (nesting, FUSE, NFS)
特性配置(嵌套、FUSE、NFS)
pct set 200 --features nesting=1
pct set 200 --features nesting=1,fuse=1,mount=nfs
pct set 200 --features nesting=1
pct set 200 --features nesting=1,fuse=1,mount=nfs
DNS
DNS配置
pct set 200 --nameserver "1.1.1.1 8.8.8.8" --searchdomain example.com
pct set 200 --nameserver "1.1.1.1 8.8.8.8" --searchdomain example.com
Start on boot
设置开机自启
pct set 200 --onboot 1 --startup order=1,up=30
undefinedpct set 200 --onboot 1 --startup order=1,up=30
undefinedContainer Snapshots and Cloning
容器快照与克隆
bash
undefinedbash
undefinedSnapshot
创建快照
pct snapshot 200 clean-install
pct snapshot 200 clean-install
Rollback
回滚快照
pct rollback 200 clean-install
pct rollback 200 clean-install
Clone
克隆容器
pct clone 200 201 --hostname cloned-ct --full
undefinedpct clone 200 201 --hostname cloned-ct --full
undefinedStorage Management
存储管理
bash
undefinedbash
undefinedList storage pools
列出存储池
pvesm status
pvesm status
List content of a storage
列出存储内容
pvesm list local
pvesm list local-lvm
pvesm list local
pvesm list local-lvm
Add storage (examples)
添加存储(示例)
pvesm add dir my-backup --path /mnt/backup --content backup
pvesm add nfs nfs-share --server 10.0.0.5 --export /exports/pve --content images,vztmpl
pvesm add lvm my-lvm --vgname my-vg --content rootdir,images
pvesm add zfspool my-zfs --pool rpool/data --content rootdir,images
pvesm add dir my-backup --path /mnt/backup --content backup
pvesm add nfs nfs-share --server 10.0.0.5 --export /exports/pve --content images,vztmpl
pvesm add lvm my-lvm --vgname my-vg --content rootdir,images
pvesm add zfspool my-zfs --pool rpool/data --content rootdir,images
Remove storage
删除存储
pvesm remove my-backup
pvesm remove my-backup
Download ISO
下载ISO镜像
wget -P /var/lib/vz/template/iso/ https://example.com/image.iso
undefinedwget -P /var/lib/vz/template/iso/ https://example.com/image.iso
undefinedNetworking
网络管理
bash
undefinedbash
undefinedList network interfaces
列出网络接口
cat /etc/network/interfaces
cat /etc/network/interfaces
Common bridge configuration (in /etc/network/interfaces)
常见网桥配置(在/etc/network/interfaces中)
auto vmbr0
auto vmbr0
iface vmbr0 inet static
iface vmbr0 inet static
address 10.0.0.1/24
address 10.0.0.1/24
bridge-ports eno1
bridge-ports eno1
bridge-stp off
bridge-stp off
bridge-fd 0
bridge-fd 0
Apply network changes
应用网络变更
ifreload -a
undefinedifreload -a
undefinedCluster Management
集群管理
bash
undefinedbash
undefinedCreate a new cluster
创建新集群
pvecm create my-cluster
pvecm create my-cluster
Join an existing cluster
加入现有集群
pvecm add 10.0.0.1
pvecm add 10.0.0.1
Show cluster status
查看集群状态
pvecm status
pvecm status
List cluster nodes
列出集群节点
pvecm nodes
pvecm nodes
Remove a node (run from a remaining node)
删除节点(在剩余节点上执行)
pvecm delnode nodename
pvecm delnode nodename
Check quorum
检查法定人数
pvecm expected 1 # force quorum (dangerous, single-node recovery only)
undefinedpvecm expected 1 # 强制法定人数(仅单节点恢复时使用,有风险)
undefinedFirewall
防火墙
bash
undefinedbash
undefinedEnable/disable firewall at datacenter level
在数据中心级别启用/禁用防火墙
pve-firewall start
pve-firewall stop
pve-firewall status
pve-firewall start
pve-firewall stop
pve-firewall status
Manage rules via config files
通过配置文件管理规则
Datacenter: /etc/pve/firewall/cluster.fw
数据中心:/etc/pve/firewall/cluster.fw
Node: /etc/pve/nodes/<node>/host.fw
节点: /etc/pve/nodes/<node>/host.fw
VM/CT: /etc/pve/firewall/<vmid>.fw
虚拟机/容器: /etc/pve/firewall/<vmid>.fw
undefinedundefinedBackup and Restore
备份与恢复
bash
undefinedbash
undefinedBackup a VM
备份虚拟机
vzdump 100 --storage local --mode snapshot --compress zstd
vzdump 100 --storage local --mode snapshot --compress zstd
Backup a container
备份容器
vzdump 200 --storage local --mode stop --compress zstd
vzdump 200 --storage local --mode stop --compress zstd
Backup all guests
备份所有客户机
vzdump --all --storage local --mode snapshot --compress zstd --mailto admin@example.com
vzdump --all --storage local --mode snapshot --compress zstd --mailto admin@example.com
Restore a VM
恢复虚拟机
qmrestore /var/lib/vz/dump/vzdump-qemu-100-*.vma.zst 100
qmrestore /var/lib/vz/dump/vzdump-qemu-100-*.vma.zst 100
Restore a container
恢复容器
pct restore 200 /var/lib/vz/dump/vzdump-lxc-200-*.tar.zst
pct restore 200 /var/lib/vz/dump/vzdump-lxc-200-*.tar.zst
Restore to different storage
恢复到不同存储
qmrestore /var/lib/vz/dump/vzdump-qemu-100-*.vma.zst 100 --storage local-lvm
undefinedqmrestore /var/lib/vz/dump/vzdump-qemu-100-*.vma.zst 100 --storage local-lvm
undefinedCommon Provisioning Patterns
常见置备模式
Cloud-Init VM from Template
从模板创建Cloud-init虚拟机
bash
undefinedbash
undefined1. Create base VM and install OS, then convert to template
1. 创建基础虚拟机并安装系统,然后转换为模板
qm template 9000
qm template 9000
2. Clone and customize with cloud-init
2. 克隆并通过Cloud-init自定义
qm clone 9000 110 --name web-server --full
qm set 110 --ciuser deploy --sshkeys ~/.ssh/authorized_keys
qm set 110 --ipconfig0 ip=10.0.0.110/24,gw=10.0.0.1
qm set 110 --nameserver 1.1.1.1
qm start 110
undefinedqm clone 9000 110 --name web-server --full
qm set 110 --ciuser deploy --sshkeys ~/.ssh/authorized_keys
qm set 110 --ipconfig0 ip=10.0.0.110/24,gw=10.0.0.1
qm set 110 --nameserver 1.1.1.1
qm start 110
undefinedBatch Create Containers
批量创建容器
bash
for i in $(seq 1 5); do
CTID=$((300 + i))
pct create $CTID local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst \
--hostname "worker-${i}" --memory 1024 --cores 2 \
--rootfs local-lvm:8 \
--net0 name=eth0,bridge=vmbr0,ip=10.0.0.$((60 + i))/24,gw=10.0.0.1 \
--unprivileged 1 --start 1
donebash
for i in $(seq 1 5); do
CTID=$((300 + i))
pct create $CTID local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst \
--hostname "worker-${i}" --memory 1024 --cores 2 \
--rootfs local-lvm:8 \
--net0 name=eth0,bridge=vmbr0,ip=10.0.0.$((60 + i))/24,gw=10.0.0.1 \
--unprivileged 1 --start 1
doneImport Disk Image (e.g., cloud image)
导入磁盘镜像(如云镜像)
bash
undefinedbash
undefinedDownload a cloud image
下载云镜像
Import to a VM
导入到虚拟机
qm importdisk 100 jammy-server-cloudimg-amd64.img local-lvm
qm importdisk 100 jammy-server-cloudimg-amd64.img local-lvm
Attach the imported disk
挂载导入的磁盘
qm set 100 --scsi0 local-lvm:vm-100-disk-0
qm set 100 --boot order=scsi0
undefinedqm set 100 --scsi0 local-lvm:vm-100-disk-0
qm set 100 --boot order=scsi0
undefinedTroubleshooting
故障排查
| Problem | Solution |
|---|---|
| VM won't start | Check |
| "TASK ERROR: can't lock file" | |
| Container has no network | Check bridge exists: |
| Disk full on storage | |
| Cluster quorum lost | |
| Migration fails | Ensure same CPU type or use |
| Backup fails with lock error | |
| Slow disk I/O in VM | Use |
| Guest agent not responding | Install |
| 问题 | 解决方案 |
|---|---|
| 虚拟机无法启动 | 检查 |
| "TASK ERROR: can't lock file" | 删除 |
| 容器无网络 | 检查网桥是否存在: |
| 存储磁盘已满 | 使用 |
| 集群丢失法定人数 | 在存活节点执行 |
| 迁移失败 | 确保CPU类型一致,或使用 |
| 备份因锁错误失败 | 执行 |
| 虚拟机磁盘I/O缓慢 | 使用 |
| 客户机代理无响应 | 在虚拟机中安装 |
Useful Paths
常用路径
| Path | Contents |
|---|---|
| Cluster-wide config (pmxcfs) |
| VM configuration files |
| Container configuration files |
| Storage definitions |
| Per-node configuration |
| Default local storage root |
| ISO images |
| Container templates |
| Backup files |
| Task logs |
| 路径 | 内容 |
|---|---|
| 集群范围配置(pmxcfs) |
| 虚拟机配置文件 |
| 容器配置文件 |
| 存储定义 |
| 节点专属配置 |
| 默认本地存储根目录 |
| ISO镜像文件 |
| 容器模板 |
| 备份文件 |
| 任务日志 |