1. 问题:
执行db2start,无法启动db2,直到10分钟超时。
2. 解决方法:
使用 pstack 工具来确定进程挂起的位置。
① ps -ef|grep db2,查找db2start进程的pid
② pstack pid,以下是输出结果:
#0 0x00007f37e355bde0 in __poll_nocancel () from /lib64/libc.so.6
#1 0x00007f37d996cd64 in __libc_res_nsend () from /lib64/libresolv.so.2
#2 0x00007f37d996ac5e in __libc_res_nquery () from /lib64/libresolv.so.2
#3 0x00007f37d996b840 in __libc_res_nsearch () from /lib64/libresolv.so.2
#4 0x00007f37d9b7e77d in _nss_dns_gethostbyname3_r () from /lib64/libnss_dns.so.2
#5 0x00007f37e354cd82 in gaih_inet () from /lib64/libc.so.6
#6 0x00007f37e354fa3d in getaddrinfo () from /lib64/libc.so.6
#7 0x00007f37e5985811 in sqloPdbTcpIpGetAddrInfo () from /home/db2inst1/sqllib/lib64/libdb2.so.1
#8 0x00007f37e597cf16 in sqloPdbTcpIpResolveHostName () from /home/db2inst1/sqllib/lib64/libdb2.so.1
#9 0x00007f37e59dbd74 in sqloReadDb2nodesWithHandleInternal () from /home/db2inst1/sqllib/lib64/libdb2.so.1
#10 0x00007f37e59da010 in sqloReadDb2nodesInternal () from /home/db2inst1/sqllib/lib64/libdb2.so.1
#11 0x00007f37e59e2dbc in sqloGetNumDB2MembersAndCFs () from /home/db2inst1/sqllib/lib64/libdb2.so.1
#12 0x00007f37e598a311 in sqloInitializeCPUBindingGlobals() () from /home/db2inst1/sqllib/lib64/libdb2.so.1
#13 0x00007f37e598894b in sqloGetDb2Processors () from /home/db2inst1/sqllib/lib64/libdb2.so.1
#14 0x00007f37e5903ca6 in sqloInitializeLatchTuningInfo () from /home/db2inst1/sqllib/lib64/libdb2.so.1
#15 0x00007f37e55465ea in sqlePrimitiveKRCBInitialization () from /home/db2inst1/sqllib/lib64/libdb2.so.1
#16 0x00007f37e59770fa in sqlo_create_init_app_data_preset () from /home/db2inst1/sqllib/lib64/libdb2.so.1
#17 0x00007f37e54afe85 in sqleInitApplicationEnvironment(int, unsigned int, unsigned int, sqlca*) () from /home/db2inst1/sqllib/lib64/libdb2.so.1
#18 0x00007f37e4fc7971 in clp_fp_init(int*, int, char**) () from /home/db2inst1/sqllib/lib64/libdb2.so.1
#19 0x00007f37e4fb96dd in clp_api () from /home/db2inst1/sqllib/lib64/libdb2.so.1
#20 0x00000000004013de in main ()
--------------------------------------------------------
根据栈跟踪结果,可以找到进程挂起的原因。以上结果是由于dns无法解析导致进程挂起。