이 페이지는 기계 번역되었습니다. 영어 원본을 읽어보세요. English

IBSurgeon 라이브러리

Linux에서 Firebird 덤프를 수집하고 스택 트레이스를 생성하는 방법

소개

Firebird에 심각한 문제(예: 행(hang) 또는 비정상 종료)가 발생한 경우, 덤프 수집을 구성한 다음 스택 트레이스를 생성해야 합니다. 덤프와 스택 트레이스를 통해 IBSurgeon의 Firebird 핵심 개발자들이 행/장애의 상세한 상황을 분석하고 해결책을 제시할 수 있습니다.

덤프 및 스택 트레이스 분석은 IBSurgeon의 고급 Firebird 기술 지원 서비스의 일부로 제공됩니다. 요금제는 서버당 월 USD199부터 시작하며, 채팅(WhatsApp, Telegram 등)을 통한 지원이 포함되어 있어 심각한 문제 발생 시 거의 즉시 전문적인 도움을 받을 수 있습니다.
자세한 내용은 다음을 방문하세요: /ko/enterprise-subscription-plans-for-firebird/
아래의 모든 작업은 root 또는 sudoer 권한이 필요합니다.

1. 사전 요구사항

1.1 방해가 되는 패키지 삭제 또는 중지

Ubuntu/Debian

  • systemd-coredump
Code
apt-get purge --auto-remove systemd-coredump

삭제 확인:

Code
cat /proc/sys/kernel/core_pattern

다음과 같은 출력이 없어야 합니다:

Code
/lib/systemd/systemd-coredump%P %u %g %s %t %e
  • apport
Code
# 검색
service --status-all | grep -m1 -i apport

# 삭제 시뮬레이션
apt-get -s remove apport

# 삭제
sudo apt-get remove apport

# 남은 파일 정리
sudo apt-get purge apport

CentOS/RedHat

  • abrtd

확인:

Code
cat /proc/sys/kernel/core_pattern

다음과 같은 출력이 보이면:

Code
/usr/libexec/abrt-hook-ccpp %s %c %p %u %g%t e %P %I

abrtd 중지 및 삭제:

CentOS 6의 경우:

Code
service abrtd stop

CentOS 7의 경우:

Code
systemctl disable abrtd.service

삭제:

Code
yum -y remove abrt*

# 남은 파일 정리
rm -r /var/cache/abrt/

# 정리 확인
cat /var/log/yum.log | grep abrt

1.2 GDB 설치

GDB는 수집된 덤프에서 스택 트레이스를 생성하는 데 필요합니다. GDB 설치는 성능에 영향을 주지 않으며 Firebird를 “디버그” 모드로 전환하지 않습니다.

CentOS의 경우:

Code
yum install gdb

Ubuntu/Debian의 경우:

Code
apt-get install gdb

2. 덤프 크기 제한 제거

현재 덤프 크기 제한 확인:

Code
ulimit -c

0이 표시되면 덤프 생성이 금지된 것입니다.

systemd를 사용하는 시스템의 경우 서비스 파일을 수정합니다:

CentOS/RedHat

Code
/usr/lib/systemd/system/firebird-superserver.service

Ubuntu/Debian

Code
/lib/systemd/system/firebird-superserver.service

[Service] 섹션에 추가:

Code
LimitCORE=infinity

서비스 재시작:

Code
systemctl daemon-reload
systemctl restart firebird-superserver.service

무제한 덤프 크기 확인:

Code
strings /proc/$(pgrep firebird)/limits

3. 덤프 파일 위치 및 이름 구성

이 단계는 선택 사항이지만 의미 있는 덤프 파일 이름을 지정하고 충분한 저장 공간을 확보하기 위해 적극 권장됩니다.

임시 구성

Code
sysctl -w kernel.core_pattern=/path/to/dumps/core.%e.%t.%p

영구 구성

/etc/sysctl.conf에 추가:

Code
kernel.core_pattern=/path/to/dumps/core.%e.%t.%p

소유권 설정

Code
chown firebird /path/to/dumps -R

4. 덤프 수집 테스트

사전 요구사항

  1. SSH 재시작

  2. ulimit -c가 “unlimited"를 반환하는지 확인

테스트 크래시 명령

Firebird 3+ (SuperServer 또는 SuperClassic)

Code
echo "shell kill -6 $(pgrep firebird);" | /opt/firebird/bin/isql -q localhost:employee -user sysdba -pas masterkey

Firebird 2.5 (SuperClassic)

Code
echo "shell kill -6 $(pgrep fb_smp_server);" | /opt/firebird/bin/isql -q localhost:employee -user sysdba -pas masterkey

Classic 모드

Code
select mon$server_pid from mon$attachments where mon$attachment_id = current_connection;
shell kill -6 <찾은_PID>;

5. 디버그 파일 설치

- 디버그 파일은 Firebird 빌드 버전과 일치해야 합니다

- 디버그 파일 설치는 성능에 영향을 주지 않습니다

- Firebird 업데이트 시 디버그 파일도 업데이트해야 합니다

예상 디버그 파일 위치:

Code
/opt/firebird/bin/.debug/firebird.debug
/opt/firebird/bin/.debug/gbak.debug
/opt/firebird/bin/.debug/isql.debug
/opt/firebird/lib/.debug/libfbclient.so.3.0.11.debug
/opt/firebird/lib/.debug/libib_util.so.debug
/opt/firebird/plugins/.debug/libfbtrace.so.debug
/opt/firebird/plugins/.debug/libEngine12.so.debug
HQbird 설치에는 올바른 디버그 파일이 포함되어 있으며 업데이트를 자동으로 처리합니다.

6. 실행 중인 프로세스에서 스택 트레이스 생성

  1. gdb-commands.txt 생성:
Code
thread apply all bt
quit
yes
  1. 스택 트레이스 생성:
Code
gdb -q -x ./gdb-commands.txt /opt/firebird/bin/firebird $(pgrep firebird) 1>./stacktrace.txt 2>&1

7. 실행 중인 프로세스에서 덤프 생성

Code
gcore -o /path/to/dumps/firebirdprefix $(pgrep firebird)
도구가 접두사에 프로세스 ID를 추가합니다.

8. 기존 덤프에서 스택 트레이스 생성

Code
gdb -q -x ./gdb-commands.txt /opt/firebird/bin/firebird /tmp/core.firebird.23041 1>./stacktrace1.txt 2>&1

9. 심층 덤프 분석

공유 라이브러리 분석:

Code
echo -e "info sharedlibrary\nquit\n" | gdb