nanjing_2013
作者nanjing_20132012-07-13 19:01
系统架构师, 北京卓望

总结记录一下

字数 9395阅读 984评论 0赞 0

查看AIX系统硬盘空间:
df -g
已文件大小排序命令:
ls -sl | sort -n +4 | pg
ls -lS
查看AIX  CPU个数:
lsdev -Cc processor
查看目录大小:单位(GB)
du -gs *
查看文件条数:
wc -l 文件名
提取文件前10行:
head -10 table_name>1.txt
查看文件load条数
db2 "load query table table_name"
terminate 表    表空间挂起的时候需要用到
db2 "load client from /home/dipf/diapp/split/xae of del modified by coldel, messages /home/split/table_name.msg terminate into table_name SORT BUFFER 7500 CPU_PARALLELISM 4"


db2 "load client from /home/dipf/diapp/workdir/pi_cbod_dec/20111001/table_name.ps of DEL modified by nochardel coldel0X1D WARNINGCOUNT 100 messages /home/dipf/diapp/workdir/log/log_import/20111001/table_name.msg replace into table_name NONRECOVERABLE"

terminate 表    表空间挂起的时候需要用到

db2 "load from /dev/null of del terminate into table_name"

--db2表空间backup pending情况下
db2 backup db jsbodm on TABLESPACE USERSPACE1 online to /dev/null
DB2 BACKUP database dbname TABLESPACE tablespacename ONLINE to d:/backup

删除字段
ALTER TABLE table_name DROP COLUMN JIEQU_LOG_NO
添加字段
ALTER TABLE table_name ADD JIEQU_LOG_NO CHAR(2)


db2 "load client from /dev/null of del replace into table_name"


SQL0668N  Operation not allowed for reason code "7" on table
---对表进行重构
db2 reorg table table_name

---查文件内记录
grep -R 320625001 *


db2diag.log 日志的备份清理

db2diag命令,是用来查看db2数据库运行日志信息的,实际上,db2运行日志是记录在db2diag.log文件中,可以 通过此文件,查看记录的有关DB2数据库详细的错误信息,而db2diag只是查看该日志文件的一个小工具而已。db2数据库在运行过程中如果经常有报错的话,这个文件增长的会很快,需要定期清理,备份移走或者删除,通常有两种方法:

可以通过执行db2 get dbm cfg 来查看Diagnostic data directory path(DIAGPATH) 参数的设置。

1、使用db2diag工具,直接执行命令db2diag -A /db2diagbak (备份至/db2diagbak ,使用db2diag -h查看db2diag帮助),系统会自动移走db2diag.log并将备份的文件名添加上当前日期时间信息。

2、直接备份,在db2停止运行的情况下,将db2diag.log文件备份至其他文件系统,该文件删除后在db2启动后会自动重建。

附录:

$db2diag -h

db2diag - The db2diag.log Analysis Tool

db2diag is a tool for filtering and formatting the db2diag.log file

Command syntax:
.------------. .--------------.
V | V |
>>--db2diag--+------------+--+--------------+--><
| | | |
--option-- --filename--

Command parameters:

filename - one or more space-separated path names of diagnostic logs
-help , -h , ? - help information. To get help on help, try "db2diag -h h"
-filter , -g - case-sensitive search for a list of field-pattern pairs
-gi - case-insensitive search for a list of field-pattern pairs
-gv - case-sensitive invert matching
-gvi , -giv - case-insensitive invert matching
-invert , -v - invert the sense of matching for all filtering options
-exist - record field must exist in order to be processed
-pid - find all records for a list of process IDs
-tid - find all records for a list of thread IDs
-eduid - find all records for a list of EDU IDs
-node , -n - find all records for a list of nodes
-error , -e - find all records for a list of errors
-level , -l - find all records for a list of severity levels
-history, -H - display the history of logged records for a time interval
-time , -t - display all the records within a particular time interval
-count , -c - display a count of matching records
-verbose, -V - display all record fields whether they contain data or not
-strict - display records using one "field: value" pair per line
-cbe - display records in the Common Base Event (CBE) format
-fmt - format tool's output using a format string
-output , -o - save output into a file
-follow , -f - continuously display appended records as the file grows
-archive, -A - archive a diagnostic log file
-readfile - read from a file ignoring terminal input (used in scripts)
-rc - display descriptions of DB2 error return codes, ZRC or ECF
-ecfid - display function info extracted from the numeric ECF ID
-facility, -fac - display messages from a particular facility

