'데이터 엔지니어'로 성장하기

정리하는 걸 좋아하고, 남이 읽으면 더 좋아함

기타/Xen

Xen) Run out of space while coalescing 조치

MightyTedKim 2022. 8. 21. 23:36
728x90
반응형
이 글은 xen server를 사용하시는 분 중에서, 비슷한 장애를 나신 분들을 위해서 작성했어요
결론은 vm 데이터 날렷다는 슬픈 이야기

요약

1. 장애
2. 분석
3. 조치

설명

1. 장애

Xen server는 가상화, vm들 쉽게 관리해주는 툴이에요

https://xcp-ng.org/

XCP-ng - XenServer Based, Community Powered

Grab the latest 8.2 ISO here, then create your bootable USB key with: dd if=xcp-ng-8.2.1.iso of=/dev/sdX bs=8M oflag=direct Then just boot on it! On Windows, you can use Rufus to create the bootable USB stick. SHA256: 93853aba9a71900fe43fd5a0082e2af6ab89ac

xcp-ng.org

개발을 할 때 편해서 좋아요.


평화로운 월요일, 갑자기 VM이 read-only로 바뀌어서 확인해달라는 요청을 받았어요

# vm
$  mount | grep ubuntu--vg
/dev/mapper/ubuntu--vg-ubuntu--lv on / type ext4 (ro,relatime,data=ordered)

$ cat /proc/mounts | grep ubuntu
/dev/mapper/ubuntu--vg-ubuntu--lv / ext4 ro,relatime,data=ordered 0 0

$ lsblk
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0                        11:0    1 1024M  0 rom
xvda                      202:0    0    1T  0 disk
├─xvda1                   202:1    0    1M  0 part
├─xvda2                   202:2    0    1G  0 part /boot
└─xvda3                   202:3    0 1023G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0 1023G  0 lvm  /

역시나 SR 1개가 3.6T/3.6T 를 사용하고 있었어요(3.6T 3.6T 0 100% )
- SR(Storage Repositroy) 물리적 디스크를 VM 생성용으로 설정한 디스크

# xen server
# /dev/mapper/XSLocalEXT--ef4838c3-***  3.6T  3.6T     0 100% /run/sr-mount/ef4
$ df -h
Filesystem                                                                                                 Size  Used Avail Use% Mounted on
devtmpfs                                                                                                   3.6G   40K  3.6G   1% /dev
tmpfs                                                                                                      3.6G  420K  3.6G   1% /dev/shm
tmpfs                                                                                                      3.6G   11M  3.6G   1% /run
tmpfs                                                                                                      3.6G     0  3.6G   0% /sys/fs/cgroup
/dev/sda1                                                                                                   18G   10G  6.8G  60% /
xenstore                                                                                                   3.6G     0  3.6G   0% /var/lib/xenstored
/dev/sda5                                                                                                  3.9G  162M  3.5G   5% /var/log
/dev/sdd1                                                                                                   92G   44G   44G  50% /home
/dev/mapper/XSLocalEXT--c957b1f3--2ef8--a8b7--b692--6581d80bf908-c957b1f3--2ef8--a8b7--b692--6581d80bf908  3.6T  1.8T  1.7T  52% /run/sr-mount/c957b1f3-2ef8-a8b7-b692-6581d80bf908
/dev/mapper/XSLocalEXT--aa9133d8--495b--addb--5412--5145ded09ba0-aa9133d8--495b--addb--5412--5145ded09ba0  3.5T   73G  3.3T   3% /run/sr-mount/aa9133d8-495b-addb-5412-5145ded09ba0
/dev/mapper/XSLocalEXT--e8fb59ca--f5b7--a780--6aa4--bc2db8ce5162-e8fb59ca--f5b7--a780--6aa4--bc2db8ce5162  876G  628G  205G  76% /run/sr-mount/e8fb59ca-f5b7-a780-6aa4-bc2db8ce5162
/dev/mapper/XSLocalEXT--ef4838c3--9ce5--0dde--d607--8ddc5944cb52-ef4838c3--9ce5--0dde--d607--8ddc5944cb52  3.6T  3.6T     0 100% /run/sr-mount/ef4838c3-9ce5-0dde-d607-8ddc5944cb52
tmpfs                                                                                                      726M     0  726M   0% /run/user/0


2. 분석

과거에는 snapshot을 삭제 후 기다리면
coalesce가 진행되서 공간이 확보되었지만
이번에는 snapshot을 삭제 해도 공간이 확보가 되지 않았어요

이 떄까지만 해도 디스크 부족으로 read-only되는 경우는 많으니까, 별 생각이 없엇어요
"coalescing" 도중 에러 발생: No space left on device (Run out of space while coalescing.)

 cat /var/log/SMlog | grep "coalescing" 
