标签云
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使用说明
分类目录归档:数据库
TTS实现跨版本迁移数据
以前对Transportable Tablespaces(TTS)一直理解不深,今天无意中看到TTS可以实现数据库升级,今天测试了实现使用TTS 迁移9.2.0.4的一个表空间到11.2.0.3,平台均为Linux 32位
源端版本
SQL> select * from v$version; BANNER ---------------------------------------------------------------- Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production PL/SQL Release 9.2.0.4.0 - Production CORE 9.2.0.3.0 Production TNS for Linux: Version 9.2.0.4.0 - Production NLSRTL Version 9.2.0.4.0 - Production
创建测试环境
SQL> create tablespace tts_xff
2 datafile '/u01/oracle/oradata/xifenfei/tts_xifenfei01.dbf' size 10m autoextend on next 10m,
3 '/u01/oracle/oradata/xifenfei/tts_xifenfei02.dbf' size 10m autoextend on next 10m
4 ;
Tablespace created.
SQL> create user tts_xff identified by xifenfei;
User created.
SQL> grant dba to tts_xff;
Grant succeeded.
SQL> conn tts_xff/xifenfei
Connected.
SQL> create table t1 tablespace tts_xff
2 as
3 select * from dba_objects;
Table created.
SQL> create table t2 tablespace tts_xff
2 as
3 select * from dba_objects;
Table created.
SQL> create table t_xifenfei tablespace tts_xff
2 as
3 select * from dba_objects;
Table created.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
T1 TABLE
T2 TABLE
T_XIFENFEI TABLE
SQL> select count(*) from t1;
COUNT(*)
----------
30805
SQL> conn / as sysdba
Connected.
SQL> alter tablespace tts_xff read only;
Tablespace altered.
导出并传输测试表空间
[oracle@xifenfei ~]$ exp userid=\'/ as sysdba\' tablespaces=tts_xff file=/tmp/tts_xff.dmp transport_tablespace=y Export: Release 9.2.0.4.0 - Production on Sun Oct 7 04:53:25 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 done in ZHS16GBK character set and AL16UTF16 NCHAR character set Note: table data (rows) will not be exported About to export transportable tablespace metadata... For tablespace TTS_XFF ... . exporting cluster definitions . exporting table definitions . . exporting table T1 . . exporting table T2 . . exporting table T_XIFENFEI . exporting referential integrity constraints . exporting triggers . end transportable tablespace metadata export Export terminated successfully without warnings. [oracle@xifenfei ~]$ scp /tmp/tts_xff.dmp 192.168.1.10:/tmp/ oracle@192.168.1.10's password: tts_xff.dmp 100% 16KB 16.0KB/s 00:00 [oracle@xifenfei ~]$ scp /u01/oracle/oradata/xifenfei/tts_xifenfei* 192.168.1.10:/u01/oracle/oradata/ora11g/ oracle@192.168.1.10's password: tts_xifenfei01.dbf 100% 10MB 3.3MB/s 00:03 tts_xifenfei02.dbf 100% 10MB 5.0MB/s 00:02
目标库版本
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> create user tts_11g identified by xifenfei; User created. SQL> grant dba to tts_11g; Grant succeeded.
导入表空间
[oracle@xifenfei ~]$ imp userid=\'/ as sysdba\' tablespaces=tts_xff file=/tmp/tts_xff.dmp > transport_tablespace=y datafiles=/u01/oracle/oradata/ora11g/tts_xifenfei01.dbf, > /u01/oracle/oradata/ora11g/tts_xifenfei02.dbf fromuser=tts_xff touser=tts_11g Import: Release 11.2.0.3.0 - Production on Sat Sep 29 04:18:04 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 file created by EXPORT:V09.02.00 via conventional path About to import transportable tablespace(s) metadata... import done in ZHS16GBK character set and AL16UTF16 NCHAR character set . importing TTS_XFF's objects into TTS_11G . . importing table "T1" . . importing table "T2" . . importing table "T_XIFENFEI" Import terminated successfully without warnings.
测试数据
SQL> alter tablespace tts_xff read write;
Tablespace altered.
SQL> conn tts_11g/xifenfei
Connected.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
T1 TABLE
T2 TABLE
T_XIFENFEI TABLE
SQL> select count(*) from t1;
COUNT(*)
----------
30805
SQL> delete from t1;
30805 rows deleted.
SQL> commit;
Commit complete.
至此测试完成,证明使用tts可以实现跨版本迁移数据
补充说明
1.10g及其以上版本可以实现不同平台的tts迁移,可能需要使用rman convert转换
2.迁移前需要使用 EXECUTE DBMS_TTS.TRANSPORT_SET_CHECK检测依赖性
发表在 Oracle
评论关闭
如何查询会话 event
很多时候,我们在数据库中设置了event,如何确认设置的event生效或者如何确认你的库中设置了什么event.下面的文章测试了在11g中比较方便的方法
数据库版本
SQL> select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production PL/SQL Release 11.2.0.3.0 - Production CORE 11.2.0.3.0 Production TNS for Solaris: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3.0 - Production
设置测试event
SQL> alter session set events '10510 trace name context forever,level 1'; Session altered. SQL> alter session set events 2 '10046 trace name context forever,level 4'; Session altered. SQL> alter system set events '60025 trace name context forever'; System altered. SQL> alter system set events '10513 trace name context forever,level 2'; System altered.
测试spfile参数中是否有event
SQL> create pfile='/tmp/pfile' from spfile; File created. solaris*orcl-/home/oracle$ grep -i event /tmp/pfile --无记录 SQL> show parameter event; NAME TYPE VALUE ------------------------------------ ----------- ----------------- event string xml_db_events string enable
证明设置event不会在spfile中记录
查询会话event
--dbms_system实现
SQL> set serveroutput on size 1000000
SQL> declare
2 event_level number;
3 begin
4 for i in 1..100000 loop
5 sys.dbms_system.read_ev(i,event_level);
6 if (event_level > 0) then
7 dbms_output.put_line('Event '||to_char(i)||' set at level '||
8 to_char(event_level));
9 end if;
10 end loop;
11 end;
12 /
Event 10510 set at level 1
Event 10513 set at level 2
Event 60025 set at level 1
PL/SQL procedure successfully completed.
--oradebug实现
SQL> oradebug SETMYPID
Statement processed.
SQL> oradebug eventdump session
10510 trace name context forever,level 1
10513 trace name context forever,level 2
60025 trace name context forever
sql_trace level=4
测试证明使用dbms_system可以捕获到event,oradebug可以捕获到本身会话,还可以通过setospid/setorapid来跟踪其他会话的event设置情况.event 10046对应的本质是sql_trace所以使用dbms_system不能捕获到10046
发表在 Oracle
评论关闭
commit后lob字段使用临时表空间未释放
临时表空间被使用现状
接到客户反馈,他们的数据库使用了长连接,临时表空间使用率一直不下降,一个会话占用了几百M甚至几个G的临时表空间不释放,随着时间的积累,会话占用的临时表空间还在继续增加,最终的现象是100G的数据文件,160G的临时表空间还在继续报临时表空间不足.查询v$sort_usage发现其SEGTYPE全部为LOB_DATA而CONTENTS为TEMPORARY,而且BLOCKS都很大,通过上面的信息大概分析,怀疑是因为数据库查询或者操作LOB类型时候使用了TEMPORARY,但是没有释放导致
相关版本信息
OS:AIX 6.1(64) DB:10.2.0.5
测试案例证明
--执行查询脚本
$ more check.sql
connect / as sysdba
select * from v$tempseg_usage where username not in ('HDDS_CLPS_DTA','FOGLIGHT');
--测试脚本1
$ more test1.sh
sqlplus /nolog <<EOF
connect / as sysdba
drop user xifenfei cascade;
create user xifenfei identified by tc
default tablespace users temporary tablespace temp quota unlimited on users;
grant connect,resource,alter session to xifenfei;
revoke unlimited tablespace from xifenfei;
connect xifenfei/tc
select to_nclob('a') from dual;
!sqlplus /nolog @check
commit;
!sqlplus /nolog @check
EOF
--测试脚本2
$ more test2.sh
sqlplus /nolog << EOF2
connect xifenfei/tc
alter session set events '60025 trace name context forever';
select to_nclob('a') from dual;
!sqlplus /nolog @check
commit;
!sqlplus /nolog @check
EOF2
测试结果
$ ./test1.sh
SQL*Plus: Release 10.2.0.5.0 - Production on Fri Oct 12 10:04:39 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
SQL> Connected.
SQL> drop user xifenfei cascade
*
ERROR at line 1:
ORA-01918: user 'XIFENFEI' does not exist
Grant succeeded.
SQL>
Revoke succeeded.
SQL> SQL> SQL> Connected.
SQL>
TO_NCLOB('A')
--------------------------------------------------------------------------------
a
SQL> SQL>
SQL*Plus: Release 10.2.0.5.0 - Production on Fri Oct 12 10:04:39 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected.
USERNAME USER SESSION_ADDR
------------------------------ ------------------------------ ----------------
SESSION_NUM SQLADDR SQLHASH SQL_ID
----------- ---------------- ---------- -------------
TABLESPACE CONTENTS SEGTYPE SEGFILE# SEGBLK#
------------------------------- --------- --------- ---------- ----------
EXTENTS BLOCKS SEGRFNO#
---------- ---------- ----------
xifenfei xifenfei 07000002F96ECB30
10152 07000002AE1C36E0 1362191183 9z69tsx8m2sug
TEMP TEMPORARY LOB_DATA 201 3465
1 128 1
SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> SQL>
Commit complete.
SQL> SQL>
SQL*Plus: Release 10.2.0.5.0 - Production on Fri Oct 12 10:04:39 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected.
USERNAME USER SESSION_ADDR
------------------------------ ------------------------------ ----------------
SESSION_NUM SQLADDR SQLHASH SQL_ID
----------- ---------------- ---------- -------------
TABLESPACE CONTENTS SEGTYPE SEGFILE# SEGBLK#
------------------------------- --------- --------- ---------- ----------
EXTENTS BLOCKS SEGRFNO#
---------- ---------- ----------
xifenfei xifenfei 07000002F96ECB30
10152 07000002AE1C36E0 1362191183 9z69tsx8m2sug
TEMP TEMPORARY LOB_DATA 201 3465
1 128 1
SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
--测试脚本2
$ ./test2.sh
SQL*Plus: Release 10.2.0.5.0 - Production on Fri Oct 12 10:03:56 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
SQL> Connected.
SQL>
Session altered.
SQL>
TO_NCLOB('A')
--------------------------------------------------------------------------------
a
SQL> SQL>
SQL*Plus: Release 10.2.0.5.0 - Production on Fri Oct 12 10:03:56 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected.
no rows selected
SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> SQL>
Commit complete.
SQL> SQL>
SQL*Plus: Release 10.2.0.5.0 - Production on Fri Oct 12 10:03:56 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected.
no rows selected
SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
1.Without event 60025 set (before and after commit):都出现v$tempseg_usage中存在对应记录,而且提交后不能释放Temp LOB space
2.With event 60025 set (before and after commit):都未现v$tempseg_usage中存在对应记录,证明提交后释放Temp LOB space
解决方案
通过上面的试验证明我们可以通过设置event 60025来解决该版本的会话提交后Temp LOB space不能被回收的问题.
我们可以通过在session级别使用”alter session set events ’60025 trace name context forever’;”来实现。如果想实现全库级别的,但是因为event 60025不能通过system设置生效,所以我们可以通过logon触发器来实现该功能
create or replace trigger sys.login_db after logon on database begin execute immediate 'alter session set events ''60025 trace name context forever'''; end; /
注意这个是ORCLE bug(Bug 5723140 – Temp LOB space not released after commit [ID 5723140.8]),从10.2.0.4开始虽然已经修复了该bug,但是默认情况下:为了更加高效的利用temp,在session未断开前,不自动释放temp 空间,可以通过设置event 60025来强制会话在commit之后就立即释放temp space

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