"db2diag -h <option1[,option2[,option3...]]>" - displays additional help and
usage examples for one or more options specified in the options list

"db2diag -h brief" - displays help for all options without examples

"db2diag -h examples" - displays a few typical examples to get started

"db2diag -h tutorial" - displays more advanced examples covering all features

"db2diag -h notes" - displays usage notes and restrictions that apply

"db2diag -h all" - displays help in the most complete form with detailed
information about all options and usage examples

下面是查看该文件时经常会碰到的一个片段(蓝色部分是为了便于讲解而加上去的编号)

-----------------------------------------------

2003-04-24-13.56.13.453290(1) Instance:svtdbm2(2) Node:100(3)

PID:672(db2agent (SUN102) 100)(4) TID:1(5) Appid:*N100.svtdbm2.0074F4174930(6)

buffer pool services(7) sqlbCheckAllocation(8) Probe:800(9) Database:SUN102(10)

-----------------------------------------------

 

上面的蓝色部分分别如下含义:

1) timestamp (时间戳)

2) instance (数据库实例)

3) partition number (分区号)

4) process and database (进程和数据库)

5) thread Id (线程ID)

6) application ID (应用程序ID)

7) component (组件)

8) function (函数)

9) internal error point (内部错误指针)

10) database (数据库)

 

了解这些基本含义有助于分析和诊断DB2的相关问题。

 

2. 要显示 db2diag.log 文件中所有关于 119664 进程的信息,可利用以下命令:

 

db2diag -pid 119664

 

2004-10-11-19.01.56.555034-300 I7109918C313 LEVEL: Event

PID : 119664 TID : 1 PROC : db2star2

INSTANCE: dimi NODE : 000

FUNCTION: DB2 UDB, config/install, sqlfLogUpdateCfgParam, probe:30

CHANGE : CFG DBM: "Instance_Memory" <automatic> From: "11126" To: "11126"

....

 

结合上述两种用法,以下命令将抽取 db2diag.log 文件中分区 0 4 上所有 119664 进程的相关信息:

 

db2diag -pid 119664 -n 0,4

 

3. 为显示 db2diag.log 文件中包含的时间戳“2004-11-02-11.00.907665-360”之后的所有信息,可用下述命令:

 

db2diag -time 2004-11-02-11.00.907665-360

 

 

4. 另外一个较有用的选项是“-rc”。对于以前的 DB2 版本,用户经常希望了解的 db2diag.log 中的常出现十六进制返回码所提示的信息,在 v8.2 上,如果使用该选项便可得到关于这些十六进制返回码的解释。如对于以下一段信息:

 

2004-10-19-12.19.46.033037-300 I7202340C354 LEVEL: Severe

PID : 139048 TID : 1 PROC : db2hmon 4

INSTANCE: dimi NODE : 000

FUNCTION: DB2 UDB, routine_infrastructure, sqlerFmpOneTimeInit, probe:100

MESSAGE : DiagData

DATA #1 : Hexdump, 4 bytes

0x2FF225B0 : FFFF FBEE ....

......

 

为了解十六进制 0xFFFF FBEE 所提示的信息,可使用下面的命令:

 

db2diag -rc FFFFFBEE

 

其输出为:

 

Input ECF string 'FFFFFBEE' parsed as 0xFFFFFBEE (-1042).

ERROR: ../sqz/sqlzwhatisrc.C:

Input ZRC 0xFFFFFBEE (-1042) cannot be identified as a V7 or V6 ZRC value

 

即该返回码提示的错误码为:SQL1042C,用户可使用:

 

db2 "? sql1042"

 

获得关于这个错误的具体解释。

 

 

5. 为显示 db2diag.log 中所记录的严重错误,使用:

 

db2diag -gi "level=severe"

 

输出可参看例 4 中提供的。

 

 

如果要得到有关该工具的更多选项的帮助信息,可使用:

 

db2diag -h

 

使用db2diag工具的高级选项过滤查找db2diag.log诊断日志记录

 

内容