Aug 16 10:39:45 xen-02 SM: [13518] FAILED in util.pread: (rc 28) stdout: 'error coalescing: -28
Aug 16 10:39:45 xen-02 SM: [13518] Coalesce failed on SR ef4838c3-9ce5-0dde-d607-8ddc5944cb52: No space left on device (Run out of space while coalescing.)
Aug 16 10:39:54 xen-02 SMGC: [9402] Leaf-coalescing 8f137fd1(1024.000G/2.066M) -> *484f3f38(1024.000G/1.045G)
Aug 16 10:48:34 xen-02 SM: [19804] FAILED in util.pread: (rc 28) stdout: 'error coalescing: -28
Aug 16 10:48:34 xen-02 SM: [19804] Coalesce failed on SR ef4838c3-9ce5-0dde-d607-8ddc5944cb52: No space left on device (Run out of space while coalescing.)

[11:26 xen-gtc-02 log]# cat /var/log/SMlog | grep -i exception
Aug 16 10:29:16 xen-02 SM: [4960] Raising exception [81, Failed to clone VDI [opterr=VDI clone failed error 2]]
Aug 16 10:29:16 xen-02 SM: [4960] ***** generic exception: vdi_snapshot: EXCEPTION <class 'SR.SROSError'>, Failed to clone VDI [opterr=VDI clone failed error 2]
Aug 16 10:29:16 xen-02 SM: [4960] ***** Local EXT3 VHD: EXCEPTION <class 'SR.SROSError'>, Failed to clone VDI [opterr=VDI clone failed error 2]
Aug 16 10:39:45 xen-02 SMGC: [13518] This exception has occured: EXCEPTION <class 'util.CommandException'>, No space left on device
Aug 16 10:39:47 xen-02 SMGC: [9402] coalesce: EXCEPTION <class 'util.SMException'>, Child process exited with error
Aug 16 10:39:47 xen-02 SMGC: [9402]     raise util.SMException("Child process exited with error")
Aug 16 10:48:34 xen-02 SMGC: [19804] This exception has occured: EXCEPTION <class 'util.CommandException'>, No space left on device
Aug 16 10:48:36 xen-02 SMGC: [15327] coalesce: EXCEPTION <class 'util.SMException'>, Child process exited with error
Aug 16 10:48:36 xen-02 SMGC: [15327]     raise util.SMException("Child process exited with error")

아 '디스크가 부족하구나. 확보해주면 되겠지' 라고 생각햇죠

SR이 꽉차면 보통 Snapshot이나 orphaned-disk를 삭제해서 공간을 확보하거든요

이건 예전에 orphaned-disk 삭제해서 문제를 해결한 글이에요
https://mightytedkim.tistory.com/118?category=985729

xen) xcp_ng disk full 해결(orphan disk)

snapshot 마구 찍다가 storage 가 꽉차서, orphan disk를 xoa(UI)에서 삭제해줌 요약 상황 원인 조치 설정 상황 snapshot 마구 찍다가 storage repo가 꽉참 revert to snapshot 했는데 disk를 잡지 못해서 bootin..

mightytedkim.tistory.com


문제는 snapshot을 삭제해도 디스크가 줄거나, orphaned-disk가 생기지 않았어요

Creation date    Name    Content    Action
August 17, 2022, 12:40 PM (yesterday)    No space left on device    Run out of space while coalescing.    
August 16, 2022, 10:39 AM (2 days ago)    No space left on device    Run out of space while coalescing.

으어어어엉 망했다.
30%정도 여유 공간이 있어야 무슨 작업을 할 수 있데요
공간이 없어서 coalesce/revery/export/disk move 등의 작업이 아예 안되요

Coalesce jobs can also fail to run if the SR does not have enough free space. 
Check the problematic SR and make sure it has enough free space,
 generally 30% or more free is recommended depending on VM size. 

You can check if this is the issue by searching SMlog with 
grep -i coales /var/log/SMlog (you may have to look at previous logs such as SMlog.1).

You can check if a coalesce job is currently active by running 
ps axf | grep vhd on the XenServer host and looking for a VHD process in the results 
(one of the resulting processes will be the grep command you just ran, ignore that one).

https://xen-orchestra.com/blog/xenserver-coalesce-detection-in-xen-orchestra/


순환 참조의 대활약ㅋㅋㅋㅋㅋㅋㅋㅋㅋ

coalesce가 되지 않아서, 여유 공간이 부족한데
여유 공간이 없어서 coalesce를 할 수 없는 모순이 발생한다.

문제가 생긴건 알겠고, 어떻게 해결하는데?

"Either do an offline coalesce or increase the SR size to accommodate online coalescing."

SR_BACKEND_FAILURE_44 insufficient space:
The process of taking snapshots requires additional overhead on your SR. 
So you need sufficient room to perform the operation.
For a running VM with a single snapshot to get coalesce 
you need twice the space in case of LVM SR’s (Active VDI + Single Snapshotting VDI).
If we are in short of space in the SR, we get the following error.
Either do an offline coalesce or increase the SR size to accommodate online coalescing.

https://support.citrix.com/article/CTX201296/understanding-garbage-collection-and-coalesce-process-troubleshooting

구글링하다보니 자동으로 coalesce되지 않으니,
[수동으로 coalesce를 하라고 하네요.]
그런데 디스크가 없어서 안되는거라니까?


[다른 방법으로는 SR을 늘리라고 해요.]
지금 당장 서버실가서 디스크를 달고 할 수 있는 상황이 아니었어요

