ceph daemon core dump方法

习惯使用gdb分析的朋友,在研究ceph后,都希望同样能通过gdb分析下ceph dameon,哪如何操作呢?下面介绍下步骤;

设置linux core dump

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# echo "ulimit -c 1024" >> /etc/profile
然后退出重新登录

# ulimit -a
core file size (blocks, -c) 1024
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 128434
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65535
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 128434
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

# ulimit -c unlimited
# echo 1 > /proc/sys/kernel/core_uses_pid
# echo "/home/openstack/ceph/core-%e-%p-%t" > /proc/sys/kernel/core_pattern

通过上述方法设置了core dump的限制和规则后,就可以生成linux程序的core dump了

通过ceph-run运行ceph命令

1
2
3
4
5
ceph-run /usr/bin/ceph-osd --cluster=ceph -i 0 -f &
# ps ax | grep -w ceph
...
94899 ? S 0:00 /bin/sh /usr/bin/ceph-run /usr/bin/ceph-osd --cluster=ceph -i 0 -f
96306 ? Sl 0:01 /usr/bin/ceph-osd --cluster=ceph -i 0 -f

注意:ceph安装包最好自己编译,指定--with-debug

通过kill触发ceph daemon的core dump

1
kill -3 96306 / kill -4 96306

然后在之前配置的core dump目录下就能看到生成的core dump file
比如:/home/openstack/ceph/core-ceph-osd-96306-1450097306

通过gdb来分析core dump

1
gdb /usr/bin/ceph-osd /home/openstack/ceph/core-ceph-osd-96306-1450097306
支持原创