如何使用db2ReadLog读取数据库日志文件

本文详细介绍了如何使用db2ReadLog工具来读取数据库日志文件。步骤包括:拷贝样本文件,更改目录权限,创建测试库,预编译、绑定数据库文件,编译和链接可执行程序,最后运行解析日志的示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

如何使用db2ReadLog读取数据库日志文件:
1,拷贝sqllib/samples/c下的所有文件到本地文件位置:
[db2inst1@localhost ~/db2test]$ cp -R ~/sqllib/samples/c .
2,更改本地目录的权限使其能够创建修改文件
[root@localhost db2test]# pwd
/home/db2inst1-m/db2test
[root@localhost db2test]# chmod -R 777 c/
3,使用db2sampl命令创建一个示例测试库
[db2inst1@localhost ~/db2test]$db2sampl
Starting the DB2 instance...
  Creating database "SAMPLE"...
  Connecting to database "SAMPLE"...
  Creating tables and data in schema "TEST97"...
  Creating tables with XML columns and XML data in schema "TEST97"...
  Stopping the DB2 instance...

  'db2sampl' processing complete.
4,连接到测试数据库
[db2inst1@localhost c]$ db2 connect to sample

Database Connection Information

Database server = DB2/LINUXX8664 9.7.10
SQL authorization ID = DB2INST1
Local database alias = SAMPLE
5,预编译:
预编译数据库文件,embprep是一个脚本文件,生成*.c和*.bnd,并且绑定到了数据库
预编译*.sqc文件生成*.c和*.bnd
[db2inst1@localhost c]$ db2 precompile dblogconn.sqc bindfile

LINE MESSAGES FOR dblogconn.sqc
------ --------------------------------------------------------------------
SQL0060W The "C" precompiler is in progress.
SQL0091W Precompilation or binding was ended with "0"
errors and "0" warnings.

[db2inst1@localhost c]$ db2 precompile utilemb.sqc bindfile

LINE MESSAGES FOR utilemb.sqc
------ --------------------------------------------------------------------
SQL0060W The "C" precompiler is in progress.
SQL0091W Precompilation or binding was ended with "0"
errors and "0" warnings.
6,绑定
绑定是从绑定文件创建包并将其存储在数据库中的过程。
[db2inst1@localhost c]$ db2 bind dblogconn.bnd

LINE MESSAGES FOR dblogconn.bnd
------ --------------------------------------------------------------------
SQL0061W The binder is in progress.
SQL0091N Binding was ended with "0" errors and "0" warnings.

[db2inst1@localhost c]$ db2 bind utilemb.bnd
LINE MESSAGES FOR utilemb.bnd
------ --------------------------------------------------------------------
SQL0061W The binder is in progress.
SQL0091N Binding was ended with "0" errors and "0" warnings.

[db2inst1@localhost c]$ db2 list packages

Bound Total Isolation
Package Schema Version by sections Valid Format level Blocking
----------- --------- ----------- --------- ------------- ------- -------- --------- --------
DBLOGCON DB2INST1 DB2INST1 19 Y 0 CS U
P1567770> DB2INST1 DB2INST1 10 N 0 CS U
UTILEMB DB2INST1 DB2INST1 1 Y 0 CS U

7,编译
编译是从源文件生成到目标文件的过程
[db2inst1@localhost c]$ cc -I$DB2PATH/include -c dblogconn.c
[db2inst1@localhost c]$ cc -I$DB2PATH/include -c utilemb.c
8,链接
链接是将目标文件与适当的共享库合并以执行的可执行程序的过程。
[db2inst1@localhost c]$ cc -o dblogconn dblogconn.o utilemb.o -L$DB2PATH/lib -ldb2
9,输出
[db2inst1@localhost c]$ ./dblogconn

对照dblogconn输出的例子来分析db2日志格式
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值