标签:
check Archiving processing
查看日志归档情况
db2 "SELECT DATE(CAST(START_TIME as TIMESTAMP)) as DATE,
count(*) as NUMBER_OF_LOGS_PER_DAY,
(count(*)*23.4375) as AMOUNT_LOGS_DAY_MB,
DBPARTITIONNUM as DBPART
FROM SYSIBMADM.DB_HISTORY
WHERE operation = ‘X‘ -- Archive logs
and OPERATIONTYPE = ‘1‘ -- 1 = first log archive method
and TIMESTAMP(END_TIME) > CURRENT_TIMESTAMP - 10 DAYS
GROUP BY DATE(CAST(START_TIME as TIMESTAMP)) , DBPARTITIONNUM
ORDER BY DATE DESC "
查看过去24小时是否进行过备份
[db2inst1@db2v9r7 ~]$]db2 "select substr(comment,1,30) as comment, timestamp(start_time) as start_time, timestamp(end_time) as end_time, substr(firstlog,1,25) as firstlog, substr(lastlog,1,25) as lastlog, seqnum, substr(location,1,50) as location from sysibmadm.db_history where operation = ‘B‘ and timestamp(start_time) > current_timestamp - 24 hours and sqlcode is null "
Dprop check
Capture side:
db2 "SELECT SYNCHTIME, CURRENT TIMESTAMP AS CURRENT_TIMESTAMP FROM ASN.IBMSNAP_REGISTER WHERE GLOBAL_RECORD=‘Y‘ with ur"
Apply side:
db2 "select APPLY_QUAL, SET_NAME, SOURCE_ALIAS, TARGET_ALIAS, ACTIVATE, STATUS, LASTRUN, LASTSUCCESS, SYNCHTIME, SLEEP_MINUTES,REFRESH_TYPE from ASN.IBMSNAP_SUBS_SET"
### 查看hadr 环境
$ db2pd -alldbs -hadr
db2pd -db sfa -hadr
#### 在 server端查询node 使用空间
SELECT node_name,CAST(FLOAT(SUM(physical_mb)) / 1024 /1024 AS DEC(8,2))as "Space in TB" ,SUM(num_files)as "Number of files" FROM occupancy GROUP BY node_name ORDER BY "Space in TB" DESC
DB2跟oracle不一样,用户都是操作系统创建的
而且用户没有所谓的默认表空间,默认临时表空间等等
整个数据库的默认表空间就是数据库创建的默认表空间,usertablespace
没有专门记录所有用户的视图,但是有个sysibmadm.privileges记录所有的用户权限
所以可以认为它就是专门记录用户的视图。
db2move 导出数据的时候 ,虽然 可以 db2move export
但是在设置导出字符集的时候 还是有些问题 ,
此时可以 export DB2CODEPAGE=1208 在用户的环境变量级别设置,使其生效。
### 获取root权限
yangmsu@b03zeddbc002i:/> sudo -l|grep -i auto
yangmsu‘s password:
(root) /usr/opt/db2*/instance*/, (root) /usr/opt/db2*/adm/*, (root) /usr/opt/db2*/bin/*, (root) /tmp/auto_db2install.sh,
(root) /usr/opt/db2*/instance*/, (root) /usr/opt/db2*/adm/*, (root) /usr/opt/db2*/bin/*, (root) /tmp/auto_db2install.sh,
yangmsu@b03zeddbc002i:/>
yangmsu@b03zeddbc002i:/tempdb2> sudo /tmp/auto_db2install.sh ### then we have root priviledges
b03zeddbc002i:~ #
b03zeddbc002i:~ # id
uid=0(root) gid=0(root) groups=0(root),64(pkcs11)
b03zeddbc002i:~ #
db2中有2个用户临时表空间,数据库默认使用哪一个?能修改吗?
1) if they are different page size, use the one with larger bufferpool (actually there are more logic behind there, but usually the result will be pointing to the one with larger bufferpool)
2) if they are with same page size, it is round-robin then
查询表大小
db2 "SELECT SUBSTR(TabSchema,1,15), TabName, TabType, (Data_Object_P_Size + Index_Object_P_Size + Long_Object_P_Size + Lob_Object_P_Size + Xml_Object_P_Size)/1024 as Total_P_Size_MB FROM SysIbmAdm.AdminTabInfo ORDER BY Total_P_Size_MB desc" >table_size.log
db2 "SELECT SUBSTR(TabSchema,1,15), TabName, TabType, (Data_Object_P_Size + Index_Object_P_Size + Long_Object_P_Size + Lob_Object_P_Size + Xml_Object_P_Size)/1024 as Total_P_Size_MB FROM SysIbmAdm.AdminTabInfo where TabName =‘T_CHANGE_DETAIL‘ "
查看数据库大小,单位byte
1. db2 "CALL GET_DBSIZE_INFO(?, ?, ?, 0) "
2. 通过表来查询数据库大小 snaphot_tbs_cfg
db2 "select (SUM(total_pages)*4)/1024.0/1024 TOTAL_ALLOCATED_SPACE_IN_GB from table (snapshot_tbs_cfg(‘dbname‘,-1)) TBS_SPCE"
查看表大小:
db2 "SELECT SUBSTR(TabSchema,1,15), TabName, TabType, (Data_Object_P_Size + Index_Object_P_Size + Long_Object_P_Size + Lob_Object_P_Size + Xml_Object_P_Size)/1024 as Total_P_Size_MB FROM SysIbmAdm.AdminTabInfo ORDER BY Total_P_Size_MB desc" >table_size.log
DB2执行sql脚本
db2 -tvf sql文件名
du -sg
du -amx| sort -nr |more linux 下查文件系统下文件大小
lsof 命令
grep两个字段/也可以grep两个以上的字段
=> db2 list db directory | grep -E "alias|type"
查询存储过程的内容:
db2 " select PROCNAME,text from syscat.procedures where PROCNAME = ‘SP_A_TSKRES‘"
team function ID
gdccndba@cn.ibm.com
查看当前数据库名
db2 "select current server from sysibm.sysdummy1"
vi编辑器中替换的方法
:%s/vivian/sky/g(等同于 :g/vivian/s//sky/g) 替换每一行中所有 vivian 为 sky
:%s/^/#/g && :%s/^#//g 禁用crontab 时 可以采取这个方法 行首替换
标准unix/linux下的grep通过以下参数控制上下文
grep -C 5 foo file 显示file文件中匹配foo字串那行以及上下5行
grep -B 5 foo file 显示foo及前5行
grep -A 5 foo file 显示foo及后5行
查看用户权限
db2 "select * from syscat.dbauth where grantee=‘CHUBALA‘"
db2 "select * from syscat.tabauth where grantee=‘CHUBALA‘"
db2 "select substr(GRANTOR,1,30), GRANTORTYPE, substr(GRANTEE,1,30), GRANTEETYPE, substr(TABSCHEMA,1,30), substr(TABNAME,1,30), CONTROLAUTH, ALTERAUTH, DELETEAUTH, INDEXAUTH, INSERTAUTH, REFAUTH, SELECTAUTH, UPDATEAUTH from syscat.tabauth where GRANTEE=‘AIXDBA3‘"
db2 "select substr(GRANTOR,1,30), GRANTORTYPE, substr(GRANTEE,1,30), GRANTEETYPE, substr(TABSCHEMA,1,30), substr(TABNAME,1,30), CONTROLAUTH from syscat.tabauth where GRANTEE=‘AIXDBA3‘"
查看aix下所有用户
cat /etc/passwd
查看aix下所有group
cat /etc/group
查看db2诊断日志
507 db2 get dbm cfg|grep -i diag
508 cd /db/lsinst/db2diag/
509 ls -alrt
510 tail db2diag.log
512 db2diag -time 2013-08-21-21.00|more
db2 "? sql-514" ### 查错误
db2 "? SQL0805N"
传送备份集到TSM(IBM Tivoli Storage Manager)
*****查询tsm 的备份文件存不存在必须要到 备份文件所在的目录下 ,已经测试过:
=> dsmc query backup 文件名
dsmc query backup /db2inst5/backup/SMIWSLA.0.db2inst5.NODE0000.CATN0000.20130824231022.001 -ina
nohup dsmc restore /db2inst5/backup/SMIWSLA.0.db2inst5.NODE0000.CATN0000.20130824231022.001 -ina &
=> dsmc incremental /db/inst2/db2backup/tmp.adsm.LPDB.output
=> dsmc DELETE BACKUP /db2inst5/backup/SMIWSLA.0.db2inst5.NODE0000.CATN0000.20130629121219.001 -deltype=INACTIVE
oslevel -s
db2level
有ITM进程,说明tivoli在运行
### db2的归档 不是用 dsmc 做active log的backup 而是调用tsm 的API
### 查询 和 提取 ,详细参考infocenter db2adutl command
db2adutl query logs between S0002650 and S0002650 db blogs
db2adutl extract logs between S0002650 and S0002655 db blogs ### 提取到当前目录下
db2adutl upload logs between S0168147 and S0168147 db blogs
$HOME/sqllib/adsm/dsmapipw
tsm client 重置密码
## 查tsm 的 客户端配置的server 信息
cat /usr/tivoli/tsm/client/api/bin64/dsm.opt
cat /usr/tivoli/tsm/client/api/bin64/dsm.sys
cat /usr/tivoli/tsm/client/ba/bin/dsm.sys
db2inst5@b03cxnp01028:/db/db2data/db2inst5/db2inst5/NODE0000> env|grep DSM
DSMI_CONFIG=/usr/tivoli/tsm/client/api/bin64/dsm.opt
DSM_LOG=/db2inst5/sqllib/db2dump
DSMI_LOG=/db2inst5/sqllib/db2dump
DSM_DIR=/usr/tivoli/tsm/client/api/bin64
DSM_CONFIG=/usr/tivoli/tsm/client/api/bin64/dsm.opt
DSMI_DIR=/usr/tivoli/tsm/client/api/bin64
db2 catalog tcpip node nodewin1 remote 9.1.39.85 server 50000
db2 catalog database sample (as alias) at node nodewin1
db2 uncatalog db 数据库别名
db2 uncatalog node 节点名
###############################################################
################################################################
通过ID owner来判断,服务器是否为本team维护,以下几个ID为本team
################################################################
################################################################
查看当前目录下最大的文件
du -amx |sort -nr|more
################################################################
1.我们可以在VI编辑器里把^M进行删除:
将VI切换至命令行模式,输入(注意输入这个^M,这个不是shift+^再加上M,应该是ctrl+v加上ctrl+m)
:%s/^M//g --该命令copy无效,注意^M的输入
在vi命令行模式执行上面的命令,可以将所有行末的^M去掉
2.可以使用dos2unix命令
dos2unix filename
################################################################
扩展表空间步骤
################################################################
查看表空间使用率
查看表空间使用率
db2 "select TBSP_ID,substr(TBSP_NAME,1,30) as TBSP_NAME, TBSP_TYPE, TBSP_TOTAL_SIZE_KB/1024 as TOTAL_M,TBSP_USED_SIZE_KB/1024 as USED_M,TBSP_UTILIZATION_PERCENT as Pct, TBSP_USING_AUTO_STORAGE, TBSP_AUTO_RESIZE_ENABLED from SYSIBMADM.TBSP_UTILIZATION" |grep CLOBS_TSP
查看表空间属性(是否自动扩展,看AR/auto resize字段)
db2pd -db PMOR11 -tablespace 5
查看扩展到目标使用率需要扩展多少容量
db2 "select substr(TBSP_NAME,1,30) as TBSP_NAME,round((TBSP_USED_SIZE_KB/1024/0.75),0) as After_Extend_M,TBSP_USED_SIZE_KB/1024/0.75-TBSP_TOTAL_SIZE_KB/1024 Should_Extend_M from SYSIBMADM.TBSP_UTILIZATION where TBSP_NAME=‘CLOBS_TSP‘"
查看目标服务器是否为高可用架构
db2pd -db CWAMAPP -hadr
查看是否有备份恢复task正在执行中
db2 list utilities show detail
扩展表空间
alter tablespace CLOBS_TSP extend (all 30M)
HADR 基本维护操作
1. hadr 的启停操作
起 HADR
备 :
db2 deactivate database sample
db2 start hadr on database sample as standby
主 :
db2 deactivate database sample
db2 start hadr on database sample as primary
##启动完成后 ,查看hadr 状态
1. db2 get snapshot for db on sample
2. db2pd -db sample -hadr
停 HADR
主 :
db2 deactivate database sample
db2 stop hadr on database sample
备 :
db2 deactivate database sample /[db2inst1@hadr1 logtarget]$ db2 deactivate database sample user db2inst1 using db2inst1
db2 stop hadr on database sample
### 有时 deactivate database 不加用户名密码时,在stop hadr 时会报错
[db2inst1@hadr1 logtarget]$ db2 stop hadr on database sample
SQL1769N Stop HADR cannot complete. Reason code = "2".
[db2inst1@hadr1 logtarget]$
2. 在备用服务器上执行数据库接管
db2 takeover hadr on database sample (by force)
###################################################################
AIX group:NUS_W_DNAHEAIX
dispool4@in.ibm.com
Tivoli Monitoring Team(NUS_N_SSEASMI)
Tivoli Database Support team(NUS_N_ASTIVDB)
Linux Team group:NUS_N_LINUX
OPS funcation id:cnagdsop@cn.ibm.com
CC: db2inter@br.ibm.com,gdccndba@cn.ibm.com,zfzheng@cn.ibm.com
7:01:37 PM: Wei Shi: BCC: szshiwei@cn.ibm.com, SUZHOU DBA
NUS_W_SSAHEDBA for AHE DBA team
NUS_N_SSUDBDBA for OOP DBA team
NUS_N_SSBRCONN for connect team
NUS_W_DNAHEAIX
NUS_W_SSTIVOLI Tivoli
NUS_N_
3:30:54 PM: yangmsu@cn.ibm.com - Kimi M Yang/China/IBM: tsm :
storbur2@br.ibm.com NUS_N_ADSM
msstsm@us.ibm.com NUS_N_UDTSM , I-MSV-US-BRBLD
标签:
原文地址:http://www.cnblogs.com/DBA-Ivan/p/4197367.html