정상적으로 삭제되지 않은
base copy가 너무 많이 남은게 문젠인 것 같아,
검색을 더해봤는데

$ xe vdi-list | grep base
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy
          name-label ( RW): base copy

In rare cases, with third party backup tools we have seen
the Base copy VDI to be corrupted and needs to be repaired to complete the coalesce.

운나빠서 문제가 생겼다고 하는 것 같아요..
아래 명령대로 실행했는데, 여전히 디스크가 부족해서 그런지 묵묵 부답이더라고요.

In rare cases, with third party backup tools we have seen the Base copy VDI to be corrupted and needs to be repaired to complete the coalesce. 
 Remember that base copy is always set to read-only mode and the LV is in offline mode.  To repair the base copy VDI corruption, change the permission and bring online, repair, and revert back the changes.  Here are the 

steps:
1. Check if the volume is active (#lvscan |grep <vhd-uuid>
2. Check if the permission is read-write (#lvdisplay |grep <vhd-uuid> -A10
3. If required activate the VDI (#lvchange –ay /dev/VG_XenStorage-<SR-UUID>/VHD-<VDI-UUID>   
(in case of ext/nfs the path changes ie /var/run/sr-mount/sr-uuid/vhd-uuid)
4. If required set the permission to read-write (#lvchange –p rw /dev/VG_XenStorage-<SR-UUID>/VHD-<VDI-UUID>   
(in case of ext/nfs the path changes ie /var/run/sr-mount/sr-uuid/vhd-uuid)
5. Repair the VHD (#vhd-util repair –n /dev/VG_XenStorage-<SR-UUID>/VHD-<VDI-UUID>
6. Return the volume to original state (lvchange –an <path to vdi> and lvchange –p r <path to vdi>

After completing, rescan the SR and let the GC do the coalesce. 

조치

그냥 ceph용 OSD hdd 2개를 날렸어요

HDD-01(SR)

  • K8s clusterA용 CEPH OSD 1TB -> 삭제
  • K8s clusterB용 CEPH OSD 1TB -> 삭제
  • 기타 VM용 1TB

다행히 ceph는 osd 날라가도 데이터가 사라지지는 않으니까...

OSD를 삭제하고 rescan을 하면, coalesce가 도는데
아래 명령어로 확인할 수 있어요. 몇시간을 기다려야해요. 아주 천천히 정리하거든요

ps axf | grep vhd
 4406 pts/13   S+     0:00                      \_ grep --color=auto vhd
 1342 ?        D      0:24      \_ /usr/bin/vhd-util coalesce --debug -n /var/run/sr-mount/e8fb59ca-f5b7-a780-6aa4-bc2db8ce5162/36dc3f54-dc8b-45ea-9a53-f1f22d3ec00b.vhd
17082 ?        D      3:17      \_ /usr/bin/vhd-util coalesce --debug -n /var/run/sr-mount/c957b1f3-2ef8-a8b7-b692-6581d80bf908/e1181012-3d3b-4bfc-a7e9-b5471e1373d3.vhd


하드 날린거는 날린거고, 왜 이런 문제가 발생했을까 생각해봣어요
1tb hdd를 6개월 간 snapshot을 찍다가 보니, 문제가 생긴 것 같아요

snapshot을 뜨면 base copy가 생겨요

계속 chain식을 snapshot이 생기면 basecopy를 뜨고
snapshot을 지우게 되면 알아서 basecopy를 정리한다고 해요

그런데 이 일반적인 base copy가 제대로 지워지지 않은게 문제의 원인이었고
이건 버그라서, 보통 디스크를 날려버린다고 하더라고요
유료는 따로 관리를 해주지만 대부분 오픈소스를 사내 테스트용으로 사용하니까요

사고 방지를 위해서 snapshot 보관 주기를 대폭 줄이고,
VM들을 하나씩 보고 과도하게 디스크를 요청한 분들에게 주의를 주려고 해요
1TB 요청했는데, 28G가 사용하는 분도 있더라고요...
EC2였으면 이렇게 쉽게 요청했을까 싶은 생각이 드네요.
온프렘이라고 공짜가 아닌데ㅜㅜ

이거 때문에 지난주 많이 쫄려서 정리했는데
너무 두서 없이 써내려간게 아니가 싶네요 ㅋㅋ

참고
https://discussions.citrix.com/topic/411898-can-i-delete-two-base-copy-in-tree/
https://support.citrix.com/article/CTX201296/understanding-garbage-collection-and-coalesce-process-troubleshooting
https://xcp-ng.org/forum/topic/1290/base-copy-vdi-not-merged
https://xcp-ng.org/forum/topic/3894/vm-space-used-in-local-storage-and-base-copies/2
https://xen-orchestra.com/blog/xenserver-coalesce-detection-in-xen-orchestra/

728x90
반응형

'기타 > Xen' 카테고리의 다른 글

xen) xcp-ng 설치  (0) 2022.07.10
xen) xcp_ng disk full 해결(orphan disk)  (0) 2022.06.02
xen) vg not available 해결_reboot,vgchange -ay,k8s  (0) 2022.03.29