今天为了诊断问题,想抓一个db2start过程的系统trace, 结果发现还不是那么容易,颇费周折。下面我把过程简单记录下来。
先是最直接的方式,失败:
db2v1057@turing1:~> strace -o db2start.out db2start
SQL1641N The db2start command failed because one or more DB2 database manager program files was prevented from executing with root privileges by file system mount settings.
然后想到通过root用户:
root@turing1:~ # strace -o db2start.out su - db2v1057 -c db2start
12/19/2017 22:07:14 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
检查输出文件后,发现没有想要的数据。然后想到默认trace应该没打子进程的trace, 于是加上“-f”:
root@turing1:~ # strace -o db2start.out -f su - db2v1057 -c db2start
SQL1641N The db2start command failed because one or more DB2 database manager program files was prevented from executing with root privileges by file system mount settings.
又是这倒霉的错。
查资料,终于发现一个可行的方案:
窗口1:
db2v1057@turing1:~> cat start.sh
#
echo 'My process ID = ' $$
read -p 'Enter to run db2start ...' temp
echo 'Run db2start ...'
/home/db2v1057/sqllib/adm/db2start
db2v1057@turing1:~> chmod a+x start.sh
db2v1057@turing1:~> ./start.sh
My process ID = 30046
Enter to run db2start ... (等待回车键)
窗口2:
root@turing1:~ # strace -o db2start.out -f -p 30046
Process 30046 attached - interrupt to quit
Process 30098 attached (waiting for parent)
Process 30098 resumed (parent 30046 ready)
Process 30046 suspended
Process 30099 attached
Process 30098 suspended
Process 30098 resumed
Process 30099 detached
Process 30100 attached
Process 30098 suspended
Process 30101 attached (waiting for parent)
Process 30101 resumed (parent 30100 ready)
Process 30102 attached
Process 30101 suspended
Process 30101 resumed
Process 30102 detached
Process 30101 detached
Process 30103 attached
Process 30100 suspended
Process 30104 attached
Process 30100 resumed
Process 30103 detached
Process 30105 attached
Process 30106 attached
Process 30107 attached
Process 30108 attached (waiting for parent)
Process 30108 resumed (parent 30107 ready)
Process 30109 attached
Process 30110 attached (waiting for parent)
Process 30110 resumed (parent 30107 ready)
Process 30111 attached
Process 30112 attached
Process 30113 attached
Process 30114 attached
Process 30115 attached (waiting for parent)
Process 30115 resumed (parent 30107 ready)
Process 30116 attached
Process 30117 attached (waiting for parent)
Process 30117 resumed (parent 30107 ready)
Process 30134 attached (waiting for parent)
Process 30134 resumed (parent 30107 ready)
Process 30135 attached (waiting for parent)
Process 30135 resumed (parent 30107 ready)
Process 30136 attached (waiting for parent)
Process 30136 resumed (parent 30107 ready)
Process 30137 attached
Process 30138 attached (waiting for parent)
Process 30138 resumed (parent 30107 ready)
Process 30139 attached
Process 30140 attached (waiting for parent)
Process 30140 resumed (parent 30107 ready)
Process 30141 attached
Process 30140 detached
...
Process 30139 detached
Process 30141 detached
窗口1:
db2v1057@turing1:~> ./start.sh
My process ID = 30046
Enter to run db2start ... (按回车键)
Run db2start ...
12/19/2017 22:13:56 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
窗口2: Ctrl + c
搞定!




