本文介绍如何通过 SSH 登录 Proxmox VE (PVE) 并使用 pvesh 命令来管理(启动、停止)虚拟机。

常用命令

通过 SSH 登录 PVE 主机后,可以使用 pvesh 工具进行操作。

1. 查看所有节点资源

1
pvesh get /cluster/resources

2. 获取虚拟机当前状态

1
2
# 格式: pvesh get /nodes/{node}/qemu/{vmid}/status/current
pvesh get /nodes/pve/qemu/101/status/current

3. 启动虚拟机

1
2
# 格式: pvesh create /nodes/{node}/qemu/{vmid}/status/start
pvesh create /nodes/pve/qemu/141/status/start

4. 停止虚拟机 (关机)

1
2
# 格式: pvesh create /nodes/{node}/qemu/{vmid}/status/stop
pvesh create /nodes/pve/qemu/141/status/stop

参数说明:

  • {node}: PVE 节点名称(例如 pve)。
  • {vmid}: 虚拟机的 ID(例如 100, 101)。

操作示例

假设节点名称为 pve,虚拟机 ID 为 141

1
2
3
4
5
6
7
8
# 查看资源列表
pvesh get /cluster/resources

# 启动
pvesh create /nodes/pve/qemu/141/status/start

# 关机
pvesh create /nodes/pve/qemu/141/status/stop