proxmox서버를 사용중에 있으나, memory나 cpu의 가용성을 확보하기 위해
안쓰는 VM들은 Hibernate 기능으로 내려두고자 하는데 Hibernate 에 대해서 알아봐야겠다.
Ref :: https://pve.proxmox.com/pve-docs/pve-admin-guide.html#qm_hibernate
proxmox에서 설명하는 Hibernate는 메모리의 현재 내용이 디스크에 저장되고 VM이 중지하는 기능입니다.
명령어는 다음과 같다.
# qm suspend ID --todisk
그러면 테스트를 해보자.
$ free -mh
total used free shared buff/cache available
Mem: 566Gi 383Gi 114Gi 3.2Gi 68Gi 175Gi
Swap: 8.0Gi 135Mi 7.9Gi
현재 proxmox에서 사용하는 자원현황은 위와 같다.
$ sudo qm list|grep running
807 dev-01 running 131072 250.00 2126220
해당 vm을 Hibernate 해보자.
$ sudo qm suspend 807 --todisk
Hibernate에 성공하면 dev vm이 사용한 메모리 만큼 줄어들게 된다.
## AS
$ free -mh
total used free shared buff/cache available
Mem: 566Gi 383Gi 114Gi 3.2Gi 68Gi 175Gi
Swap: 8.0Gi 135Mi 7.9Gi
## TO-BE
$ free -mh
total used free shared buff/cache available
Mem: 566Gi 255Gi 242Gi 3.2Gi 68Gi 303Gi
Swap: 8.0Gi 118Mi 7.9Gi
hibernate에 성공하면 vm의 상태는 아래와 같이 변경이된다.
$ sudo qm list |grep goe
807 dev-01 stopped 131072 250.00 0
다만 Hibernate 해제 시 아래와 같이 timeout이 발생하게 된다.
$ sudo qm resume 807
Resuming suspended VM
activating and using 'vm-807-state-suspend-2025-03-04' as vmstate
auth_supported=cephx:id=admin:keyring=/etc/pve/priv/ceph/rbd.keyring'' failed: got timeout
이유는 다음과 같다.
$ sudo vi /usr/share/perl5/PVE/QemuServer/Helpers.pm
...
sub config_aware_timeout {
my ($config, $is_suspended) = @_;
my $memory = $config->{memory};
my $timeout = 30;
# Based on user reported startup time for vm with 512GiB @ 4-5 minutes
if (defined($memory) && $memory > 30720) {
$timeout = int($memory/1024);
}
if ($is_suspended && $timeout < 300) {
- $timeout = 300;
+ $timeout = 600;
}
if ($config->{hugepages} && $timeout < 150) {
$timeout = 150;
}
return $timeout;
}
Timeout값이 300초로 고정되어있어 발생한 문제로 위와 같이 5분 timeout에서 10분 timeout으로 변경하고 아래 2개의 daemon을 재기동해준다.
$ sudo systemctl restart pveproxy
$ sudo systemctl restart pvedaemon
2개의 daemon을 재기동하게되면 발생하는 서비스 이상도는
proxmox에서 vm 실행 중지 등의 명령이 재기동 동안 동작을 안하는것 뿐이다.
변경을 완료 후 다시 resume을 하게 되면,
$ sudo qm resume 807
Resuming suspended VM
activating and using 'rbd:vm-807-state-suspend-2025-03-04' as vmstate
Resumed VM, removing state
Removing image: 1% complete...
Removing image: 2% complete...
Removing image: 3% complete...
Removing image: 4% complete...
...
Removing image: 98% complete...
Removing image: 99% complete...
Removing image: 100% complete...done.
정상적으로 running으로 변경되며, proxmox가 사용하는 메모리가 hibernate 전과 동일해진다.
## hibernate 전
$ free -mh
total used free shared buff/cache available
Mem: 566Gi 383Gi 114Gi 3.2Gi 68Gi 175Gi
Swap: 8.0Gi 135Mi 7.9Gi
## hiberneate 후
$ free -mh
total used free shared buff/cache available
Mem: 566Gi 255Gi 242Gi 3.2Gi 68Gi 303Gi
Swap: 8.0Gi 118Mi 7.9Gi
## vm resume
$ free -mh
total used free shared buff/cache available
Mem: 566Gi 383Gi 115Gi 3.2Gi 67Gi 176Gi
Swap: 8.0Gi 116Mi 7.9Gi
vm은 shutdown과 다르게 서비스 상태등의 이슈는 없다.