标签云
asm恢复 bbed bootstrap$ dul kcbzib_kcrsds_1 kccpb_sanity_check_2 kcratr_nab_less_than_odr MySQL恢复 obet ORA-00312 ORA-00704 ORA-00742 ORA-01110 ORA-01200 ORA-01555 ORA-01578 ORA-01595 ORA-600 2662 ORA-600 2663 ORA-600 3020 ORA-600 4000 ORA-600 4137 ORA-600 4193 ORA-600 4194 ORA-600 16703 ORA-600 kcbzib_kcrsds_1 ORA-600 KCLCHKBLK_4 ORA-600 kcratr_nab_less_than_odr ORA-15042 ORA-15196 ORACLE 12C oracle dul ORACLE PATCH Oracle Recovery Tools oracle加密恢复 oracle勒索 oracle勒索恢复 oracle异常恢复 ORACLE恢复 Oracle 恢复 ORACLE数据库恢复 oracle碎片 OSD-04016 YOUR FILES ARE ENCRYPTED 比特币加密文章分类
- MongoDB (1)
- MongoDB恢复 (1)
- Others (2)
- 中间件 (2)
- WebLogic (2)
- 操作系统 (112)
- 数据库 (1,884)
- DB2 (22)
- MySQL (82)
- Oracle (1,709)
- Data Guard (53)
- EXADATA (8)
- GoldenGate (24)
- ORA-xxxxx (168)
- ORACLE 12C (72)
- ORACLE 18C (6)
- ORACLE 19C (15)
- ORACLE 21C (3)
- Oracle 23ai (8)
- Oracle ASM (73)
- Oracle Bug (8)
- Oracle RAC (56)
- Oracle 安全 (6)
- Oracle 开发 (28)
- Oracle 监听 (29)
- Oracle备份恢复 (662)
- Oracle安装升级 (108)
- Oracle性能优化 (62)
- 专题索引 (5)
- 勒索恢复 (91)
- PostgreSQL (37)
- pdu工具 (7)
- PostgreSQL恢复 (13)
- SQL Server (34)
- SQL Server恢复 (14)
- TimesTen (7)
- 达梦数据库 (5)
- 达梦恢复 (3)
- 生活娱乐 (2)
- 至理名言 (11)
- 虚拟化 (2)
- VMware (2)
- 软件开发 (51)
- Asp.Net (9)
- JavaScript (12)
- PHP (2)
- 小工具 (34)
- MongoDB (1)
-
最近发表
- 记录19c ASM磁盘掉线触发ORA-59048故障处理
- aix平台Oracle数据库由于断电无法启动故障处理
- 断电引起ORA-600 3005故障处理
- 记录一次云存储资源到期之后引起的数据库恢复
- Firebird 损坏数据库数据抢救工具—firebirdext
- Oracle 19c 202610补丁(RUs+OJVM)-19.33
- 由于con$.con#值达到极限,触发数据库增加约束报ORA-600 12807错误
- MongoDB 离线提取工具—mongoext
- .bres勒索病毒加密数据库dmp文件可恢复
- ORA-600 krsm_mrp_rebuild_lf_list.lno_mismatch
- 记录一次0丢失的ORA-00354: 损坏重做日志块标头故障恢复
- 不当数据库恢复操作导致一个月数据丢失
- obet快速修复oracle 位图损坏块
- 不太常见的10.2.0.1的oracle redo损坏恢复
- obet forcecopy功能抢救硬件故障中的数据文件
- kcratr_nab_less_than_odr和system坏块故障处理
- 通过obet 恢复system坏块,打开数据库
- obet dbv功能完整说明
- 分享一例运行在aix上的sap系统数据库恢复过程
- OBET-Oracle Block Editor Tool使用说明
分类目录归档:数据库
sql_id和hash value的部分转换
从oracle 10g开始引进了sql_id,在老版本的oralce中,要表明一条sql,一般使用hash value,而在10g及其以后版本中一般建议使用sql_id,从9i的sp和10g的awr中也可以看出.对于Library Cache对象,Oracle使用MD5算法进行哈希,生成一个128位的Hash Value,其中低32位作为HASH VALUE显示,SQL_ID则取了后64位.既然hash value和sql_id之前存在着这样的关系,那么我们就可以通过函数实现两者的部分转换(因为最终取值长度不同,所以不能完全转换)
1.查询sql_id和hash value
SQL> select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi PL/SQL Release 10.2.0.4.0 - Production CORE 10.2.0.4.0 Production TNS for Linux: Version 10.2.0.4.0 - Production NLSRTL Version 10.2.0.4.0 - Production SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') 2 "www.xifenfei.com" from dual; www.xifenfei.com ------------------- 2012-05-26 01:05:39 SQL> select sql_id,hash_value from v$sql where sql_text like 2 'select * from dual'; SQL_ID HASH_VALUE ------------- ---------- a5ks9fhw2v9s1 942515969
2.oracle自带函数转换sql_id to hash value
SQL> select dbms_utility.SQLID_TO_SQLHASH('a5ks9fhw2v9s1') hash_value FROM DUAL;
HASH_VALUE
----------
942515969
3.自己编写函数sql_id to hash value
SQL> CREATE OR REPLACE FUNCTION sql_id_2_hash_value (sql_id VARCHAR2)
2 RETURN NUMBER
3 IS
4 l_output NUMBER := 0;
5 BEGIN
6 SELECT TRUNC (
7 MOD (
8 SUM (
9 (INSTR ('0123456789abcdfghjkmnpqrstuvwxyz',
10 SUBSTR (LOWER (TRIM (sql_id)), LEVEL, 1))
11 - 1)
12 * POWER (32, LENGTH (TRIM (sql_id)) - LEVEL)),
13 POWER (2, 32)))
14 INTO l_output
15 FROM DUAL
16 CONNECT BY LEVEL <= LENGTH (TRIM (sql_id));
17 RETURN l_output;
18 END;
19 /
函数已创建。
SQL> select sql_id_2_hash_value('a5ks9fhw2v9s1') hash_value FROM DUAL;
HASH_VALUE
----------
942515969
4.hash value 转换为部分 sql_id
SQL> CREATE OR REPLACE FUNCTION hash_value_2_sql_id (p_hash_value NUMBER) 2 RETURN VARCHAR2 3 IS 4 l_output VARCHAR2 (8) := ''; 5 BEGIN 6 FOR i 7 IN ( SELECT SUBSTR ( 8 '0123456789abcdfghjkmnpqrstuvwxyz', 9 1 10 + FLOOR ( 11 MOD (p_hash_value / (POWER (32, LEVEL - 1)), 32)), 12 1) 13 sqlidchar 14 FROM DUAL 15 CONNECT BY LEVEL <= LN (p_hash_value) / LN (32) 16 ORDER BY LEVEL DESC) 17 LOOP 18 l_output := l_output || i.sqlidchar; 19 END LOOP; 20 21 RETURN l_output; 22 END; 23 / 函数已创建。 SQL> select hash_value_2_sql_id(942515969) from dual; HASH_VALUE_2_SQL_ID(942515969) -------------------------------------------------------- 2v9s1
参考:http://blog.tanelpoder.com/2009/02/22/sql_id-is-just-a-fancy-representation-of-hash-value/
发表在 Oracle
评论关闭
使用exp/imp 导入11g数据到9i
现在有个需求,需要使用exp/imp导入11g的数据库数据到9i中,解决这个问题一般来说想到三种方法思路,一个个尝试(其实从高版本服务端支持低版本客户端的原则,可以大概的猜测出使用9i的客户端处理该问题)
方法1:导出导入都使用11g客户端
--11g客户端导出 [oracle@xifenfei ~]$ exp chf/xifenfei file=/tmp/t_xifenfei.dmp >log=/tmp/t_xifenfei.log tables=chf.t_xifenfei Export: Release 11.2.0.3.0 - Production on Fri May 18 18:15:18 2012 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set server uses AL32UTF8 character set (possible charset conversion) About to export specified tables via Conventional Path ... . . exporting table T_XIFENFEI 2 rows exported Export terminated successfully without warnings. --11g客户端导入 [oracle@xifenfei ~]$ imp chf/xifenfei@ora9i file=/tmp/t_xifenfei_11g.dmp >log=/tmp/t_xifenfei.log tables=chf.t_xifenfei Import: Release 11.2.0.3.0 - Production on Fri May 18 18:17:24 2012 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. IMP-00058: ORACLE error 6550 encountered ORA-06550: line 1, column 33: PLS-00302: component 'SET_NO_OUTLINES' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored IMP-00000: Import terminated unsuccessfully
这个错误是版本不兼容导致:PLS-00302: component ‘SET_NO_OUTLINES’ must be declared
方法2:11g客户端导出,9i客户端导入
--11g客户端导出 [oracle@xifenfei ~]$ exp chf/xifenfei file=/tmp/t_xifenfei.dmp >log=/tmp/t_xifenfei.log tables=chf.t_xifenfei Export: Release 11.2.0.3.0 - Production on Fri May 18 18:15:18 2012 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set server uses AL32UTF8 character set (possible charset conversion) About to export specified tables via Conventional Path ... . . exporting table T_XIFENFEI 2 rows exported Export terminated successfully without warnings. --传输到9i [oracle@xifenfei tmp]$ scp t_xifenfei.dmp 192.168.1.10:/tmp/ The authenticity of host '192.168.1.10 (192.168.1.10)' can't be established. RSA key fingerprint is 3d:0c:d1:4b:45:bd:a3:f5:25:eb:4d:52:d2:32:03:69. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.1.10' (RSA) to the list of known hosts. oracle@192.168.1.10's password: t_xifenfei.dmp 100% 56KB 56.0KB/s 00:00 --9i客户端导入 [oracle@xifenfei ~]$ imp chf/xifenfei file=/tmp/t_xifenfei.dmp tables=t_xifenfei Import: Release 9.2.0.4.0 - Production on Thu May 24 23:32:18 2012 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to: Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.4.0 - Production IMP-00010: not a valid export file, header failed verification IMP-00000: Import terminated unsuccessfully --版本不兼容(高版本的dump文件低版本不能识别)
方法3:9i客户端导出,9i客户端导入
--9i客户端导出 [oracle@xifenfei ~]$ exp chf/xifenfei@ora11g file=/tmp/t_xifenfei_11g.dmp >log=/tmp/t_xifenfei.log tables=chf.t_xifenfei Export: Release 9.2.0.4.0 - Production on Thu May 24 23:37:20 2012 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set server uses AL32UTF8 character set (possible charset conversion) About to export specified tables via Conventional Path ... . . exporting table T_XIFENFEI 2 rows exported Export terminated successfully without warnings. --9i客户端导入 [oracle@xifenfei log]$ imp chf/xifenfei file=/tmp/t_xifenfei_11g.dmp log=/tmp/xifenfei.log full=y Import: Release 9.2.0.4.0 - Production on Fri May 25 03:22:14 2012 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to: Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.4.0 - Production Export file created by EXPORT:V09.02.00 via conventional path import done in ZHS16GBK character set and AL16UTF16 NCHAR character setSegmentation fault --导入数据遇到setSegmentation fault异常终止
解决setSegmentation fault异常终止
--修改exu9defpswitches视图 [oracle@xifenfei ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Fri May 18 22:29:00 2012 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> CREATE OR REPLACE VIEW exu9defpswitches ( 2 compflgs, nlslensem ) AS 3 SELECT a.value, b.value 4 FROM sys.v$parameter a, sys.v$parameter b 5 WHERE a.name = 'plsql_code_type' AND 6 b.name = 'nls_length_semantics' ; View created. --9i导出11g数据 [oracle@xifenfei tmp]$ exp chf/xifenfei@ora11g file=/tmp/t_xifenfei_11g.dmp >log=/tmp/xifenfei.log tables=t_xifenfei Export: Release 9.2.0.4.0 - Production on Fri May 25 04:08:32 2012 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set server uses AL32UTF8 character set (possible charset conversion) About to export specified tables via Conventional Path ... . . exporting table T_XIFENFEI 2 rows exported Export terminated successfully without warnings. --9i导入数据 [oracle@xifenfei tmp]$ imp chf/xifenfei file=/tmp/t_xifenfei_11g.dmp >log=/tmp/xifenfei.log tables=t_xifenfei Import: Release 9.2.0.4.0 - Production on Fri May 25 04:08:53 2012 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to: Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.4.0 - Production Export file created by EXPORT:V09.02.00 via conventional path import done in ZHS16GBK character set and AL16UTF16 NCHAR character set . importing CHF's objects into CHF . . importing table "T_XIFENFEI" 2 rows imported Import terminated successfully without warnings. --至此导入成功,完成了11gr2数据导入到9ir2中
通过一系列的实验证明,需要把11g的数据导入到9i中,需要使用9i的客户端进行,其中exu9defpswitches视图需要重建,否则会出现setSegmentation fault异常,导致导入失败.
Hanganalyze分析会话阻塞—锁表
前两篇分别大概的介绍了Systemstates分析会话阻塞—锁表和使用ass109.awk分析systemstate,这篇也大概的学习下hanganalyze.
模拟阻塞会话
--会话1
SQL> select * from v$version;
BANNER
-------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> select * from t_xifenfei;
ID NAME
---------- ----------------------------------------
1 xifenfei
2 www.xifenfei
SQL> delete from t_xifenfei where id=2;
1 row deleted.
--会话2
SQL> delete from t_xifenfei where id=2;
--hang住
做hanganalyze
--sys登录 SQL> ORADEBUG setmypid Statement processed. SQL> oradebug unlimit; Statement processed. SQL> oradebug hanganalyze 3 Hang Analysis in /u01/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_13719.trc
分析hanganalyze 文件
--HANG ANALYSIS基本信息
===============================================================================
HANG ANALYSIS:
instances (db_name.oracle_sid): ora11g.ora11g
oradebug_node_dump_level: 3
analysis initiated by oradebug
os thread scheduling delay history: (sampling every 1.000000 secs)
0.000000 secs at [ 15:53:16 ]
NOTE: scheduling delay has not been sampled for 0.356486 secs 0.000000 secs from [ 15:53:12 - 15:53:17 ], 5 sec avg
0.000000 secs from [ 15:52:17 - 15:53:17 ], 1 min avg
0.000000 secs from [ 15:48:17 - 15:53:17 ], 5 min avg
===============================================================================
Chains most likely to have caused the hang:
[a] Chain 1 Signature: 'SQL*Net message from client'<='enq: TX - row lock contention'
Chain 1 Signature Hash: 0x38c48850
===============================================================================
Non-intersecting chains:
-------------------------------------------------------------------------------
Chain 1:
-------------------------------------------------------------------------------
--被阻塞会话信息
Oracle session identified by:
{
instance: 1 (ora11g.ora11g)
os id: 13634
process id: 21, oracle@xifenfei (TNS V1-V3)
session id: 143
session serial #: 281
}
--等待信息
is waiting for 'enq: TX - row lock contention' with wait info:
{
p1: 'name|mode'=0x54580006
--54580006 is split into ASCII 54 + ASCII 58 (TX) + Mode 0006 (X) ... 在等待TX mode=6
p2: 'usn<<16 | slot'=0x20010
p3: 'sequence'=0x356
time in wait: 1 min 56 sec
timeout after: never
wait id: 24
blocking: 0 sessions
current sql: delete from t_xifenfei where id=2
short stack: --省略
wait history:
* time between current wait and wait #1: 0.001471 sec
1. event: 'SQL*Net message from client'
time waited: 10.776765 sec
wait id: 23 p1: 'driver id'=0x62657100
p2: '#bytes'=0x1
* time between wait #1 and #2: 0.000001 sec
2. event: 'SQL*Net message to client'
time waited: 0.000001 sec
wait id: 22 p1: 'driver id'=0x62657100
p2: '#bytes'=0x1
* time between wait #2 and #3: 0.000028 sec
3. event: 'SQL*Net message from client'
time waited: 0.000032 sec
wait id: 21 p1: 'driver id'=0x62657100
p2: '#bytes'=0x1
}
and is blocked by
=> Oracle session identified by:
--阻塞会话信息
{
instance: 1 (ora11g.ora11g)
os id: 13546
process id: 20, oracle@xifenfei (TNS V1-V3)
session id: 15
session serial #: 189
}
--该会话处于空闲状态
which is waiting for 'SQL*Net message from client' with wait info:
{
p1: 'driver id'=0x62657100
p2: '#bytes'=0x1
time in wait: 2 min 26 sec
timeout after: never
wait id: 29
blocking: 1 session
current sql: <none>
short stack: --省略
wait history:
* time between current wait and wait #1: 0.000019 sec
1. event: 'SQL*Net message to client'
time waited: 0.000007 sec
wait id: 28 p1: 'driver id'=0x62657100
p2: '#bytes'=0x1
* time between wait #1 and #2: 0.049656 sec
2. event: 'SQL*Net message from client'
time waited: 9.759067 sec
wait id: 27 p1: 'driver id'=0x62657100
p2: '#bytes'=0x1
* time between wait #2 and #3: 0.000216 sec
3. event: 'SQL*Net message to client'
time waited: 0.000002 sec
wait id: 26 p1: 'driver id'=0x62657100
p2: '#bytes'=0x1
}
Chain 1 Signature: 'SQL*Net message from client'<='enq: TX - row lock contention'
Chain 1 Signature Hash: 0x38c48850
-------------------------------------------------------------------------------
===============================================================================
通过上述分析:大概可以得出sid=143因为请求enq: TX - row lock contention(TX mode=6)被sid=15阻塞
查询视图验证
SQL> select sid,event from v$session where wait_class#<>6;
SID EVENT
---------- ------------------------------
20 SQL*Net message to client
143 enq: TX - row lock contention
SQL> select * from v$lock where type in('TX','TM');
ADDR KADDR SID TYPE ID1 ID2 LMODE REQUEST CTIME BLOCK
-------- -------- ---------- ---- ---------- ---------- ---------- ---------- ---------- ----------
352F8BEC 352F8C18 143 TX 131088 854 0 6 1862 0
B6B9C7A8 B6B9C7D8 15 TM 75928 0 3 0 1892 0
B6B9C7A8 B6B9C7D8 143 TM 75928 0 3 0 1862 0
343C0E54 343C0E94 15 TX 131088 854 6 0 1892 1
--查询结果sid=15的会话持有TX MODE=6阻塞sid=143的TX MODE=6的请求,和HANG ANALYSIS分析基本一致
参考文档:USING AND READING HANGANALYZE或者[ID 215858.1]
发表在 Oracle性能优化
评论关闭

加我微信(17813235971)
加我QQ(107644445)

