家里有一台PVE主机打算换下来休息了,但上面还跑着2台要用的VM。PVE 7.3引入了迁移虚拟机的命令行工具,于是尝试使用qm来更方便的迁移虚拟机。

注意!源主机PVE版本需要高于7.3,否则不具备该功能

在目标主机上创建API令牌

在文件夹视图下找到“数据中心>权限>API令牌”,然后创建一个token,记得复制保留secret;然后在“数据中心>权限”处为刚刚创建的API令牌授权,需要给/路径赋予Administrator权限才能成功完成迁移。

若不授权的话,则执行迁移命令时会首先报remote: storage '<storage_name>' does not exist!,如果出现该问题的话首先检查是否忘记授权。

查看目标主机fingerprint

执行pvenode cert info,查看pve-ssl.pem的fingerprint并复制保留。

在源主机上执行迁移命令

执行命令:

qm remote-migrate <source_vm_id> <target_vm_id> apitoken='Authorization: PVEAPIToken=root@pam!<token_name>=<token_secret>,fingerprint=<target_host_fingerprint>',host=<target_host>,port=<target_host_port> --target-bridge <target_bridge> --target-storage <target_storage>

静候即可。完成迁移后若需要解锁源VM,则运行qm unlock <source_vm_id>

参考