Category Archives: Tip

tip, trubleshooting
도움이 되는 팁 또는 문제해결을 다룹니다.

[Tip | Docker] 컨테이너 자원할당 변경

Docker 사용시 컨테이너별 자원 할당법을 정리한다.

테스트서버 : Ubuntu22.04
작성일 : 2023-04-26

1> 할당된 자원 및 상태 확인

# 프로세스 전체 확인
docker ps -a
# 실행되고 있는 자원 확인
docker stats

2> 메모리 제한 변경

# memory
docker update --memory 1024m {Container ID}
# swap memory (should be larger than memory limit)
docker update --memory-swap 2048m {Container ID}
# 확인
docker inspect {Container ID} | grep -i memory

3> CPU 코어수 변경

docker update --cpus 2 {Container ID}

[Tip | Ubuntu] 논리 볼륨 크기 조정

리눅스에서 할당된 논리적인 볼륨 크기를 조정하는 법을 정리한다.

테스트서버 : Ubuntu22.04
작성일 : 2023-02-23

1> 디스크 용량을 확인

df -h

2> 논리적인 볼륨 크기 조정

# 100%로 조정
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
# 적용
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

3> 현재 디스크 블럭의 정보를 확인

lsblk

[Tip | Ubuntu] zombie 프로세스 제거

프로세스를 종료 하였음에도 메모리가 정상해지 되지 않았거나 프로세스 엔트리에 남아 실행되고 있는 경우 이를 제거 하는 방법을 정리한다.


테스트서버 : Ubuntu22.04
작성일 : 2023-01-03

Zombie

On Unix operating systems, a zombie process or defunct process is a process that has completed execution but still has an entry in the process table, allowing the process that started it to read its exit status. In the term's colorful metaphor, the child process has died but has not yet been reaped.

When a process ends, all of the memory and resources associated with it are deallocated so they can be used by other processes. However, the process's entry in the process table remains. The parent is sent a SIGCHLD signal indicating that a child has died; the handler for this signal will typically execute the wait system call, which reads the exit status and removes the zombie. The zombie's process ID and entry in the process table can then be reused. However, if a parent ignores the SIGCHLD, the zombie will be left in the process table. In some situations this may be desirable, for example if the parent creates another child process it ensures that it will not be allocated the same process ID.

1> zombie 프로세서 확인

top
# ----------------------------------------
top - 10:13:56 up 4 days, 16:19,  2 users,  load average: 0.08, 0.53, 3.08
Tasks: 246 total,   1 running, 245 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2.2 us,  0.7 sy,  0.0 ni, 97.1 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
# ----------------------------------------

zombie의 숫자가 1이상이라면 pid 를 확인하여 kill 해야한다.


2> pid 확인

ps axo stat,ppid,pid,comm | grep -w defunct
# ----------------------------------------
Z     544478  545217 ruby <defunct>
Z     544478  547937 ruby <defunct>
# ----------------------------------------

3> kill 프로세스

kill -9 544478