提要 db2diag.logDB2中非常重要的诊断日志,一般出现问题后,首先就要查看db2diag.log文件。但是很多时候特别是在多分区数据库中,查看db2diag.log变得非常费时。因为所有分区所有应用程序的诊断日志都会写到DB2的诊断日志中。从DB2版本8.2开始,DB2提供了db2diag工具可以用来过滤查找特定的日志,

有时候我们需要做一些更高级的过滤查询,以便帮助我们进一步诊断问题,该文章通过例子对于db2diag中的高级选项做了介绍。

正文首先简单介绍db2diag.log中的条目构成,如下所示为一条标准的db2diag.log日志条目:

2005-12-26-19.09.14.702039+480 I84831569A398 LEVEL: Severe

PID : 1060946 TID : 1 PROC : db2agent (XXXX) 0

INSTANCE: db2inst1 NODE : 000 DB : XXXX

APPHDL : 0-222 APPID: C0A86402.OD11.03F806110349

FUNCTION: DB2 UDB, relation data serv, sqlrr_fetch, probe:20

RETCODE : ZRC=0x80120086=-2146303866=SQLR_PRTCLE "DRDA Protocol Error"

 

其中上面的黑体字部分是我们的每条诊断日志的不同列标识。其中FUNCTION包含:PRODUCT,COMPONENT,FUNCNAME,PROBE,这几个也是可以单独搜索的列标志。

 

利用db2diag工具的-g选项可以对每一个列标志进行搜索,下面是-g选项的说明:

 

-g: 搜索符合搜索一系列“<列标志>=<列值>”条件的诊断日志记录,条件中间使用逗号分开。搜索区分大小写。

-gi: 功能等同于-g,搜索不区分大小写。

-gv: 搜索不符合一系列“<列标志>=<列值>”条件的诊断日志记录,条件中间使用逗号分开。搜索区分大小写。

-gvi:功能等同于-gv,搜索不区分大小写。

 

另外我们的条件表达式支持如下几种:

 

= 全字精确匹配查询

:= 部分匹配模糊查询

!= 查找不符合全字精确匹配查询条件的记录

!:= 查找不符合部分匹配模糊查询条件的记录

^= 选择查找列中以后面的查找条件开头的记录

!^= 选择查找列中不以后面的查找条件开头的记录

 

关于高级查找功能的帮助,您可以随时通过"db2diag -h filter" 获得。

 

另外db2diag还对于特定的列标志提供了快捷选项,如LEVEL,可以使用-l选项指定,NODE可以使用-n选项指定。下面我们就以几个例子演示一下如何使用高级查找功能:

 

1、查找应用程序句柄APPHDL0-222的所有诊断日志条目:

 

db2diag -g APPHDL="0-222"

 

2、查找应用程序句柄APPHDL0-222在分区0上的所有诊断日志条目:

 

db2diag -g APPHDL="0-222",NODE=000

 

3、查找进程1060946的所有严重错误(Severe):

 

db2diag -g PID=1060946,LEVEL=Severe

 

4、查找所有FUNCTION名称中包饭fetch的诊断日志条目:

 

db2diag -g FUNCTION:=fetch

 

5、查找所有component名称以"base sys"开头的诊断日志条目:

 

db2diag -g "COMPONENT^=base sys"

 

6、查找所有返回码为"ZRC=0x80120086"的记录:

 

db2diag -g RETCODE:=0x80120086

 

除了过滤查找之外,db2diag还可以格式化输出。您可以指定查找结果的输出格式。关于格式化输出的详细帮助,请使用"db2diag -h fmt"命令查看。下面简单介绍一个例子:

 

db2diag -time 2005-12-22 -node "0,1,2" -level "Severe, Error" |db2diag -fmt "Time: %{ts} Partition: %node Message Level:%{level} nPid: %{pid} Tid: %{tid} Instance:%{instance}nMessage: @{msg}n"

 

该命令将查找20051222日以来在分区012上错误级别为SevereError的错误,并按照下面的格式输出:

 

Time: 2005-12-28-14.32.01.067843 Partition: 000 Message Level:Error

Pid: 1871948 Tid: 1 Instance:db2inst1

Message: ZRC=0x860F000A=-2045837302=SQLO_FNEX "File not found."

DIA8411C A file "" could not be found.

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

0

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

X社区推广