The setting for the SHARED_POOL_SIZE parameter determines the amount of memory required to manage the instance. The setting for this parameter is also used to determine the amount of space that is allocated for extent storage. The default value for this parameter is suitable for most ASM environments.
如果你的系统中,通过statspack report或awr report,发现这样的SQL执行比较频繁,而且test表的记录数比较多,test表中附合status = '1'的记录数也非常多,占test表记录数90%的比例吧,从statspack report或awr report可以发现该SQL的逻辑读会相当大,假定该表没有任何索引,那DBA该如何着手进行SQL的优化呢? SELECT seller_id FROM (SELECT * FROM (SELECT seller_id, max(gmt_create) FROM test WHERE status = 1 GROUP BY seller_id) ORDER BY gmt_create DESC) WHERE rownum <= 10;
五 如何在DB中配置DRCP? 在11g中,系统默认包含了一个连接池:SYS_DEFAULT_CONNECTION_POOL,这个池默认被创建,但默认该池是不启动的,如果要启动默认的连接池,必须显式地执行启动DRCP的命令,oracle提供dbms_connection_pool package来执行这个工作,如果连接池被显式地启动,必须显式地被停掉,当实例宕掉时,如果DRCP是活动的,则实例启动时,DRCP也将自动实动。 启动DRCP需要以下步骤: A 用sysdba权限连接到sqlplus B 执行exec dbms_connection_pool.start_pool(); C 查看DRCP的状态
三Dedicated Servers,Shared Servers与DRCP的内存需求 一般情况下,由于每个会话需要消耗400k的内存,每个进程需要消耗4m的内存,现在我们以DRCP的pool size是100,shared server的shared server进程是100为例,假如有5000个客户端连接到这些环境,则这些主机的内存分配如下: A Dedicated Server Memory used = 5000 X (400 KB + 4 MB) = 22 GB B Shared Server Memory used = 5000 X 400 KB + 100 X 4 MB = 2.5 GB Out of the 2.5 GB, 2 GB is allocated from the SGA. C Database Resident Connection Pooling Memory used = 100 X (400 KB + 4 MB) + (5000 X 35KB)= 615 MB
"OPT_PARAM" is a new optimizer hint introduced in 10g Release 2. This hint behaves the same way as setting a parameter (e.g, using alter session) except that the effect is for the statement only.where parameter_name is the name of a parameter and parameter_value is its value. If the parameter contains a numeric value, the parameter value has to be specified without quotes.
The syntax is:opt_param(<parameter_name> [,] <parameter_value>). For example:/*+ opt_param('hash_join_enabled','false') */
V$SESSION_WAIT_HISTORY displays the last 10 wait events for each active session,这是10gR2中reference对该动态性能视的介绍,从该动态性能视图中追溯活动会话最后10个等待事件,如果我们想追溯活动会话更多的等待事件,那该如何实现呢?
Errors in file /opt/oracle/admin/dbtest/udump/dbtest_ora_14166.trc: ORA-00604: error occurred at recursive SQL level 1 ORA-12663: Services required by client not available on the server ORA-36961: Oracle OLAP is not available. ORA-06512: at "SYS.OLAPIHISTORYRETENTION", line 1 ORA-06512: at line 15 Wed Oct 25 12:34:50 2006 Completed: ALTER DATABASE OPEN
昨晚收到短信报警,有两台DB报ORA-00020错误,如果你不太清楚ORA-20代表了什么,在linux/unix平台下,可以用oerr ora 20来查看它比较详细的错误代码;在生产环境中,processes参数一般都设置的比实际的processes多一些,所以DB一旦报ORA-20错误,基本上可以确定是程序出了问题,那该如何着手解决呢?
当我们rebuild index online失败后,smon进程会清除sys_journal_xxx(xxx是object_id)以及其它的不一致的东西,在smon清除它们之前,是不能再进行rebuild index online的,如果要清除它们,需要执行dbms_repare包的online_index_clean过程来处理...
DEPRECATION OF RAW DEVICES IN LINUX 2.6 KERNELS -----------------------------------------------
Starting with the 2.6 Linux kernel, raw devices are being phased out in favor of O_DIRECT access directly to the block devices.
With Oracle RDBMS 10.2.0.2 and higher, block devices can be accessed via any of the following methods, and utilized by RDBMS:
- Directly to the block device - Via ASMLib mapped devices - OCFS2 devices (Note: OCFS2 is still Pending Certification) - LVM2 mapped devices if single-instance
1. Character devices are read and written directly without buffering.
2. Block devices can only be written to and read from in multiples of the block size, typically 512 or 1024 bytes. Block devices are accessed via the buffer cache and may be randomly accessed, that is to say, any block can be read or written no matter where it is on the device. Block devices can be accessed via their device special file but more commonly they are accessed via the file system. Only a block device can support a mounted file system.
3. Network devices are accessed via the BSD socket interface and the networking subsytems described in the Networking chapter.
The Raw devices are character devices (major number 162).
oerr ora 19573 19573, 00000, "cannot obtain %s enqueue for datafile %s" // *Cause: The file access enqueue could not be obtained for a file // specified in a backup, copy or restore operation. // If the enqueue type shown is 'shared', then the file is the // input file for a backup or copy. If the type is 'exclusive', then // the file is the output file for a datafile copy or restore which // is attempting to overwrite the currently active version of that // file - in this case, the file must be offline or the database must // be closed. If the type is 'read-only', then you are attempting // to back up or copy this file while the database is in NOARCHIVELOG // mode. // *Action: Wait until the conflicting operation is complete, then retry // the copy or backup. If the database is in NOARCHIVELOG mode, then // all files being backed up must be closed cleanly.
rem --------------------------------------------------- rem Filename: ctlimits.sql rem Purpose: List control file structures with usage limits rem Date: 21-Sep-2000 rem Author: Frank Naude, Oracle FAQ rem ---------------------------------------------------
set pages 50000 col PCT_USED format 990.09
-- Controlfile creation parameters: -- Type DATAFILE is for MAXDATAFILES -- Type REDO LOG is for MAXLOGFILES -- Type LOG HISTORY is for MAXLOGHISTORY -- Type REDO THREAD is for MAXINSTANCES -- No entry for MAXLOGMEMBERS (?)
You can now use OUI to clone RAC nodes and clusterware. The R2 Oracle Universal Installer comes with a perl script, $ORACLE_HOME/clone/bin/clone.pl, which automates the cloning process. A companion script, prepare_clone.pl, prepares the source ORACLE_HOME for cloning by archiving and compressing it; you copy the files over yourself, unarchive, and run clone.pl.
o In Oracle8i, release 8.1, we could use java to run a system command with an "&" after it (assuming unix) or perhaps "start xxx.cmd" if using NT.
o In Oracle8.0 and up, we can write an external procedure in C that runs host commands with system() and the "&". (see attached for an external procedure example)
o In Oracle7.0 and up, we can use dbms_pipes to talk to a daemon running outside the database. Here is a simple example that uses sqlplus to be the daemon:
A quick and dirty way to do this is with a csh script and sqlplus as such (cut and pasted from another email)
Ok, so can you do this without C? Yes. Here is a PL/SQL subroutine you can install in your schema:
Oracle Database 10 genhances the data collection mechanism with the introduction of the Automatic Workload Repository and Active Session History, which replace the previous performance data gathering tools such as Statspack and utlbstat/utlestat. The major differences between the current repositories from previous such tools include the following:
The MMON (Manageability Monitor) process is responsible for various manageability tasks such as taking snapshots of various statistical information at prescribed time intervals and issuing alerts when metric values exceed defined thresholds. The MMON process can spawn multiple slave processes to perform these tasks. The MMNL (the Manageability Monitor—Lightweight) process is responsible for computing various metrics and taking snapshots of active sessions at every second.We’ll discuss this further in the section “Active Session History.”
SQL Profile Enhancements This feature allows SQL Profile to match SQL text after literal values have been normalized into bind variables.SQL Profile has been enhanced to allow applications to use literal values rather than bind variables.
Distributed LOBs support provides easy-to-use and efficient support for accessing unstructured data in a distributed environment. The data interface for LOBs can now INSERT, UPDATE, and SELECT LOBs across dblinks.The benefit of this new support is the ability to access remote LOBs.
1 可加密的备份集 2 闪回数据库增强(可跨过open resetlogs) 3 Restore Points 4 Guaranteed Restore Points 5 Incremental Roll Forward of Database Copy 6 Easy Conversion of Physical Standby Database to a Reporting Database 7 Database Transport Across Same Endian Platforms 8 Transportable Tablespaces from Backup 9 Unused Block Compression 10 Temporary Datafiles Are Re-Created on RMAN Recovery 11 Support for Backup Vaulting in Media Managers 12 Backup and Recovery Enhancements in Enterprise Manager
SQL> select * from test_0210; ID NAME AGE ---------- -------------------------------- ---------- 1 abc 32 2 def 33 3 def 45 要求的结果: ID NAME AGE ---------- -------------------------------- ---------- 2 def 33 3 def 45
---------------- showsql.sql -------------------------- column status format a10 set feedback off set serveroutput on
select username, sid, serial#, process, status from v$session where username is not null /
column username format a20 column sql_text format a55 word_wrapped
set serveroutput on size 1000000 declare x number; begin for x in ( select username||'('||sid||','||serial#|| ') ospid = ' || process || ' program = ' || program username, to_char(LOGON_TIME,' Day HH24:MI') logon_time, to_char(sysdate,' Day HH24:MI') current_time, sql_address, LAST_CALL_ET from v$session where status = 'ACTIVE' and rawtohex(sql_address) <> '00' and username is not null order by last_call_et ) loop for y in ( select max(decode(piece,0,sql_text,null)) || max(decode(piece,1,sql_text,null)) || max(decode(piece,2,sql_text,null)) || max(decode(piece,3,sql_text,null)) sql_text from v$sqltext_with_newlines where address = x.sql_address and piece < 4) loop if ( y.sql_text not like '%listener.get_cmd%' and y.sql_text not like '%RAWTOHEX(SQL_ADDRESS)%') then dbms_output.put_line( '--------------------' ); dbms_output.put_line( x.username ); dbms_output.put_line( x.logon_time || ' ' || x.current_time|| ' last et = ' || x.LAST_CALL_ET); dbms_output.put_line( substr( y.sql_text, 1, 250 ) ); end if; end loop; end loop; end;
大约 7 年前,Oracle 发布了 Linux 上的第一个商业数据库。从那时起,Oracle、Red Hat 和 Novell/SUSE 就不断地合作更改 Linux 内核,从而提高数据库和应用程序的性能。正因为这样,用于 Linux 的 Oracle 数据库 10g 才包含了与操作系统紧密相关的许多增强功能。DBA 比以往任何时候更需要了解和使用此平台来在其监视下对系统进行最佳管理。
declare type rec_name is record (lastname varchar2(32), firstname varchar2(32)); type var_array is table of rec_name; v_rec rec_name; v_arr var_array := var_array(); begin v_arr.extend; v_rec.lastname := 'abc'; v_rec.firstname := 'def'; v_arr(1) := v_rec; dbms_output.put_line(v_arr(1).lastname); end;
Let's say you are tying to resolve some performance issues in the production databases. As you saw elsewhere in this article, the AWR data is vital for the analysis. However, analyzing AWR data during a normal production run may not be desirable or even feasible. Rather, you may want to load the data in some central location for comparative analysis. How can you do that?
If a session is not doing what it is supposed to do, or is doing it slowly, the first step for most DBAs is to check the wait events. To build a profile, you may also want to trace the session over an extended period, which produces a trace file in the user_dump_dest directory. Now, imagine that you have been using end-to-end tracing on several sessions for some time but now you have no idea which sessions have tracing turned on. How do you find out?
Like numerous other DBAs, I fell in love with RMAN soon after it was introduced in Oracle8. Nevertheless, I never felt that I understood its activities as thoroughly as I should. In Oracle Database 10g Release 2, the new dynamic views provided for RMAN jobs make it extremely easy to peek into these activities—current as well as past.
Many DBAs, of course, still like to use the command line and write scripts. OSB provides a command line tool called obtool. You can invoke the command line version of the tool by typing: obtool which brings up the OSB prompt ob>. You can type "help" here to see the commands available.
DBMS_FILE_TRANSFER Package in Oracle Database 10g,Oracle 10g has introduced the DBMS_FILE_TRANSFER package which provides an API for copying binary files between database servers.
Common Usage Notes
COPY_FILE
GET_FILE
PUT_FILE
Common Usage Notes,All of the the currently supported procedures have some common usage notes listed below:
The user must have read privilege on the source directory object and write privilege on the destination directory object. The procedure converts directory object names to uppercase unless they are surrounded by double quotes. Files to be copied must be multiples of 512 bytes in size. Files to be copied must be equal to or less than 2 terabytes in size. File transfers are not transactional. Files are copied as binary, so no character conversions are performed. File copies can be monitored using the V$SESSION_LONGOPS view. 查看全文
Introduction ========== Performance tuning and problem diagnosis are the two most challenging and important management tasks that any database administrator erforms. In line with the primary drive of the server manageability effort, the Autometic Database Diagnostic Monitor (ADDM) attempts to make, performing these two tasks, a lot simpler and easier. ADDM employs an iterative top-down approach and drives a rule-based expert system, to identify bottlenecks in a system and suggest relevant recommendations to tackle them.
在10gR2中,提供了$ORACLE_HOME/rdbms/admin/sqltrpt.sql脚本,用于抽取占用资源较多的sql,并可以为指定的sql生成执行计划,资源占用较多的sql分为两部分 1 15 Most expensive SQL in the cursor cache 2 15 Most expensive SQL in the workload repository
Historically, in trying to achieve maximum database performance, Oracle DBAs and performance analysts have fought an uphill battle to obtain solid response time metrics for system as well as user session activity. The problem facing DBAs has always had two facets: first, determining exactly "where" the database or user sessions have been spending their time; and second, determining the objective nature of the user experience
Memory-attached SGA query (Arup's favorite Release 2 feature) tops this list, but optimizer statistics management, the new "compare periods" report, and other new features are equally compelling.
The Self-Managing Database becomes even more so with an Automatic Storage Management command-line tool, direct-attached SGA access, support for online partition redefinition, and more.
Transparent Data Encryption and XQuery support are the two major new SQL-related features in Oracle Database 10g Release 2, but the list doesn't end there.
最近有个新项目,从老项目中迁移数据,由于新项目其实是从老项目重构的,所以表结构完全不同,但功能是差不多的,所以我在迁移这些数据时,先创建好表结构及索引,然后再用insert into select from的方式导入数据,发现在批量装入数据时,数据与索引的维护是分离的,开始装载数据时,索引表空间没有任何变化,当数据装载完毕后,索引表空间才开始变化,这样看来,那这样应该比insert into select from后再创建索引要更节省时间。
asktom关于v$open_cursor的解释 ops$tkyte@ORA817DEV.US.ORACLE.COM> select sql_text from v$open_cursor where user_name = user and sql_text like 'table%'; no rows selected ops$tkyte@ORA817DEV.US.ORACLE.COM> create or replace type myTableType as table of number / Type created. ops$tkyte@ORA817DEV.US.ORACLE.COM> select sql_text from v$open_cursor where user_name = user and sql_text like 'table%'; SQL_TEXT ------------------------------------------------------------ table_1_0_10e_0_0_0
Ah-Hah -- there we go, we have that mysterious statement in there. Its all about nested table types.. ops$tkyte@ORA817DEV.US.ORACLE.COM> create table t ( x int, y myTableType ) nested table y store as y_tab; Table created. ops$tkyte@ORA817DEV.US.ORACLE.COM> select sql_text from v$open_cursor where user_name = user and sql_text like 'table%'; SQL_TEXT ------------------------------------------------------------ table_1_0_10e_0_0_0 table_1_0_116_0_0_0 table_1_0_112_0_0_0 and now we have MORE of them.. ops$tkyte@ORA817DEV.US.ORACLE.COM> insert into t values ( 1, myTableType( 1, 2,3 ) ); 1 row created. ops$tkyte@ORA817DEV.US.ORACLE.COM> select sql_text 2 from v$open_cursor 3 where user_name = user and sql_text like 'table%'; SQL_TEXT ------------------------------------------------------------ table_1_0_10e_0_0_0 table_1_0_116_0_0_0 table_1_0_112_0_0_0 ops$tkyte@ORA817DEV.US.ORACLE.COM> ops$tkyte@ORA817DEV.US.ORACLE.COM> select * from t; MYTABLETYPE(1, 2, 3)
so, they are a natural side effect of using nested tables. Now, why are the "open" -- well, they use the same cursor sharing technique as PLSQL does. In PLSQL when you close a cursor -- it'll still (most likely) be there in v$open_cursor which should really be called "v$MOST_LIKELY_STILL_open_cursor" -- the cursors for the nested table access are still there but -- they are replaceable -- they will go away if someone else needs that slot (eg: they do not count against your open_cursor init.ora setting)
So, thats the mystery here, they are implicit sql (magic sql apparently) to do with nested table types. They will go away as their slots are needed, they are not "leaked" cursors (which is probably what you were looking for).
1) set transaction use rollback segment system (this is VERY important, otherwise database loss can occur) (2) select * from dba_2pc_pending where state='collecting'; (3) for each local_tran_id in selected rows, delete where local_tran_id is that value from the following tables: dba_2pc_pending pending_sessions$ pending_sub_sessions$
开始脑筋,优化原来如此简单 SELECT COUNT(*) FROM BMW_ABCD t WHERE t.USER_NICK = :1 AND t.ACTION_ID = :2;
下面显示的是表的结构与索引情况,很明显,该表的USER_NICK字段没有索引, ACTION_ID虽然有索引,但它不是组合索引的前导字段,所以这个sql必然会全表扫描, 即使通过hints让action_id走组合索引进行跳跃扫描的话,性能也不会很好, 由于通过user_nick进行扫描的查询不多,没有必要为这个字段创建索引, 但可以与bmw_XYZ表做关联 11:52:35 SQL> desc bmw_abcd Name Null? Type ----------------------------- -------- ---------------- ID NOT NULL NUMBER(11) USER_NICK NOT NULL VARCHAR2(32) USER_ID NOT NULL VARCHAR2(32) ACTION_ID NUMBER(8) ....
11:51:07 SQL> @list_index Enter value for table_name: bmw_abcd INDEX_NAME COLUMN_NAME COLUMN_POSITION STATUS TABLESPACE_NAME ------------------------------ ------------------------------ IND_BMW_ABCD_USER_ACTION_ID USER_ID 1 VALID TBS_INDEX1 IND_BMW_ABCD_USER_ACTION_ID ACTION_ID 2 VALID TBS_INDEX1
12:13:52 SQL> explain plan for SELECT COUNT(*) FROM BMW_ABCD t WHERE t.USER_NICK = :1 AND t.ACTION_ID = :2; 12:13:58 SQL> @plan PLAN_TABLE_OUTPUT ---------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost | ---------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 101 | 3705 | | 1 | SORT AGGREGATE | | 1 | 101 | | |* 2 | TABLE ACCESS FULL | BMW_ABCD | 429 | 43329 | 3705 | ----------------------------------------------- 新修改后的sql如下所示,执行计划相当好. SELECT COUNT(*) FROM BMW_ABCD t,BMW_USERS bu WHERE bu.NICK = :1 AND t.user_id = bu.id AND t.ACTION_ID = :2 -----------------------------------------------
update tbf_thread set thread_type = 3 where thread_type <> 3 and ((valid_start_date is null and sysdate - creation_date > 90) or (valid_start_date is not null and sysdate - valid_start_date > 90)) 拿到这个sql后,由于表是我创建的,知道这个表上在thread_type字段上有索引, 该索引的取值是1,2,3,但99%的贴子集中在3上面,第一印象看,需要将<>3改为<3, 这样就会走thread_type,实际测试后,发现从7分钟减少到45second,但由于该表 的访问相当频繁,但这个sql执行频繁却不高,每天一次,如果在一次作业过程中, 产生大量的锁也是很讨厌的,然后再分析表结构,发现valid_start_date是设计时 就不允许为空,所以可以精简为如下所示. update tbf_thread set thread_type = 3 where thread_type < 3 and (sysdate - creation_date > 90 or sysdate - valid_start_date > 90) 由于目前这个表的tbf_thread的creation_date与valid_start_date都没有索引,所以 不管它怎么写都是一样的,但如果考虑到后来会创建索引或者为了符合一般的sql编写 规范的话,还可以继续改为如下所示. update tbf_thread set thread_type = 3 where thread_type < 3 and (creation_date < sysdate - 90 or valid_start_date < sysdate - 90) 到为这个步聚,就已经比较明了啦,然后分析业务,发现可以将create_date这个条件去 掉,然后就成最终的sql语句啦,按将来的业务看,每次执行时要更新10w甚至更多些的的 记录,根据我们的访问量,即使在1分钟内完成,也会产生大量的锁. update tbf_thread set thread_type = 3 where thread_type < 3 and valid_start_date < sysdate - 90 为了彻底地减少锁,将这个sql用pl/sql来实现,批量进行提交,虽然效率降低了,但系统 的锁可以尽大限度地消除lock: create or replace procedure sp_update_thread(v_count number default 200) as cursor cur_threads is select thread_id from tbf_thread where thread_type < 3 and valid_start_date < sysdate - 90; begin for cur_row in cur_threads loop update tbf_thread set thread_type=3 where thread_id = cur_row.thread_id; if mod(cur_threads%rowcount,v_count) = 0 then commit; end if; end loop; commit; end;
logminer在10g的一个改进 当你在10g中执行dbms_logmnr_d的set_tablespace('&ts_name')过程后, 你可以到alter_sid.log中看看,你会发现一些输出信息,与logminer相关 的字典表的索引失效,系统会监控并写入alert_sid.log,然后会对这些字 共表的失效索引进行rebuild,比9i要更人性化一些. Some indexes or index [sub]partitions of table SYSTEM.LOGMNR_ATTRCOL$ have been marked unusable ... Indexes of table SYSTEM.LOGMNR_ATTRCOL$ have been rebuilt and are now usable
CONSTRAINT_NAME C COLUMN_NAME POSITION STATUS VALIDATED ------------------------------ - ------------------------------ ---------- -------- ------------- PK_POINT_BALANCE_BALANCE_ID P BALANCE_ID 1 ENABLED VALIDATED
SQL> select count(*) from tbf_userperm;
COUNT(*) ---------- 6
SQL> alter table tbf_userperm move;
Table altered.
SQL> @list_index Enter value for table_name: tbf_userperm
CONSTRAINT_NAME C COLUMN_NAME POSITION STATUS VALIDATED ------------------------------ - ------------------------------ ---------- -------- ------------- PK_USERPERM_USERPERM_ID P USERPERM_ID 1 ENABLED VALIDATED
(1) set transaction use rollback segment system (this is VERY important, otherwise database loss can occur) (2) select * from dbc_2pc_pending where state='collecting'; (3) for each local_tran_id in selected rows, delete where local_tran_id is that value from the following tables: dba_2pc_pending pending_sessions$ pending_sub_sessions$
Note: For additional ORA-600 related information please read Note 146580.1
PURPOSE: This article discusses the internal error "ORA-600 [729]", what it means and possible actions. The information here is only applicable to the versions listed and is provided only for guidance.
ERROR: ORA-600 [729] [a]
VERSIONS: versions 7.0 to 10.1
DESCRIPTION:
A space leak has been detected in the User Global Area (UGA).
There is NO data corruption as a result of this error.
It is an internal memory housekeeping problem.
ARGUMENTS: Arg [a] This is the number of bytes leaked
FUNCTIONALITY: MEMORY COMPONENT
IMPACT: PROCESS FAILURE - But only during logoff so impact is minimal. NON CORRUPTIVE - No underlying data corruption.
SUGGESTIONS:
Event 10262 can be set to safely ignore small memory leaks.
Set the following in init.ora for example to disable space leaks less than 4000 bytes:
event = "10262 trace name context forever, level 4000"
and stop and restart the database.
Repeated errors or large memory leaks can be diagnosed further by sending the alert.log and trace files to Oracle support.
Please note that if you are running Oracle 8.1.7.3, then there is every chance that you have encountered Bug 2177050. The workaround is to Set EVENT 10262 with a LEVEL of 102400.
Known Issues:
Bug# 3216432 See Note 3216432.8 PLSQL using recursive calls which open cursors may get OERI:KGIFLPUSH / 17278 / 17277 Fixed: 9.2.0.6, 10.1.0.2
Bug# 2887209 See Note 2887209.8 UGA memory leak / OERI:729 with failed shared database link connection Fixed: 9.2.0.7, 10.1.0.2
Bug# 2884469 See Note 2884469.8 OERI[729] possible using literal replacement Fixed: 9.2.0.4, 10.1.0.2
Bug# 2782196 See Note 2782196.8 ORA-3106 / OERI:729 after CTRL-C of INSERT..SELECT via a DBLINK Fixed: 9.2.0.4, 10.1.0.2
Bug# 2678481 See Note 2678481.8 OERI[729] possible on SHUTDOWN Fixed: 9.2.0.3, 10.1.0.2
Bug# 2537917 See Note 2537917.8 OERI:729 possible with XDB Fixed: 9.2.0.3
Bug# 2295845 See Note 2295845.8 OERI:729 if TRUNCATE PARTITION / ALTER TABLE MODIFY COLUMN interrupted Fixed: 9.0.1.4, 9.2.0.2, 10.1.0.2
Bug# 2177050 See Note 2177050.8 OERI:729 space leak possible (with tags "define var info" / "oactoid info") Fixed: 8.1.7.4, 9.0.1.0
Bug# 2028564 See Note 2028564.8 ORA-7445 or OERI:17114 errors possible after OERI:729 - PMON may die Fixed: 9.0.1.4, 9.2.0.2, 10.1.0.2
Bug# 1731079 See Note 1731079.8 OERI:729 space leak possible Fixed: 9.0.1.4, 9.2.0.1
Bug# 1712645 See Note 1712645.8 OERI:729 space leak possible if DROP COLUMN is interrupted Fixed: 8.1.7.3, 9.0.1.1, 9.2.0.1
Bug# 1674074 See Note 1674074.8 Leak of "ktatt" memory chunks possible (OERI:729) on failed creation of a TEMP segment Fixed: 9.2.0.1
Bug# 1573524 See Note 1573524.8 OERI:729 / OERI:kghxhdr1 using DEFERRED TRANSACTION PROPAGATION with AUDITING enabled Fixed: 8.1.7.2, 9.0.1.0
Bug# 1366596 See Note 1366596.8 Leak of "kgbt" memory chunks possible (OERI:729) on failed creation of a TEMP LOB Fixed: 9.0.1.0
Bug# 918272 See Note 918272.8 OERI:729 memory leak when AUDIT_TRAIL=TRUE Fixed: 8.0.6.2, 8.1.6.2, 8.1.7.0
Bug# 744179 See Note 744179.8 OERI:729 from shared server using DB Links at logoff Fixed: 7.3.4.5, 8.0.5.2, 8.0.6.0, 8.1.5.1
Bug# 690413 See Note 690413.8 OERI:729 possible from failed direct export Fixed: 8.0.4.4, 8.0.5.2, 8.0.6.0
Bug# 410215 See Note 410215.8 ORA-600 [729] [493888], [SPACE LEAK] after DIRECT LOAD Fixed: 7.3.3.1, 7.3.4.0
Abstract Linux is an open source operating system developed by people all over the world. The source code is freely available and can be used under the GNU General Public License. The operating system is made available to users in the form of distributions from companies such as Red Hat. Whereas some desktop Linux distributions can be downloaded at no charge from the Web, the server versions typically must be purchased. IBM has embraced Linux, and it is now recognized as an operating system suitable for enterprise-level applications running on IBM eServer xSeries servers. Most enterprise applications are now available on Linux as well as Microsoft Windows, including file and print servers, database servers, Web servers, and collaboration and mail servers. With the use in an enterprise-class server comes the need to monitor performance and, when necessary, tune the server to remove bottlenecks that affect users. This IBM Redpaper describes the methods you can use to tune Red Hat Advanced Server, tools you can use to monitor and analyze server performance, and key tuning parameters for specific server applications. Table of Contents Chapter 1. Tuning the operating system Chapter 2. Tuning tools Chapter 3. Analyzing performance bottlenecks Chapter 4. Tuning Apache Chapter 5. Tuning database servers Chapter 6. Tuning Samba for file and print Chapter 7. Tuning LDAP Chapter 8. Tuning Lotus Domino
There are various features of Oracle 10g that get all the publicity and press, and for many people, the decision to migrate is driven by whether or not they happen to see anything in the high-profile features that might be useful.
set lines 121 set pages 999 col opname format a29 col target format a29 col target_desc format a12 col perwork format a12 col remain format 99 col elapsed format 9999 col start_time format a21 col sofar format 99999999 col totalwork format 99999999 col sql_text format a101
select opname,target,to_char(start_time,'yy-mm-dd:hh24:mi:ss') start_time,elapsed_seconds elapsed,buffer_gets/decode(executions,0,1,executions) bufgets,sql_text from v$session_longops sl,v$sqlarea sa where sl.sql_hash_value = sa.hash_value;
我们知道在AIX操作系统中,Paging Space是一项很重要的设备,AIX kernel(内 核)需要利用 Paging Space 来管理虚拟内存。和内存页面一样,AIX的 Paging Space也是以4KB为单位,当实际内存数的空闲值低于一定数量以后,系统需要把 实际内存中的某些计算页面(Computation Page)写回到Paging Space中(page out),以便释放出实际内存页面用于其他程序。在AIX 4.3.2及以后版本中,操作系统提供了3种 Paging Space的管理机制。分别为: Early Page Space Allocation (EPSA) Late Page Space Allocation (LPSA) Deferred Page Space Allocation (DPSA) Early Page Space Allocation
正确的将man文件输出转成文本文件的方法是: $ man ls | col -b > man.txt
★如何在打印队列出现故障时发邮件通知管理员
#!/bin/ksh ERR_Q=""*** WARNING - Printer queue" enq -AW | while read QUEUE DEVICE STATUS do if [ $STATUS = "DOWN" ] then ERR_Q="${ERR_Q} ${QUEUE}" fi done echo "${ERR_Q} is down ***" | mail operator
Oracle9i Release 2 (9.2) provides the initialization parameter STATISTICS_LEVEL , which controls all major statistics collections or advisories in the database. This parameter sets the statistics collection level for the database.
Depending on the setting of STATISTICS_LEVEL, certain advisories and statistics are collected, as follows:
BASIC: No advisories or statistics are collected.
TYPICAL: The following advisories or statistics are collected:
ALL: All of the preceding advisories or statistics are collected, plus the following:
* Timed operating system statistics * Row source execution statistics
The default level is TYPICAL. STATISTICS_LEVEL is a dynamic parameter and can be altered at the system or the session level.
When modified by ALTER SYSTEM, all advisories or statistics in the preceding list are dynamically turned on or off, depending on the new value of STATISTICS_LEVEL.
When modified by ALTER SESSION, only the following advisories or statistics are turned on or off in the local session only. Their systemwide state is not changed.
The purpose of dynamic sampling is to improve server performance by determining more accurate selectivity and cardinality estimates. More accurate selectivity and cardinality estimates allow the optimizer to produce better performing plans.
You can use dynamic sampling to:
* Estimate single-table predicate selectivities when collected statistics cannot be used or are likely to lead to significant errors in estimation. * Estimate table cardinality for tables without statistics or for tables whose statistics are too out of date to trust.
The DYNAMIC_SAMPLING hint lets you control dynamic sampling to improve server performance by determining more accurate selectivity and cardinality estimates. You can set the value of DYNAMIC_SAMPLING to a value from 0 to 10. The higher the level, the more effort the compiler puts into dynamic sampling and the more broadly it is applied. Sampling defaults to cursor level unless you specify a table. See Also:
* "Dynamic Sampling" for information about when and how to use dynamic sampling * "DYNAMIC_SAMPLING" for details about using this hint
......
Dynamic Sampling
The purpose of dynamic sampling is to improve server performance by determining more accurate selectivity and cardinality estimates. More accurate selectivity and cardinality estimates allow the optimizer to produce better performing plans.
You can use dynamic sampling to:
* Estimate single-table predicate selectivities when collected statistics cannot be used or are likely to lead to significant errors in estimation. * Estimate table cardinality for tables without statistics or for tables whose statistics are too out of date to trust. * How Dynamic Sampling Works
The primary performance attribute is compile time. Oracle determines at compile time whether a query would benefit from dynamic sampling. If so, a recursive SQL statement is issued to scan a small random sample of the table's blocks, and to apply the relevant single table predicates to estimate predicate selectivities. The sample cardinality can also be used, in some cases, to estimate table cardinality.
Depending on the value of the OPTIMIZER_DYNAMIC_SAMPLING initialization parameter, a certain number of blocks are read by the dynamic sampling query.
SQL> set autotrace only
SQL> select * from test_normal where empno=&empno;
Enter value for empno: 1000
old 1:select * from test_normal where empno=&empno
new 1:select * from test_normal where empno=1000
Elapsed: 00:00:00.01
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=4 Card=1 Bytes=34)
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TEST_NORMAL' (Cost=4 Car
d=1 Bytes=34)
2 1 BITMAP CONVERSION (TO ROWIDS)
3 2 BITMAP INDEX (SINGLE VALUE) OF 'NORMAL_EMPNO_BMX'
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
5 consistent gets
0 physical reads
0 redo size
515 bytes sent via SQL*Net to client
499 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> drop index NORMAL_EMPNO_BMX;
Index dropped.
SQL> create index normal_empno_idx on test_normal(empno);
Index created.
SQL> analyze table test_normal compute statistics for table for all indexes for all indexed columns;
Table analyzed.
SQL> select substr(segment_name,1,30) segment_name, bytes/1024/1024 "Size in MB"
2 from user_segments
3 where segment_name in ('TEST_NORMAL','NORMAL_EMPNO_IDX');
SEGMENT_NAME Size in MB
---------------------------------- ---------------
TEST_NORMAL 50
NORMAL_EMPNO_IDX 18
SQL> select index_name, clustering_factor from user_indexes;
INDEX_NAME CLUSTERING_FACTOR
---------------------------------- ----------------------------------
NORMAL_EMPNO_IDX 6210
SQL> set autot trace
SQL> select * from test_normal where empno=&empno;
Enter value for empno: 1000
old 1:select * from test_normal where empno=&empno
new 1:select * from test_normal where empno=1000
Elapsed: 00:00:00.01
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=4 Card=1 Bytes=34)
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TEST_NORMAL' (Cost=4 Car
d=1 Bytes=34)
2 1 INDEX (RANGE SCAN) OF 'NORMAL_EMPNO_IDX' (NON-UNIQUE) (C
ost=3 Card=1)
Statistics
----------------------------------------------------------
29 recursive calls
0 db block gets
5 consistent gets
0 physical reads
0 redo size
515 bytes sent via SQL*Net to client
499 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> create bitmap index random_empno_bmx on test_random(empno);
Index created.
SQL> analyze table test_random compute statistics for table for all indexes for all indexed columns;
Table analyzed.
SQL> select substr(segment_name,1,30) segment_name, bytes/1024/1024 "Size in MB"
2 from user_segments
3* where segment_name in ('TEST_RANDOM','RANDOM_EMPNO_BMX');
SEGMENT_NAME Size in MB
------------------------------------ ---------------
TEST_RANDOM 50
RANDOM_EMPNO_BMX 28
SQL> select index_name, clustering_factor from user_indexes;
INDEX_NAME CLUSTERING_FACTOR
------------------------------ ---------------------------------
RANDOM_EMPNO_BMX 1000000
再次,统计值(大小和群集因子)对于 TEST_NORMAL 表上的那些索引是相同的。
SQL> select * from test_random where empno=&empno;
Enter value for empno: 1000
old 1:select * from test_random where empno=&empno
new 1:select * from test_random where empno=1000
Elapsed: 00:00:00.01
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=4 Card=1 Bytes=34)
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TEST_RANDOM' (Cost=4 Card=1 Bytes=34)
2 1 BITMAP CONVERSION (TO ROWIDS)
3 2 BITMAP INDEX (SINGLE VALUE) OF 'RANDOM_EMPNO_BMX'
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
5 consistent gets
0 physical reads
0 redo size
515 bytes sent via SQL*Net to client
499 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> drop index RANDOM_EMPNO_BMX;
Index dropped.
SQL> create index random_empno_idx on test_random(empno);
Index created.
SQL> analyze table test_random compute statistics for table for all indexes for all indexed columns;
Table analyzed.
SQL> select substr(segment_name,1,30) segment_name, bytes/1024/1024 "Size in MB"
2 from user_segments
3 where segment_name in ('TEST_RANDOM','RANDOM_EMPNO_IDX');
SEGMENT_NAME Size in MB
---------------------------------- ---------------
TEST_RANDOM 50
RANDOM_EMPNO_IDX 18
SQL> select index_name, clustering_factor from user_indexes;
INDEX_NAME CLUSTERING_FACTOR
---------------------------------- ----------------------------------
RANDOM_EMPNO_IDX 999830
SQL> select * from test_random where empno=&empno;
Enter value for empno: 1000
old 1:select * from test_random where empno=&empno
new 1:select * from test_random where empno=1000
Elapsed: 00:00:00.01
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=4 Card=1 Bytes=34)
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TEST_RANDOM' (Cost=4 Card=1 Bytes=34)
2 1 INDEX (RANGE SCAN) OF 'RANDOM_EMPNO_IDX' (NON-UNIQUE) (Cost=3 Card=1)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
5 consistent gets
0 physical reads
0 redo size
515 bytes sent via SQL*Net to client
499 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> select * from test_normal where empno between &range1 and &range2;
Enter value for range1: 1
Enter value for range2: 2300
old 1:select * from test_normal where empno between &range1 and &range2
new 1:select * from test_normal where empno between 1 and 2300
2300 rows selected.
Elapsed: 00:00:00.03
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=451 Card=2299 Bytes=78166)
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TEST_NORMAL' (Cost=451 Card=2299 Bytes=78166)
2 1 BITMAP CONVERSION (TO ROWIDS)
3 2 BITMAP INDEX (RANGE SCAN) OF 'NORMAL_EMPNO_BMX'
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
331 consistent gets
0 physical reads
0 redo size
111416 bytes sent via SQL*Net to client
2182 bytes received via SQL*Net from client
155 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
2300 rows processed
步骤 3B(在 TEST_NORMAL 上)
在这一步中,我们将对具有 B-tree 索引的 TEST_NORMAL 表执行查询。
SQL> select * from test_normal where empno between &range1 and &range2;
Enter value for range1: 1
Enter value for range2: 2300
old 1:select * from test_normal where empno between &range1 and &range2
new 1:select * from test_normal where empno between 1 and 2300
2300 rows selected.
Elapsed: 00:00:00.02
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=23 Card=2299 Bytes=78166)
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TEST_NORMAL' (Cost=23 Card=2299 Bytes=78166)
2 1 INDEX (RANGE SCAN) OF 'NORMAL_EMPNO_IDX' (NON-UNIQUE) (Cost=8 Card=2299)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
329 consistent gets
15 physical reads
0 redo size
111416 bytes sent via SQL*Net to client
2182 bytes received via SQL*Net from client
155 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
2300 rows processed
SQL>select * from test_random where empno between &range1 and &range2;
Enter value for range1: 1
Enter value for range2: 2300
old 1:select * from test_random where empno between &range1 and &range2
new 1:select * from test_random where empno between 1 and 2300
2300 rows selected.
Elapsed: 00:00:08.01
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=453 Card=2299 Bytes=78166)
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TEST_RANDOM' (Cost=453 Card=2299 Bytes=78166)
2 1 BITMAP CONVERSION (TO ROWIDS)
3 2 BITMAP INDEX (RANGE SCAN) OF 'RANDOM_EMPNO_BMX'
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
2463 consistent gets
1200 physical reads
0 redo size
111416 bytes sent via SQL*Net to client
2182 bytes received via SQL*Net from client
155 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
2300 rows processed
SQL> select * from test_random where empno between &range1 and &range2;
Enter value for range1: 1
Enter value for range2: 2300
old 1:select * from test_random where empno between &range1 and &range2
new 1:select * from test_random where empno between 1 and 2300
2300 rows selected.
Elapsed: 00:00:03.04
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=613 Card=2299 Bytes=78166)
1 0 TABLE ACCESS (FULL) OF 'TEST_RANDOM' (Cost=613 Card=2299 Bytes=78166)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
6415 consistent gets
4910 physical reads
0 redo size
111416 bytes sent via SQL*Net to client
2182 bytes received via SQL*Net from client
155 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
2300 rows processed
SQL> create bitmap index normal_sal_bmx on test_normal(sal);
Index created.
SQL> analyze table test_normal compute statistics for table for all indexes for all indexed columns;
Table analyzed.
现在让我们来获取索引的大小和群集因子。
SQL>select substr(segment_name,1,30) segment_name, bytes/1024/1024 "Size in MB"
2* from user_segments
3* where segment_name in ('TEST_NORMAL','NORMAL_SAL_BMX');
SEGMENT_NAME Size in MB
------------------------------ --------------
TEST_NORMAL 50
NORMAL_SAL_BMX 4
SQL> select index_name, clustering_factor from user_indexes;
INDEX_NAME CLUSTERING_FACTOR
------------------------------ ----------------------------------
NORMAL_SAL_BMX 6001
现在开始进行查询,首先使用等式谓词运行它们:
SQL> set autot trace
SQL> select * from test_normal where sal=&sal;
Enter value for sal: 1869
old 1:select * from test_normal where sal=&sal
new 1:select * from test_normal where sal=1869
164 rows selected.
Elapsed: 00:00:00.08
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=39 Card=168 Bytes=4032)
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TEST_NORMAL' (Cost=39 Card=168 Bytes=4032)
2 1 BITMAP CONVERSION (TO ROWIDS)
3 2 BITMAP INDEX (SINGLE VALUE) OF 'NORMAL_SAL_BMX'
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
165 consistent gets
0 physical reads
0 redo size
8461 bytes sent via SQL*Net to client
609 bytes received via SQL*Net from client
12 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
164 rows processed
然后使用范围谓词:
SQL> select * from test_normal where sal between &sal1 and &sal2;
Enter value for sal1: 1500
Enter value for sal2: 2000
old 1:select * from test_normal where sal between &sal1 and &sal2
new 1:select * from test_normal where sal between 1500 and 2000
83743 rows selected.
Elapsed: 00:00:05.00
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=601 Card=83376 Bytes
=2001024)
1 0 TABLE ACCESS (FULL) OF 'TEST_NORMAL' (Cost=601 Card=83376
Bytes=2001024)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
11778 consistent gets
5850 physical reads
0 redo size
4123553 bytes sent via SQL*Net to client
61901 bytes received via SQL*Net from client
5584 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
83743 rows processed
现在丢弃位图索引,并在 TEST_NORMAL 上创建一个 B-tree 索引。
SQL> create index normal_sal_idx on test_normal(sal);
Index created.
SQL> analyze table test_normal compute statistics for table for all indexes for all indexed columns;
Table analyzed.
查看索引和群集因子的大小。
SQL> select substr(segment_name,1,30) segment_name, bytes/1024/1024 "Size in MB"
2 from user_segments
3 where segment_name in ('TEST_NORMAL','NORMAL_SAL_IDX');
SEGMENT_NAME Size in MB
------------------------------ ---------------
TEST_NORMAL 50
NORMAL_SAL_IDX 17
SQL> select index_name, clustering_factor from user_indexes;
INDEX_NAME CLUSTERING_FACTOR
------------------------------ ----------------------------------
NORMAL_SAL_IDX 986778
在上面的表中,您可以看到此索引比相同列上的位图索引大。群集因子也接近此表中的行数。
下面要进行测试了,首先使用等式谓词:
SQL> set autot trace
SQL> select * from test_normal where sal=&sal;
Enter value for sal: 1869
old 1:select * from test_normal where sal=&sal
new 1:select * from test_normal where sal=1869
164 rows selected.
Elapsed: 00:00:00.01
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=169 Card=168 Bytes=4032)
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TEST_NORMAL' (Cost=169 Card=168 Bytes=4032)
2 1 INDEX (RANGE SCAN) OF 'NORMAL_SAL_IDX' (NON-UNIQUE) (Cost=3 Card=168)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
177 consistent gets
0 physical reads
0 redo size
8461 bytes sent via SQL*Net to client
609 bytes received via SQL*Net from client
12 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
164 rows processed
然后,范围谓词:
SQL> select * from test_normal where sal between &sal1 and &sal2;
Enter value for sal1: 1500
Enter value for sal2: 2000
old 1:select * from test_normal where sal between &sal1 and &sal2
new 1:select * from test_normal where sal between 1500 and 2000
83743 rows selected.
Elapsed: 00:00:04.03
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=601 Card=83376 Bytes
=2001024)
1 0 TABLE ACCESS (FULL) OF 'TEST_NORMAL' (Cost=601 Card=83376
Bytes=2001024)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
11778 consistent gets
3891 physical reads
0 redo size
4123553 bytes sent via SQL*Net to client
61901 bytes received via SQL*Net from client
5584 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
83743 rows processed
SQL> alter table test_normal add GENDER varchar2(1);
Table altered.
SQL> select GENDER, count(*) from test_normal group by GENDER;
S COUNT(*)
- ----------
F 333769
M 499921
166310
3 rows selected.
此列上的位图索引的大小大约是 570 KB,如下表中所示:
SQL> create bitmap index normal_GENDER_bmx on test_normal(GENDER);
Index created.
Elapsed: 00:00:02.08
SQL> select substr(segment_name,1,30) segment_name, bytes/1024/1024 "Size in MB"
2 from user_segments
3 where segment_name in ('TEST_NORMAL','NORMAL_GENDER_BMX');
SEGMENT_NAME Size in MB
------------------------------ ---------------
TEST_NORMAL 50
NORMAL_GENDER_BMX .5625
2 rows selected.
相反,此列上的 B-tree 索引的大小为 13 MB,它比此列上的位图索引要大得多。
SQL> create index normal_GENDER_idx on test_normal(GENDER);
Index created.
SQL> select substr(segment_name,1,30) segment_name, bytes/1024/1024 "Size in MB"
2 from user_segments
3 where segment_name in ('TEST_NORMAL','NORMAL_GENDER_IDX');
SEGMENT_NAME Size in MB
------------------------------ ---------------
TEST_NORMAL 50
NORMAL_GENDER_IDX 13
2 rows selected.
SQL>select * from test_normal
where sal in (1000,1500,2000,2500,3000,3500,4000,4500,5000) and GENDER='M';
1453 rows selected.
Elapsed: 00:00:02.03
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=198 Card=754 Bytes=18850)
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TEST_NORMAL' (Cost=198 Card=754 Bytes=18850)
2 1 BITMAP CONVERSION (TO ROWIDS)
3 2 BITMAP AND
4 3 BITMAP OR
5 4 BITMAP INDEX (SINGLE VALUE) OF 'NORMAL_SAL_BMX'
6 4 BITMAP INDEX (SINGLE VALUE) OF 'NORMAL_SAL_BMX'
7 4 BITMAP INDEX (SINGLE VALUE) OF 'NORMAL_SAL_BMX'
8 4 BITMAP INDEX (SINGLE VALUE) OF 'NORMAL_SAL_BMX'
9 4 BITMAP INDEX (SINGLE VALUE) OF 'NORMAL_SAL_BMX'
10 4 BITMAP INDEX (SINGLE VALUE) OF 'NORMAL_SAL_BMX'
11 4 BITMAP INDEX (SINGLE VALUE) OF 'NORMAL_SAL_BMX'
12 4 BITMAP INDEX (SINGLE VALUE) OF 'NORMAL_SAL_BMX'
13 4 BITMAP INDEX (SINGLE VALUE) OF 'NORMAL_SAL_BMX'
14 3 BITMAP INDEX (SINGLE VALUE) OF 'NORMAL_GENDER_BMX'
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
1353 consistent gets
920 physical reads
0 redo size
75604 bytes sent via SQL*Net to client
1555 bytes received via SQL*Net from client
98 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1453 rows processed
为 B-tree 索引时:
SQL>select * from test_normal
where sal in (1000,1500,2000,2500,3000,3500,4000,4500,5000) and GENDER='M';
1453 rows selected.
Elapsed: 00:00:03.01
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=601 Card=754 Bytes=18850)
1 0 TABLE ACCESS (FULL) OF 'TEST_NORMAL' (Cost=601 Card=754 Bytes=18850)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
6333 consistent gets
4412 physical reads
0 redo size
75604 bytes sent via SQL*Net to client
1555 bytes received via SQL*Net from client
98 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1453 rows processed
Oracle变化数据捕捉(Change Data Capture,CDC)特性简化了识别自上次提取后发生变化的数据的过程。CDC提供了易于使用的API来设置CDC环境。 如果你是参与数据集成项目的DBA或开发人员,需要定期从一个系统提取大量数据并将其传输到另一个系统或多个系统,那就赶快考虑使用CDC来缩短ETL的时间吧。
SQL> DESC PRICE_LIST
Name Null? Type
---------- ------- -------
PRODUCT_ID NOT NULL VARCHAR2(20)
UOM NOT NULL VARCHAR2(20)
PRICE_PER_UOM NOT NULL NUMBER(10,2)
SQL> DESC SALES_TRAN
Name Null? Type
---------- ------- -------
PRODUCT_ID NOT NULL VARCHAR2(20)
SALE_DATE_TIME NOT NULL TIMESTAMP(6)
QUANTITY NOT NULL NUMBER(10,2)
connect sales_op/sales_op
grant select on PRICE_LIST to sales_dw;
grant select on SALES_TRAN to sales_dw;
grant select on CDC_PRICE_LIST
to sales_dw;
grant select on CDC_SALES_TRAN
to sales_dw;
SQL> select :sv_price_list from dual;
:SV_PRICE_LIST
----------------
CDC#CV$1430621
SQL> select :sv_sales_tran from dual;
:SV_SALES_TRAN
-----------------
CDC#CV$1430623
8.访问变化表中的数据
订阅者视图包含你所需要的变化数据。它还包含使用变化数据所需的其他一些附加信息:
SQL> desc CDC#CV$1430621
Name Null? Type
---------- ------- --------
OPERATION$ CHAR(2)
CSCN$ NUMBER
COMMIT_TIMESTAMP$ DATE
TIMESTAMP$ DATE
USERNAME$ VARCHAR2(30)
PRICE_PER_UOM NUMBER(10,2)
PRODUCT_ID VARCHAR2(20)
UOM VARCHAR2(20)
一、获取机器ID和机器类型的命令 #hostid #uname -i 二、添加License的命令 #vxlicense -c 三、查看License的命令 # vxlicense -p 四、名词解析 VRTSvxvm VxVM软件 VRTSlic VxVM licensing utilities VRTSvmdoc VxVM电子文档 VRTSvmman VxVM帮助手册 VRTSvmdev VxVM developer’s package VRTSvxsa VxVM图形管理界面 VRTSvxfs VxFS软件 VRTSfsdoc VxFS文档 五、添加VxVM和VxFS包 #mount –F hsfs –o ro /dev/dsk/c0t6d0s2 /mnt # pkgadd –d path_name product_packages 注意:要以超级用户权限登录系统,完了后还要重启系统。 六、安装VxFS后,修改/etc/system ,在里面添加一行: set lwp_default_stksize=0x4000 并将原始的文件拷贝一份。 七、检查安装包: #pkginfo 列出所有安装的包 #pkginfo | grep VRTS 列出安装的VERITAS的包 #pkginfo –l pkckage 列出某个安装包的详细信息 八、用vxinstall来创建rootdg 。 选择Custom安装。 九、显示执行过的命令: #tail –f /var/opt/vmsa/logs/command 十、命令行 在如下几个目录中,可以找到在命令行中使用的命令: /etc/vx/bin /usr/sbin /usr/lib/vxvm/bin 注:把这些目录加入到PATH环境变量中去。 十一、几条常用命令: vxassist 、vxprint 、vxdg 、vxdisk 十二、检查是否有别的VMSA版本存在: #pkginfo –l | grep vmsa 如果有则删除: #pkgrm VRTSvmsa 十三、启动VMSA 1.以root用户登录; 2.#./vmsa_server & 3.xhost + system_name (这一步有时需要做) 4.DISPLAY=’uname –n ‘:0.0 ;export DISPLAY(这一步有时需要做) 十四、启动VMSA客户端 1.本地启动:# vmsa 2.远程启动:# vmsa remote_machine_name 十五、几个命令 1.确定VMSA是否运行:# vmsa_server -q 2.停止VMSA服务: # vmsa_server -k 3.显示VMSA运行版本:# vmsa_server -v 4.启动自动模式:# autostart on 5.显示当前运行模式:# netstat -a | grep vmsa 6.改变自动模式:# autostart off 7.运行在只读模式下:# vmsa_server -r & 和# vmsa -r & 十六、添加磁盘的方法:(行命令) 1.vxdisksetup :configures a disk for VxVM 2.vxdg addisk :add a disk to a disk group 3.# /etc/vx/bin/vxdisksetup –i disk_address [attributes] 注:The disk_address defines the controller , target , and SCSI logical unit number of the disk to be set up and takes the form c # t # d # . The –i option writes a disk header to the disk , making the disk derectly usable . 4.# vxdg –g diskgroup adddisk disk_name=device_name 十七、查看磁盘信息(命令行) 1.vxdisk list :list disk information 2.prtvtoc :Display VTOC configuration 3.vxdisk –o alldgs list :show all disk groups in the output . 4.# vxdisk list disk_name :显示某个磁盘的信息。 5.# prtvtoc physical_disk_path 6.# prtvtoc /dev/rdsk/c1t10d0s2 注:注意磁盘在卷中和不在卷中,prtvtoc命令结果显示的不同。 十八、Evacuating a disk // remove a disk(命令行) 1.vxevac –g diskgroup from_diskname to_diskname 2.例子:# vxevac –g datadg datadg02 datadg03 3.vxdg rmdisk :returns a disk to the free disk pool 4.vxdiskunsetup :returning a disk to an uninitialized state 5.vxdg –g diskgroup rmdisk disk_name 6.例子:# vxdg –g newdg rmdisk newdg02 7./etc/vx/bin/vxdiskunsetup –[C] disk_address 8.例子:# vxdiskunsetup c1t0d0 十九、给磁盘重命名(命令行) 1.# vxedit –g diskgroup rename old_diskname new_diskname 2.Using vxdg deport and vxdg import rename a disk group 二十、The rootdg disk group cannot be destroyed and must exist on every system , because it is an essential part of the VxVM boot process . 二十一、创建磁盘组(命令行) 1.vxdg init diskgroup disk_name=device_name 2.# vxdg init newdg newdg01=c1t1d0s2 二十二、创建备用磁盘 # vxdg –g diskgroup set spare=on|off disk_media_name 二十三、Deporting a disk group(命令行) 1.# unmount /filesystem(先卸载磁盘组上的文件系统) 2.# vxdg deport diskgroup 3.# vxdg –n new_name deport old_name(deport and rename a disk group) 4.# vxdg –h hostname deport diskgroup(deport to a new host) 二十四、Importing a disk group(命令行) 1.# vxdg import diskgroup 2.# vxdg –n new_name import old_name(import and rename a disk group) http://www.uxma.com/sheke/news/pic/8.swf 3.# vxdg –t –n temp_name import old_name(import and rename temporaily) 4.# vxdg –tC –n newerdg import newdg(clear import locks,add the –C option) 5.# vxdg –f import newdg(force an import) 二十五、Rename a disk group:CLI 1.# vxdg –n new_name deport old_name 2.# vxdg import new_name 以上是第一种方式 3.# vxdg deport old_name 4.# vxdg –n new_name import old_name 5.# vxvol –g diskgroup_newname startall(在命令行中重命名磁盘组后要重启volume) 二十六、Destroying a disk group # vxdg destroy diskgroup 二十七、查看磁盘组信息 1.vxdisk –s list 显示磁盘组名和ID 2.vxdisk –o alldg list 显示所有磁盘组的信息,包括已经destroy的。 3.vxdg –g diskgroup free 显示磁盘组中的free space 。 4.vxdg free 二十八、显示磁盘组的版本 1.# vxdg list diskgroup 2.# vxprint -l 二十九、升级磁盘组版本 1.vxdg [-T version] upgrade diskgroup 2.# vxdg –T 40 upgrade datadg(把datadg从20升级到40) 3.# vxdg upgrade datadg(把datadg升级到当前的版本90) 4.# vxdg -T 50 init newdg newdg01=c0t3d0s2(创建版本为50的磁盘组)
Unix程序员有点象数学家。你能从他们身上观察到一个神秘现象,我们称之为“空头编程”(Programming by Implication)。一次我们和一个Unix程序员聊天,谈到需要这样一个工具,能够回答诸如“函数foo被谁调用过?”或者“那个函数改变过全局变量bar”之类的问题。他也认为这个工具会很有用,提议到,“你们可以自己写一个。”
"YACC"是再一个编译编译器的编译器(Yet Another Compiler Compiler)的意思。它接受与上下文无关(context-free)的语法,构造用于解析的下推自动机(pushdown automaton)。运行这个自动机,就得到了一个特定语言的解析器。这一理论是很成熟的,因为以前计算机科学的一个重要课题就是如何减少编写编译器的时间。
% grep min netinet/ip_icmp.c icmplen = oiplen + min(8, oip->ip_len); * that not corrupted and of at least minimum length. * If the incoming packet was addressed directly to us, * to the incoming interface. * Retrieve any source routing from the incoming packet; %
挺不错的吧,grep找到了所有的min函数调用,而且还不止这些。
“不知道怎么做爱。我撤。”("Don't know how to make love. Stop.")
C Shell的元语法操作符带来了大量和引用有关的问题和混乱。元操作符在一个命令被执行前对其进行转换。我们把这些操作符叫做元操作符是因为它们不属于命令的语法成分,它们作用于命令本身。大多数程序员对元操作符(有时也叫做escape operators)并不陌生。比如,C字符串中的反斜杠()就是一个元语法操作符;它不代表自己,而是对其后的字符的说明。如果你不希望如此,你必须使用引用机制来告诉系统把元操作符当做一般字符来处理。回到刚才C字符串的例子,如果想得到反斜杠字符,你必须写成。
日期: 19 Aug 91 15:26:00 GMT 发信人: Dan_Jacobson@att.com 主题: ${1+"$@"} in /bin/sh family of shells shell scripts 收信人: comp.emacs.gnu.emacs.help, comp.unix.shell
理论上说,使用Shell编程比用C语言要有很多好处:Shell程序移植容易。这指的是使用shell“编程语言”写的程序能够在不同的体系结构和不同的Unix变种上运行,因为shell会解析这些程序,而不是把这些程序编译成机器码运行。而且,标准Unix Shell sh 自从1977年以来就成为Unix中不可或缺的一部分,所以你可以在许多机器上找到它。
% find . -name '*.el' -exec 'test -f {}c'; find: Can't execute test -f {}c: No such file or directory
真有你的,竟然没去解析这个命令。
% find . -name '*.el' -exec test -f {}c ;
咦,似乎什么也没做...
% find . -name '*.el' -exec echo test -f {}c ; test -f c test -f c test -f c test -f c ....
明白了。是shell把大括号给展开了。
% find . -name '*.el' -exec test -f '{}'c ; test -f {}c test -f {}c test -f {}c test -f {}c
嗯?也许我记错了,{}并不是find使用的那个“替换成这个文件名”的符号。真的么?...
% find . -name '*.el' -exec test -f '{}' c ; test -f ./bytecomp/bytecomp-runtime.el c test -f ./bytecomp/disass.el c test -f ./bytecomp/bytecomp.el c test -f ./bytecomp/byte-optimize.el c ....
% find . -name '*.el' -exec echo test -f `echo '{}' | sed 's/$/c'` ; test -f c test -f c test -f c ....
OK, 看来只能去试试所有shell引用的排列组合了,总会有一款和我意吧?
% find . -name '*.el' -exec echo test -f "`echo '{}' | sed 's/$/c'`" ; Variable syntax. % find . -name '*.el' -exec echo test -f '`echo "{}" | sed "s/$/c"`' ; test -f `echo "{}" | sed "s/$/c"` test -f `echo "{}" | sed "s/$/c"` test -f `echo "{}" | sed "s/$/c"` ....
嗨,最后一个似乎有戏。我只需要这么干一下:
% find . -name '*.el' -exec echo test -f '`echo {} | sed "s/$/c"`' ; test -f `echo {} | sed "s/$/c"` test -f `echo {} | sed "s/$/c"` test -f `echo {} | sed "s/$/c"` ....
与此同时,电子出版的势头早已超过了man手册。使用今天的超文本系统你能用鼠标从一篇文章跳到另一篇文章;与之相比,man手册仅仅在末尾提供” SEE ALSO”一节,让用户自己再man下去。在线文档的索引功能又是如何呢?今天你可以买到CD-ROM上的牛津英语词典,它对其中的每一个词都加了索引;可是man手册还是仅仅对命令名和描述行进行索引。今天甚至连DOS都提供了有索引的超文本文档。可是man手册还是采用适合DEC打印终端的80列66 行的格式。
toolsun% mail Mail version SMI 4.0 Sat Apr 9 01:54:23 PDT 1988 Type ? for help “/usr/spool/mail/chris”: 3 messages 3 new >N 1 chris Thu Dec 22 15:49 19/643 editor saved “trash1” N 2 chris Tue Jan 3 10:35 19/636 editor saved “trash1” N 3 chris Tue Jan 3 10:35 19/656 editor saved “/tmp/ma9” & ? Unknown command: “?” &
Streams Monitoring Program Purpose STRMMON is a monitoring tool focused on Oracle Streams. Using this tool, database administrators get a quick overview of the Streams activity occurring within a database. The output format comes in two formats: default and long. The default format reports the rate of activity occuring for Streams processes. The long format provides the detailed information that was available in previous releases of STRMMON. The reporting interval and number of iterations to display are configurable.
STRMMON can also be used to report Streams activity on two databases at a time within the same strmmon session.
In releases 9i and 10G Release 1, STRMMON is not a supported tool by Oracle, as of Oracle 10g Release 2, STRMMON is distributed as in the demo directory of the database distribution code. Contents Installation Usage Parameters Output LOG CPxx MEM% Qx PRxx Apxx Flow Control Potential Bottleneck Instance Known Problems Compilation/Liking errors while running make command Execution errors while running strmmon utility Related Documents Installation STRMMON is delivered as a tar file that includes an OCI program and make file. Click here to download the STRMMON zip file. Change directory to a new directory. If necessary transfer the tar file in BINARY mode. Extract the files from the tar file using the command
tar -xf strmmon.tar .
Before compiling and linking the strmmon program, make sure that the ORACLE_HOME and LD_LIBRARY_PATH environmental variables are set up appropriately. To compile and link, use the command:
make -f strmmon.mk strmmon
After the program has been compiled and linked, strmmon can be used for monitoring a Streams environment. Usage There are 7 command line input parameters for STRMMON: interval, count, user, passwd, dbname, sysdba and long. The first 2 parameters (interval and count) control the sampling rate and the amount of output. The next 4 parameters specify the connect information to the particular Streams database. Use multiple occurrences of these 4 parameters to monitor multiple databases within the same strmmon command. Specifying the last parameter (long) displays more detailed information about each process.
When the command strmmon is issued without any parameters, a usage message is displayed:
% strmmon
Usage: strmmon -interval -count [-user ] [-passwd ] [-dbname ] [-sysdba] Parameters Parameter Name Value Units Description
-interval seconds The interval at which STRMMON will monitor the database. To specify that the sampling rate to be every 3 seconds:
-interval 3
This is a required parameter for strmmon.
-count Number The number of iterations to monitor the Streams environment. To specify 5 iterations, use the following: -count 5
This is a required parameter for strmmon.
-user Username The schema name for logging into the database. Any schema name can be specified. If the SYS schema is specified, additional information is displayed. To specify the SYSTEM schema, use
-user SYSTEM
This parameter should not be specified if logging in as / as sysdba is desired.
-user is an optional parameter for strmmon.
-passwd password The login password for the schema identified with the -user clause. To specify the password for the SYSTEM schema, use
-passwd oracle
This parameter should not be specified if logging in as / as sysdba is desired
-passwd is an optional parameter for strmmon.
-dbname service name The connection information or service name from tnsnames.ora for the specific database to be monitored. To specify the connect information for the monitored database, use
-dbname ORCL.WORLD
This is an optional parameter for strmmon.
-sysdba This flag indicates that the login role is SYSDBA. This optional parameter is typically used with the SYS schema.
When logging in as / as sysdba, the -user and -passwd parameters are not required
-long This flag indicates that the more detailed report is desired. This is an optional parameter for STRMMON. By default, only the capture, apply and propagation rates are displayed.
STRMMON have to be used with the Oracle release used for compilation or linking although it can connect to a different release database by using -dbname parameter. Output The strmmon output begins with a banner line identifying the program parameters and database. This information is followed with a brief description of the major components of the output display. After this initial information about the program, Strmmon produces a single line of output representing the current status of Oracle Streams after the requested interval for each iteration . For example, if strmmon is invoked with '-interval 3 -count 5' , a line of output will be displayed every 3 seconds. After 5 lines have been displayed (15 seconds), the monitoring will end. .
Each line is composed of multiple blocks of information dependent on the streams processes configured within the database. These blocks are displayed by a keyword to identify the component followed by the statistics for that particular component. The separator between the components is the '|' symbol.
There are 5 components for Streams: LOG, CPxx, Qx, PRxx, APxx. Except for the LOG component, multiple occurrences each component are possible dependent on the streams processes configured at database.
An example of this identifying output is shown below:
% strmmon -interval 3 -count 5 -sysdba
STREAMS Monitor, v 2.0 Copyright Oracle Corp. 2002, 2003. Interval = 3, Count=5 Logon= @ ORACLE 9.2.0.6.0 Streams Pool Size = 52M LOG : CPxx: t;lcrs enqueued per sec> Qx : PRxx: APxx: : flow control in effect : potential bottleneck xx->: database instance name
To connect to multiple databases, the following command can be issued. inst1 and inst2 are the network service names (tnsnames.ora) for each database. An example of the identifying output for the long report is shown below % strmmon -interval 1 -count 1 -user sys -passw change_on_install -dbname inst1 -user sys -passw change_on_install -dbname inst2 -sysdba -long
Note: The information about the Streams Pool Size is displayed only for database versions greater than or equal to 10gR1. LOG Information about the redo log activity is written in this block. The first statistic following the LOG: keyword is the current SCN that has been written to the redo log. This number represents the current activity within the database. If this number does not increase, no activity is occurring on the database. The second statistic is the last block number written in the redo log. Redo blocks are always 512 bytes, so this statistic can be used to calculate the amount of redo generated between intervals. The output for the LOG component is always the first entry after the timestamp on the display and appears as follows:
In the above example, the current scn that written to the redo log is 13103675 and the last block number is 50465. Since the strmmon command was issued with '-interval 3 -count 5', 5 lines of output are displayed with a 3 second interval between them. The activity on this database is very low, as seen by the fact that the current scn increases infrequently (note change between 14:02:52 and 14:02:55). CPxx For each capture process configured in the database, a separate block will be displayed. In each block, the total number of messages captured from the redo log and the most recent scn captured from the redo log are shown. In addition, the number messages that match the rules specified for the capture process including the most recent message scn enqueued are shown along with the capture latency.
Use the difference between successive capture 'messages captured' statistics to determine the rate at which capture is mining the redo log. The enqueue scn of capture is an indicator of where the capture process will restart, if capture is stopped and restarted while the database is running This statistic can also be used for comparison with the Apply process high-water mark scn. If these statistics, the capture and apply are caught up and the data is synchronized. MEM% If strmmon is run from the SYS schema connected as SYSDBA, and the database version is 10gR1 or higher, then this displays the percentage of Streams Pool memory currently in use. Qx For each streams queue in the database, a separate block will display the queue identifier as well as the number of outstanding messages in the buffered queue, the cumulative number of messages that have been in the queue and the number of messages spilled from memory to disk. In version 9iR2, the number of messages currently spilled is displayed. In 10gR1, the cumulative number of messages spilled is displayed.
The queue identifier (QID) can be used to identify the name of the queue. Use the QID in queries against the DBA_QUEUES view to identify the particular queue in the database. In 9i, the number of outstanding messages in the buffered queue is only displayed if strmmon is run from the SYS schema as SYSDBA. In 9iR2, if the number of spilled messages becomes non-zero, consider stopping capture temporarily to slow down the flow of data. PRxx For each propagation, the total number of messages and the total number of bytes propagated to the destination site and the total time needed to propagate those messages is displayed. Apxx For each apply process in the database, a block is displayed indicating the statistics for each apply process. In addition to the total messages dequeued and the most recent scn dequeued by the apply reader, the dequeue latency, the total number of transactions received, assigned and applied by the coordinator are displayed. The apply high water mark scn along with the apply high water mark latency is also shown. This statistic records the most recent scn from the source site that has been applied at the destination site. Flow control This flag indicates that the capture process is blocked due to flow control.
Potential Bottleneck This indicates that the capture or apply process is currently a potential
bottleneck
Instance This indicates the name of the database instance for which the data follows
Known problems
Compilation/Linking errors while running make command Error: sh: cc: not found Cause : C compiler can not be found in the path. Solution: Include the path to the C compiler in the PATH environmental variable.
Error: strmmon.c:1114: parse error before "ub8" strmmon.c:1114: warning: no semicolon at end of struct or union strmmon.c:1115: warning: data definition has no type or storage class strmmon.c: In function `print_prop_stats': Cause : strmmon make use of ub8 definition, sometimes the expansion for this definition has failed. Solution: Include the definition of ub8 in the strmmon file, just before the definition of prop struct. Definition of ub8 is as follows:
#define ub8 unsigned long long Execution errors while running strmmon utility Error: Strmmon dump a core or raise a Memory fault Cause : Compilation parameters are not the best for this platform Solution : Use -user and -passwd parameters with user SYSTEM
Error: Error while loading shared libraries Cause: LD_LIBRARY_PATH not defined Solution : Define LD_LIBRARY_PATH
Error: OCIEnvCreate() failed Cause : strmmon has been compiled/linked with a release different to the one that is being used now. Solution : Use the right ORACLE_HOME and use -dbname parameter to access a different database release
Oracle Streams enables the sharing of data and events in a data stream, either within a database or from one database to another. This article is intended to assist Replication DBAs in configuring Oracle Streams Replication.
SCOPE & APPLICATION -------------------
To be used by Oracle support analysts and replication DBAs to setup replication using Streams in Oracle 9.2.x or higher. Below, are some of the key recommendations for successful configuration of Streams in the 9.2 release of the Oracle database.
INTRODUCTION ------------- Oracle 9.2 has introduced a more flexible and efficient way of implementing replication using Streams. In the contrary to what it happens on Advanced Replication, there is no a Master Definition Site and all the sites plays the same role.
Every database involved in the Streams replication is in charge of capturing those changes involved in the replication and propagating them to the other/s sites. Also every database is in charge of applying those entries coming from other/s sites.
Then in a bidireccional database we will have 2 Streams, one from site A to site B and the other from Site B to Site A.
In a nutshell, replication using Streams is implemented in the following way.
1) A background capture process is configured to capture changes made to tables,schemas, or the entire database. The capture process captures changes from the redo log and formats each captured change into a logical change record (LCR). The capture process uses logminer to mine the redo/archive logs to format LCRs.
2) The capture process enqueues LCR events into a queue that is specified.
3) This queue is scheduled to Propagate events from one queue to another in a target database.
4) A background apply process dequeues the events and applies them at the destination database.
Streams Configuration =====================
The Configuration is divided into the following 4 sections:
Section 1 : Software Version Section 2 : Initialization Parameters Relevant to Streams Section 3 : Database Storage Section 4 : Database Privileges Section 5 : Streams site types: Source Configuration Section 6 : Streams site types: Target Configuration
Section 1: Software Version ===========================
Use the most recent patch set for Oracle 9.2, currently 9.2.0.6, available from http://Metalink.oracle.com as Patch 3948480
Patch 3023858 is for Oracle Enterprise Manager, and should be applied to the Oracle Management Server database as well as to any local systems that will use the Oracle Enterprise Manager software.
Section 2: Initialization Parameters Relevant To Streams ========================================================
At each participating Streams site, confirm that the following required init.ora parameters are set appropriately for each database:
2.1 COMPATIBLE To use Streams, Compatible must be set to 9.2.0 or higher.
2.2 GLOBAL_NAMES This parameter must be set to TRUE at each database if you want to use Streams to share information between databases. Streams uses the GLOBAL_NAME of the database to identify changes from or to a particular database. Do NOT modify the GLOBAL NAME of a Streams database after it has been configured. For example, the system-generated rules for capture, propagation, and apply typically specify the global name of the source database. In addition, changes captured by the Streams capture process automatically include the current global name of the source database. If the global name must be modified on the database, do it at a time when NO user changes are possible on the database so that the Streams configuration can be recreated.
2.3 JOB_QUEUE_PROCESSES This parameter specifies the number of processes that can handle requests created by DBMS_JOB. Ensure that it is set to 2 or higher.
2.4 AQ_TM_PROCESSES Setting the parameter to 1 or more starts the specified number of queue monitor processes.
2.5 LOGMNR_MAX_PERSISTENT_SESSIONS This parameter specifies the maximum number of persistent LOGMINER mining sessions. Streams Capture Process uses LOGMINER to mine the redo logs. If there is a need to run multiple Streams capture processes on a single database, then this parameter needs to be set equal to or higher than the number of planned capture processes.
2.6 LOG_PARALLELISM This parameter must be set to 1 at each database that captures events.
2.7 PARALLEL_MAX_SERVERS Each capture process and apply process may use multiple parallel execution servers. The apply process by default needs two parallel servers. So this parameter needs to set to at least 2 even for a single non-parallel apply process. Specify a value for this parameter to ensure that there are enough parallel execution servers.
2.8 SHARED_POOL_SIZE Each capture process needs 10MB of shared pool space, by default Streams is limited to using a maximum of 10% of the shared pool. The 10% of the shared_pool_size is in reference to the size of the buffer queue before spillover occurs. Shared_pool_size must be significantly larger if Streams capture is implemented, especially if there is a large workload. The typical recommendation is to double the existing shared_pool_size and set the _first_spare_parameter to 50.
2.9 OPEN_LINKS Specifies the maximum number of concurrent open connections to remote databases in one session. Ensure that it is set to 4 or higher.
2.10 PROCESSES Make sure the value of this parameter allows for all background processes, such as locks, job queue processes, and parallel execution processes. In Streams, capture processes and apply processes use background processes and parallel execution processes, and propagation jobs use job queue processes.
2.11 SESSIONS If you plan to run one or more capture processes or apply processes in a database, then you may need to increase the size of this parameter. Each background process in a database requires a session.
2.12 SGA_MAX_SIZE If you plan to run multiple capture processes on a single database, then you may need to increase the size of this parameter. Note :_SGA_SIZE should only be increased if a logminer error is returned indicating a need for more memory. Any memory allocated to logminer is used solely by logminer - it is not returned to the shared_pool after it has been allocated by capture until the capture process is restarted.
2.13 TIMED_STATISTICS If you want to collect elapsed time statistics in the data dictionary views related to Streams, then set this parameter to true. The views that include elapsed time statistics include: V$STREAMS_CAPTURE, V$STREAMS_APPLY_COORDINATOR, V$STREAMS_APPLY_READER, V$STREAMS_APPLY_SERVER.
2.14 Only databases that are capturing changes via Streams capture must be in archivelog mode
At each participating Streams site, configure the init.ora for each database to include the following hidden parameters:
2.1 _first_spare_parameter=50 The threshold (percent) of shared_pool_size memory at which spillover to disk is triggered for captured messages.
2.2 _kghdsidx_count=1 This parameter prevents the shared_pool from being divided among CPUs
2.3 _job_queue_interval=1 Scan rate interval (seconds) of job queue
1. Tablespace for Streams Administrator queues ===========================================
As an option, it is possible to create a separate tablespace for each streams administrator schema (STRMADMIN) at each participating Streams database.This tablespace will be used for any objects created in the streams administrator schema, including any spillover of messages from the in-memory queue.
CREATE TABLESPACE &streams_tbs_name DATAFILE '&db_file_directory/&db_file_name' SIZE 25 M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
ALTER USER strmadmin DEFAULT TABLESPACE &streams_tbs_name QUOTA UNLIMITED ON &streams_tbs_name;
2. Tablespace for Streams/logminer dictionary tables =================================================
Create a separate tablespace for the Streams/logminer dictionary tables at each participating Streams database. Use the SET_TABLESPACE procedure to relocate the Streams/logminer dictionary tables away from the SYSTEM tablespace. This step must be performed at every participating Streams database, independent of whether it is a source or target site.
CREATE TABLESPACE &tspace_name DATAFILE '&db_file_directory/&db_file_name' SIZE 25 M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
3. Separate queues for capture and apply =====================================
Configure separate queues for changes that are captured locally and for receiving captured changes from remote sites. This is especially important when configuring bi-directional replication between multiple databases.
Example: To configure a site (SITEA) that is capturing changes for distribution to another site, as well as receiving changes from that other site (SITEB), configure 2 queues at SITEA as follows:
Subsequently, use the queue CAP_SITEA when configuring capture at SITEA, and APP_FROM_SITEB as the queue when configuring the apply from SITEB on SITEA.
Grant the following privileges to the Streams Administrator schema (strmadmin) on each participating Streams database:
GRANT EXECUTE ON DBMS_AQADM TO strmadmin; GRANT EXECUTE ON DBMS_APPLY_ADM TO strmadmin; GRANT EXECUTE ON DBMS_CAPTURE_ADM TO strmadmin; GRANT EXECUTE ON DBMS_PROPAGATION_ADM TO strmadmin; GRANT EXECUTE ON DBMS_STREAMS TO strmadmin; GRANT EXECUTE ON DBMS_STREAMS_ADM TO strmadmin;
Section 5: Streams site types: Source Configuration ===================================================
1. Supplemental logging ==================== Move LogMiner tables from SYSTEM tablespace: Configure supplemental logging at each source site All target site indexed columns, including the primary key, unique index, and foreign key columns of a table or database must be unconditionally logged at the source site.
Any columns specified in rule-based transformations or used within DML Handlers at target site must be unconditionally logged at the source site.
Supplemental logging can be specified at the source either at the database level or for the individual replicated table.
2. Implement flow control ====================== When the threshold for memory of the buffer queue is exceeded, Streams will write the messages to disk. This is sometimes referred to as "spillover". When spillover occurs, Streams can no longer take advantage of the in-memory queue optimization. One technique to minimize this spillover is to implement a form of flow control. See Metalink Note 259609.1 for the scripts and pre-requisites.
3. Implement a Heartbeat Table =========================== To ensure that the applied_scn of the DBA_CAPTURE view is updated periodically, implement a "heart beat" table. A "heart beat" table is especially useful for databases that have a low activity rate. The streams capture process requests a checkpoint after every 10Mb of generated redo. During the checkpoint, the metadata for streams is maintained if there are active transactions. Implementing a heartbeat table ensures that there are open transactions occurring regularly within the source database enabling additional opportunities for the metadata to be updated frequently. Additionally, the heartbeat table provides quick feedback to the database administrator as to the health of the streams replication. To implement a heartbeat table: Create a table at the source site that includes a date or timestamp column and the global name of the database. Add a rule to capture changes to this table and propagate the changes to each target destination. Make sure that the target destination will apply changes to this table as well. Set up an automated job (dbms_job) to update this table at the source site periodically, for example every minute.
4. Checkpoint periodically ======================= Periodically force capture to checkpoint. This checkpoint is not the same as a database checkpoint. To force capture to checkpoint, use the capture parameter _CHECKPOINT_FORCE and set the value to YES. Forcing a checkpoint ensure that the DBA_CAPTURE view columns CAPTURED_SCN and APPLIED_SCN are maintained.
5. Capture Process Configuration =============================
A. Rules
Use the DBMS_STREAMS_ADM.ADD_*_RULES procedures (ADD_TABLE_RULES, ADD_SCHEMA_RULES for DML and DDL, ADD_GLOBAL_RULES for DDL only). These procedures minimize the number of steps required to configure Streams processes. Also, it is possible to create rules for non-existent objects, so be sure to check the spelling of each object specified in a rule carefully. CAPTURE requires a rule set with rules.The ADD_GLOBAL_RULES procedure cannot be used to capture DML changes for entire database. ADD_GLOBAL_RULES can be used to capture all DDL changes for the database.
A single Streams capture can process rules for multiple tables or schemas. For best performance, rules should be simple. Rules that include NOT or LIKE clauses are not simple and will impact the performance of Streams.
Minimize the number of rules added into the process rule set. A good rule of thumb is to keep the number of rules in the rule set to less than 100. If more objects need to be included in the ruleset, consider constructing rules using the IN clause. For example, a rule for the 6 TB_M21* tables in the MYACCT schema would look like the following: (:dml.get_object_owner() = 'MYACCT' and :dml.is_null_tag() = 'Y' and :dml.get_object_name() IN ('TB_M21_1','TB_M21_2','TB_M21_3', 'TB_M21_40','TB_M21_10','TB_M211B010'))
B. Parameters
Set the following parameters after a capture process is created:
PARALLELISM=3 Ensure that the appropriate supplemental logging has been configured at the source database before setting this parallelism parameter.
_CHECKPOINT_FREQUENCY=1 Increase the frequency of logminer checkpoints especially in a database with significant LOB or DDL activity. A logminer checkpoint is requested by default every 10Mb of redo mined.
_SGA_SIZE Amount of memory available from the shared pool for logminer processing. The default amount of shared_pool memory allocated to logminer is 10Mb. Increase this value especially in environments where large LOBs are processed.
Capture parameters can be set using the SET_PARAMETER procedure from the DBMS_CAPTURE_ADM package. For example, to set the checkpoint frequency of the streams capture process named CAPTURE_EX, use the following syntax while logged in as the Streams Administrator:
Use the ADD_*__PROPAGATION_RULES procedures (ADD_TABLE_PROPAGATION_RULES, ADD_SCHEMA__PROPAGATION_RULES, ADD_GLOBAL_PROPAGATION_RULES for both DML and DDL. These procedures minimize the number of steps required to configure Streams processes. Also, it is possible to create rules for non-existent objects, so be sure to check the spelling of each object specified in a rule carefully. The rules in the rule set for propagation can differ from the rules specified for the capture process. For example, to configure that all captured changes be propagated to a target site, a single ADD_GLOBAL_PROPAGATION_RULES procedure can be specified for the propagation even though multiple ADD_TABLE_RULES were configured for the capture process.
B. Parameters
LATENCY=5 Maximum wait, in seconds, in the propagation window for a message to be propagated after it is enqueued. For example, if the latency is 60 seconds, then during the propagation window, if there are no messages to be propagated,then messages from that queue for the destination will not be propagated for at least 60 more seconds. It will be at least 60 seconds before the queue will be checked again for messages to be propagated for the specified destination. If the latency is 600, then the queue will not be checked for 10 minutes and if the latency is 0, then a job queue process will be waiting for messages to be enqueued for the destination and as soon as a message is enqueued it will be propagated.
Propagation parameters can be set using the ALTER_PROPAGATION_SCHEDULE procedure from the DBMS_AQADM package. For example, to set the latency parameter of the streams propagation from the STREAMS_QUEUE owned by STRMADMIN to the target database whose global_name is DEST_DB, use the following syntax while logged in as the Streams Administrator:
Section 6: Streams site types: Target Configuration ===================================================
The following recommendations apply to target databases, ie, databases in which Streams apply is configured.
1. Grant the necessary privileges to the Streams Administrator.
2. Apply Process Configuration
A. Rules
Use the ADD_*_RULES procedures (ADD_TABLE_RULES , ADD_SCHEMA_RULES , ADD_GLOBAL_RULES (for DML and DDL), ADD_SUBSET_RULES (DML only). These procedures minimize the number of steps required to configure Streams processes. Also, it is possible to create rules for non-existent objects, so be sure to check the spelling of each object specified in a rule carefully.
APPLY can be configured with or without a ruleset. The ADD_GLOBAL_RULES can be used to apply all changes in the queue for the database.
A single Streams apply can process rules for multiple tables or schemas located in a single queue that are received from a single source database. For best performance, rules should be simple. Rules that include NOT or LIKE clauses are not simple and will impact the performance of Streams.
Minimize the number of rules added into the process rule set. A good rule of thumb is to keep the number of rules in the rule set to less than 100. If more objects need to be included in the ruleset, consider constructing rules using the IN clause. For example, a rule for the 6 TB_M21* tables in the MYACCT schema would look like the following (:dml.get_object_owner() = 'MYACCT' and :dml.is_null_tag() = 'Y' and :dml.get_object_name() IN ('TB_M21_1','TB_M21_2','TB_M21_3', 'TB_M21_40','TB_M21_10','TB_M211B010'))
B. Parameters
Set the following parameters after a apply process is created:
DISABLE_ON_ERROR=N
If Y, then the apply process is disabled on the first unresolved error, even if the error is not fatal. If N, then the apply process continues regardless of unresolved errors.
PARALLELISM=3 * Number of CPU
Apply parameters can be set using the SET_PARAMETER procedure from the DBMS_APPLY_ADM package. For example, to set the DISABLE_ON_ERROR parameter of the streams apply process named APPLY_EX, use the following syntax while logged in as the Streams Administrator:
RELATED DOCUMENTS ----------------- Oracle9i Streams Release 2 (9.2) Note 298877.1 10g Streams Recommended Configuration Note 259609.1 Script to Prevent Excessive Spill of Message From the Streams Buffer Queue To Disk Note 224255.1 Steps To Setup Replication Using Oracle Streams Note 301431.1 How To Setup Schema Level Streams Replication Note 273674.1 Streams Configuration Report and Health Check Script Note 290605.1 Oracle Streams STRMMON Monitoring Utility Note 238455.1 Streams Supported and Unsupported Datatypes Note 265201.1 Troubleshooting Streams Error ORA-1403 No Data Found
发现上面的方法太麻烦,想出一个简单的方法: create or replace procedure up_check_remotearch as v_arch number(3); begin select count(*) into v_arch from v$archived_log where sequence# in (select max(sequence#) from v$archived_log); if v_arch = 1 then sys.dbms_system.ksdwrt(2,'ORA-99999 远程归档已经停止,请检查!'); else sys.dbms_system.ksdwrt(2,'监控状态: 远程归档正常运行,请放心!'); end if; end;
var job number; exec dbms_job.submit(:job,'up_check_remotearch;',sysdate,'sysdate+5/1440');
test: admin = false admgroups = system ttys = !/dev/pts/0,ALL
结果是用户test可以在除了pts/0以外的所有端口登录,当test在pts/0登录时, 系统报错You are not allowed to access the system via this terminal.
IBM pSeries和 RS/6000 哪些型号可以安装SuSE linux?
环境 平台:RS 问题 IBM pSeries和 RS/6000 哪些型号可以安装SuSE linux? 解答 到2002年6月4日为止,RS6/6000 B50,150 和F50可以安装SuSE Linux for PowerPC Version 6.4 (支持32位内核);目前pSeries 和 RS/6000 中除p680外均可安装SuSE Linux Enterprise Server (SLES) Version 7(支持64位内核)。
环境 RS6000 问题 夏时制问题 解答 每年四月到八月,AIX会缺省使用夏时制,可以用echo $TZ看时区来判断,时区以DT结尾的就使用了夏时制。如果不想用,可以通过smit--system environment--change show date and time---change time zone using system defined values来改变,在弹出的USE DAYTIME SAVING对话框中选择No,选好相应的时区后重启机器既可。
环境 产品: AIX 平台: RS 软件版本: AIX V4 问题 客户有一个自己开发的应用,其中需要对ctrl+y的响应,来完成特定功能。 但当客户实现时,却发现一按ctrl+y程序就退出了。 解答 客户使用的是telnet终端,其中需要对pty的属性进行修改。 #smit pty Change / Show Characteristics of the PTY STATE to be configured at boot time ---------------available -----+ Maximum number of Pseudo-Terminals ---------[256]---------------- # Maximum number of BSD Pseudo-Terminals -----[16] 其中并没有象tty一样的许多选项: #smit tty POSIX special control characters:
INTERRUPT character ------------------------[^c] QUIT character -----------------------------[^] ERASE character ----------------------------[^h] KILL character -----------------------------[^u] END OF FILE character ----------------------[^d] END OF LINE character ----------------------[^@] 2nd END OF LINE character ------------------[^?] DELAY SUSPEND PROCESS character ------------[^y] SUSPEND PROCESS character ------------------[^z] LITERAL NEXT character ---------------------[^v] START character ----------------------------[^q]
xlC.aix43.rte 4.0.2.1 COMMITTED C Set ++ Runtime for AIX 4.3 xlC.cpp 4.3.0.1 COMMITTED C for AIX Preprocessor xlC.msg.en_US.cpp 4.3.0.1 COMMITTED C for AIX Preprocessor xlC.msg.en_US.rte 4.0.2.0 COMMITTED C Set ++ Runtime xlC.msg.zh_CN.rte 4.0.2.0 COMMITTED C Set ++ Runtime xlC.rte COMMITTED 4.0.2.0 COMMITTED C Set ++ Runtime
内容 提要 本文将就AIX Affinity with Linux的发展以及在AIX操作系统下如何进行Linux的开发和如何将自由开发的Linux应用移植到AIX操作系统做介绍,目的是让更多的朋友在AIX系统平台上使用Linux, 并同时感受到AIX操作系统在整体性能上的魅力。我们期待着有更多更好的Linux应用被移植到AIX操作平台,使AIX操作系统更加丰富多彩,让我们工作得更轻松自如。 第一部分 AIX Affinity with Linux 的发展情况 第二部分 AIX Affinity 的其本原理介绍 第三部分 AIX Toolbox for Linux 最新版的获得、安装、包含工具和基本使用 第四部分 对开发的建议 说明 任何机型,操作系统 AIX 4.3.3 or AIX 5L 正文 第一部分 AIX Affinity with Linux 的发展情况
IBM对AIX Affinity with Linux的发展分为以下两个阶段。
第一个阶段,发布AIX Toolbox for Linux Applications, 它主要包含GNU和其他一些常用开发工具,来帮助开发人员在AIX系统上编译程序,并在两种行业内开放性最好的操作系统平台,即AIX和Linux之间,进行平滑技术移植。由于应用程序运行于AIX环境中,因此客户可以同时得到Linux的灵活性和AIX操作系统的先进性能,包括工作负载管理、先进系统管理工具以及高安全性。
第二个阶段是,在最新发布的AIX 5L Version 5.1 操作系统中提供更多的兼容Linux的API和头文件,来支持源文件的兼容性,使两个不同操作系统有更强的互操作性,从而达到更高程度的兼容。
那么我们能用AIX Affinity for Linux做什么呢?
1。在AIX系统上使用众多Linux上开发的自由软件,例如,运行流行的 Gnome and KDE 图形桌面,运行其他的多媒体工具,等等。 2。用功能强大的RedHat Package Manager包工具管理应用。 3。在AIX 系统上,使用GNU和Linux开发工具进行新应用的开发。
第二部分 AIX Affinity 的其本原理介绍 AIX Affinity with Linux的目的并不是在系统中提供一个模拟层供Linux应用来运行,它的意义在于通过重新编译Linux应用后,得到AIX的兼容的二进制本地代码,并能使用所有系统的特性,如可靠性、扩展性、以及可用性。这就是说,我们提供了一个强大的跨平台编译器以及众多的兼容API来保证Linux应用在AIX系统上的成功移植。
由于AIX的设计开发从网络、主机硬件系统,到操作系统完全遵守开放系统的原则,所以在目前的AIX 4.3.3 和 AIX 5L Version 5.0, 使用AIX Toolbox for Linux,只需通过简单的编译就能在AIX平台上实现Linux的很多应用。这样,我们就不用浪费许多人力、物力去重新开发很多已经很成熟的应用。我们不断地重用经典代码,就可以把我们有限的精力投入到更精彩、更需要的地方。 当使用AIX Affinity with Linux时,我们还会想到的它对性能的影响。AIX Affinity with Linux在设计阶段,就希望提供最优化的性能给应用,其中包括让Linux应用和本地应用享有同样访问资源的权利。尤其是AIX 5L Version 5.1操作系统,会提供更高级别的应用与操作系统间的兼容性。当我们考虑性能时,还应该想到我们要开发什么样的应用,前端的还是后台的。后台的大型应用还是比较适合AIX应用,但前端的人机界面用Linux则更能发挥其特长,也减少了可能的性能影响。
ssh -l [your accountname on the remote host] [address of the remote host]
如果OpenSSH工作正常,你会看到下面的提示信息:
The authenticity of host [hostname] can't be established. Key fingerprint is 1024 5f:a0:0b:65:d3:82:df:ab:44:62:6d:98:9c:fe:e9:52. Are you sure you want to continue connecting (yes/no)?
Generating RSA keys: ............................ooooooO......ooooooO Key generation complete. Enter file in which to save the key (/home/[user]/.ssh/identity): [按下ENTER就行了] Created directory '/home/[user]/.ssh'. Enter passphrase (empty for no passphrase): [输入的口令不会显示在屏幕上] Enter same passphrase again: [重新输入一遍口令,如果忘记了口令就只能重新生成一次密匙了] Your identification has been saved in /home/[user]/.ssh/identity. [这是你的私人密匙] Your public key has been saved in /home/[user]/.ssh/identity.pub. The key fingerprint is: 2a:dc:71:2f:27:84:a2:e4:a1:1e:a9:63:e2:fa:a5:89 [user]@[local machine]
Host *fbc HostName www.foobar.com User bilbo ForwardAgent yes Compression yes # Be paranoid by default Host * ForwardAgent no ForwardX11 no FallBackToRsh no
当然,这个方法要求你手工输入所有的POP命令,这是很不方便的。可以用Fetchmail(参考how to configure Fetchmail)。Secure POP via SSH mini-HOWTO、man fetchmail和在“/usr/doc/fetchmail-[…]”目录下的Fetchmail的FAQ都提供了一些具体的例子。
10g Stream Replication 的新特征 在9iR2中,oracle stream组合advance queuing technique, replication methodology, data warehousing, and the event management system等技术; 在10g中,oracle又增加了一些新的、有用的功能,并改善了stream的配置与管理: 配置改善(Configuration Changes) 许多配置已经简化啦,提供了更集成的工具,比如简化了授权方法等。 begin dbms_streams_auth.grant_admin_privilege( grantee => 'strmadmin', grant_privileges => true); end; / 异地捕获(Down Stream Capture) 它允许将capture process配置在非source database上进行捕获,减轻产品库负载。
规则集改善(Rules Set Changes) 捕获、传播、应用进程可以利用the positive rule set and a negative rule set。 Streams Pool In SGA 为stream 提供了专用的stream buffers,在9iR2中它是分配为shared pool的10%。
RAC支持(Support for RAC) 支持RAC的online redo log捕获,减少数据同步时间, 9iR2中capture进程只能捕获RAC的archive redo log。 Migrate from Advanced Replication to Streams 提供了脚本方便将Advanced Replication迁移到Stream。 消息机制(Messaging Mechanism) 改进并简化了消息的入队与出列,消息通知等功能。 清除队列(Purge Streams Queues) 完善了9iR2的清除队列与队列表的工具。 begin dbms_aqadm.purge_queue_table ( queue_table => 'strmadmin.streams_queue', purge_condition => 'consumer_name=''sales_apply'' ', block => false); end; /
a 情况 enable storage in row create table test_clob_in(id int,name varchar2(20),clob_1 clob,clob_2 clob); alter table test_clob_in modify clob_1 default empty_clob(); alter table test_clob_in modify clob_2 default empty_clob(); b 情况 disable storage in row create table test_clob_out(id int,name varchar2(20),clob_1 clob,clob_2 clob) lob (clob_1) store as (disable storage in row chunk 8k) lob (clob_2) store as (disable storage in row chunk 8k); alter table test_clob_out modify clob_1 default empty_clob(); alter table test_clob_out modify clob_2 default empty_clob(); c 情况 data与clob分两个表 create table test_clob_1(id int,name varchar2(20)); create table test_clob_2(id int,clob_1 clob,clob_2 clob); alter table test_clob_2 modify clob_1 default empty_clob(); alter table test_clob_2 modify clob_2 default empty_clob(); d 情况 data与clob分两个表 create table test_clob_3(id int,name varchar2(20)); create table test_clob_4(id int,clob_1 clob,clob_2 clob) lob (clob_1) store as (disable storage in row chunk 8k) lob (clob_2) store as (disable storage in row chunk 8k); alter table test_clob_4 modify clob_1 default empty_clob(); alter table test_clob_4 modify clob_2 default empty_clob();
a 测试脚本: set timing on set time on begin for i in 1..50000 loop insert into test_clob_in values(i,to_char(i),'clob_1'||to_char(i),'clob_2'||to_char(i)); if mod(i,1000)=0 then commit; end if; end loop; commit; end; / PL/SQL procedure successfully completed. Elapsed: 00:00:12.50
b 测试脚本 begin for i in 1..50000 loop insert into test_clob_out values(i,to_char(i),'clob_1'||to_char(i),'clob_2'||to_char(i)); if mod(i,1000)=0 then commit; end if; end loop; commit; end; / 当lob被disable storage in row时,播入数据极慢,28分钟后,取消测试, 些时只完成30000条的任务,故不再测试b/d方案(disable store in row).
c 测试脚本 begin for i in 1..50000 loop insert into test_clob_1 values(i,to_char(i)); insert into test_clob_2 values(i,'clob_1'||to_char(i),'clob_2'||to_char(i)); if mod(i,1000)=0 then commit; end if; end loop; commit; end; / PL/SQL procedure successfully completed. Elapsed: 00:00:24.58
d 测试脚本 begin for i in 1..50000 loop insert into test_clob_3 values(i,to_char(i)); insert into test_clob_4 values(i,'clob_1'||to_char(i),'clob_2'||to_char(i)); if mod(i,1000)=0 then commit; end if; end loop; commit; end; / 说明:初步测试后,a/c(enable store in row)方案将进行下一轮测试,
--刷新buffer cache alter session set events 'immediate trace name flush_cache';
--测试它们的select性能. select count(*) from test_clob_in; COUNT(*) ---------- 50000 Elapsed: 00:00:00.17 select count(*) from test_clob_1; COUNT(*) ---------- 50000 Elapsed: 00:00:00.01
总结: clob在使用disable store in row时对insert性能影响很大,对select影响较小; clob在使用enable store in row时与不含clob的表相比,对select影响较大, 含clob的表,如果不是经常查询clob的值,可以将clob与访问频繁的表分离.
3. 系统错误报告(Error Log)的检查: 硬件故障检测命令:# errpt -d H -T PERM 若有故障执行命令# errpt -a -d H -T PERM>/tmp/harderror.log保存,分析结果报告给客户 软件故障检测命令:# errpt -d S -T PERM 若有故障执行命令# errpt -a -d S -T PERM>/tmp/softerror.log保存,分析结果报告给客户
4. 有否发给root用户的错误报告(mail): #mail 1. 观察所有未读消息,注意有关diagela的消息。 2. 常用命令: h [] Display headings of group containing message t [] Display messages in or current message. n Display next message. q Quit 3. 对发现的问题详细分析,结果报告给客户
11.补丁程序(PTF)的检查 1. 系统维护补丁版本为ML09,检查命令为: #instfix –i |grep ML
12.系统参数的检查 1.HIGH water mark for pending write I/Os # lsattr -El sys0 |grep maxpout 输出判断: 结果应为 maxpout 33 HIGH water mark for pending write I/Os per file True 2.LOW water mark for pending write I/Os # lsattr -El sys0|grep minpout 输出判断: 结果应为 minpout 24 LOW water mark for pending write I/Os per file True 更改命令为: #chdev -l sys0 -a maxpout='33' -a minpout='24'
3.Syncd参数 # grep syncd /sbin/rc.boot 输出判断: 结果应为 nohup /usr/sbin/syncd 10 > /dev/null 2>&1 & 更改命令为: #vi /sbin/rc.boot http://www.uxma.com/sheke/news/pic/8.swf 4.aio参数 # lsdev -Cc aio 输出判断: 结果应为 aio0 Available Asynchronous I/O # lsattr -El aio0 输出判断: 结果应为 minservers 1 MINIMUM number of servers True maxservers 10 MAXIMUM number of servers True maxreqs 4096 Maximum number of REQUESTS True kprocprio 39 Server PRIORITY True autoconfig available STATE to be configured at system restart True fastpath enable State of fast path True 更改命令为: #smitty aio
Oracle Server - Enterprise Edition - Version: 9.2.0.6 This problem can occur on any platform.
Symptoms
Trace file produced containing message kwqjswproc: excep After loop: ASSIGNING to self
Cause
There are not enough job queue processes available for job activities.
select * from dba_queue_schedules; This will indicates queue schedules existing which relate to this message being generated.
If you enable then disable and trace as follow to get more information :
alter system set events '24040 trace name context forever,level 10'; let this run for a little time 5 minutes then disable this using : alter system set events '24040 trace name context off';
You will likely see the following :
(from the trace file): kwqjswproc: job_q_procs is 2 kwqjswproc: aq_procs = 1 ; non_aq_procs = 1 kwqjswproc: system_load = 0 ; avg_load = 0 kwqjswproc: assigning to existing proc kwqjswproc: OLD assigned proc indx = 1 kwqjswproc: excep After loop: ASSIGNING to self kwqjswproc: NEW assigned proc indx = 0
The is is a warning message which indicates that should prompt the value of job_queue_processes to be increased. ie typically, set job_queue_processes=10
1 Instance Setup (参与stream replication的实例) alter system set job_queue_processes=1; alter system set aq_tm_processes=1; alter system set global_names=true; alter system set compatible='9.2.0' scope=spfile; alter system set log_parallelism=1 scope=spfile; shutdown immediate; startup; 说明: job_queue_processes与aq_tm_processes最好设置为>2, 如果想开多个capture进程,需要修改logmnr_max_persistent_sessions参数的值
2 Archive log (源数据库必须为归档状态) alter system set log_archive_start=true scope=spfile; shutdown immediate; startup mount; alter database archivelog; alter database open;
3 Stream Administrator Setup (在源数据库上创建) conn sys/oracle@test45 as sysdba create tablespace orastream datafile '/oradata/orastream01.dbf' size 100m autoextend on;
create user strmadmin identified by strmadminpw default tablespace orastream quota unlimited on orastream; grant connect, resource, select_catalog_role to strmadmin;
grant execute on dbms_aqadm to strmadmin; grant execute on dbms_capture_adm to strmadmin; grant execute on dbms_propagation_adm to strmadmin; grant execute on dbms_streams_adm to strmadmin; grant execute on dbms_apply_adm to strmadmin; grant execute on dbms_flashback to strmadmin;
4 Stream Administrator Setup (在目标数据库上创建) conn sys/sys@test44 as sysdba create tablespace orastream datafile '/var/oradata/orastream01.dbf' size 100m autoextend on;
create user strmadmin identified by strmadminpw default tablespace orastream quota unlimited on orastream; grant connect, resource, select_catalog_role to strmadmin;
grant execute on dbms_aqadm to strmadmin; grant execute on dbms_capture_adm to strmadmin; grant execute on dbms_propagation_adm to strmadmin; grant execute on dbms_streams_adm to strmadmin; grant execute on dbms_apply_adm to strmadmin; grant execute on dbms_flashback to strmadmin;
conn sys/oracle@test46 as sysdba create tablespace orastream datafile '/data2/orastream01.dbf' size 100m autoextend on;
create user strmadmin identified by strmadminpw default tablespace orastream quota unlimited on orastream; grant connect, resource, select_catalog_role to strmadmin;
grant execute on dbms_aqadm to strmadmin; grant execute on dbms_capture_adm to strmadmin; grant execute on dbms_propagation_adm to strmadmin; grant execute on dbms_streams_adm to strmadmin; grant execute on dbms_apply_adm to strmadmin; grant execute on dbms_flashback to strmadmin;
--在test45机器上指向44/46号机器 connect strmadmin/strmadminpw@test45; create database link testdb1 connect to strmadmin identified by strmadminpw using 'test44'; create database link testdbc connect to strmadmin identified by strmadminpw using 'test46';
--在test44机器上指向45/46号机器 connect strmadmin/strmadminpw@test44; create database link testdb2 connect to strmadmin identified by strmadminpw using 'test45'; create database link testdbc connect to strmadmin identified by strmadminpw using 'test46';
--在test46机器上指向44/45号机器 connect strmadmin/strmadminpw@test46; create database link testdb1 connect to strmadmin identified by strmadminpw using 'test44'; create database link testdb2 connect to strmadmin identified by strmadminpw using 'test45'; 说明:必须确保双方的数据库链是可以连通.
5 创建测试模式并授权(源数据库与目标数据库都做) connect / as sysdba; create user scott identified by tiger default tablespace orastream quota unlimited on orastream; grant connect,resource to scott;
connect scott/tiger; create table dept(id int primary key,name varchar2(20)); grant all on dept to strmadmin;
删除目标数据库的附加日志 conn sys/sys@test44 as sysdba; alter table scott.dept drop supplemental log group log_group_dept_pk; conn sys/oracle@test46 as sysdba; alter table scott.dept drop supplemental log group log_group_dept_pk;
12 Configure Apply Process (目标数据库上配置应用进程) connect strmadmin/strmadminpw@test44; begin dbms_streams_adm.add_table_rules( table_name => 'scott.dept', streams_type => 'apply', streams_name => 'apply_simp', queue_name => 'strmadmin.streams_queue', include_dml => true, include_ddl => true, source_database => 'testdb2'); end; / connect strmadmin/strmadminpw@test46; begin dbms_streams_adm.add_table_rules( table_name => 'scott.dept', streams_type => 'apply', streams_name => 'apply_simp', queue_name => 'strmadmin.streams_queue', include_dml => true, include_ddl => true, source_database => 'testdb2'); end; / 13 Start Apply Process (在目标数据库上启动应用进程) connect strmadmin/strmadminpw@test44; begin dbms_apply_adm.stop_apply( apply_name => 'apply_simp'); dbms_apply_adm.set_parameter( apply_name => 'apply_simp', parameter => 'disable_on_error', value => 'n'); dbms_apply_adm.start_apply( apply_name => 'apply_simp'); end; / connect strmadmin/strmadminpw@test46; begin dbms_apply_adm.stop_apply( apply_name => 'apply_simp'); dbms_apply_adm.set_parameter( apply_name => 'apply_simp', parameter => 'disable_on_error', value => 'n'); dbms_apply_adm.start_apply( apply_name => 'apply_simp'); end; / 14 Start Capture Process (在源数据库上启动捕获进程) connect strmadmin/strmadminpw@test45 begin dbms_capture_adm.start_capture( capture_name => 'capture_simp'); end; / 15 测试(不支持truncate table...) begin for i in 1..10000 loop insert into dept values(i,to_char(i)); if mod(i,100)=0 then commit; end if; end loop; commit; end; / begin for i in 1..10000 loop insert into test values(i,to_char(i),sysdate); if mod(i,100)=0 then commit; end if; end loop; commit; end; / create sequence test_pk; create sequence dept_pk; create or replace procedure up_test_stream as begin for i in 1..10000 loop insert into dept values(dept_pk.nextval,to_char(i)); insert into test values(dept_pk.nextval,to_char(i),sysdate); if mod(i,100)=0 then commit; end if; end loop; commit; end; / variable job number; exec dbms_job.submit(:job,'up_test_stream;',sysdate,'sysdate+1/14400');
16 清除测试过程 select s.user_data.gettypename() from streams_queue_table s;
set serveroutput on declare v_anydata sys.anydata; v_lcr sys.lcr$_row_record; v_row_list sys.lcr$_row_list; v_result pls_integer; begin select user_data into v_anydata from strmadmin.streams_queue_table where rownum < 2; v_result := anydata.getobject( self => v_anydata, obj => v_lcr); dbms_output.put_line('command type : ' || v_lcr.get_command_type); dbms_output.put_line('object owner : ' || v_lcr.get_object_owner); dbms_output.put_line('object name : ' || v_lcr.get_object_name); dbms_output.put_line('source database name : ' || v_lcr.get_source_database_name); end; / begin for cur_rec in (select rule_owner,rule_name from dba_rules) loop dbms_rule_adm.drop_rule( rule_name => cur_rec.rule_owner || '.' || cur_rec.rule_name, force => true); end loop; end; / begin for cur_rec in (select capture_name from dba_capture) loop dbms_capture_adm.stop_capture( capture_name => cur_rec.capture_name); dbms_capture_adm.drop_capture( capture_name => cur_rec.capture_name); end loop; for cur_rec in (select apply_name from dba_apply) loop dbms_apply_adm.stop_apply( apply_name => cur_rec.apply_name); dbms_apply_adm.drop_apply( apply_name => cur_rec.apply_name); end loop; end; / connect strmadmin/strmadminpw@test45 begin dbms_streams_adm.purge_source_catalog( source_database => 'testdb2', source_object_name => 'scott.dept', source_object_type => 'table'); end; / connect strmadmin/strmadminpw@test45 begin for cur_rec in (select propagation_name from dba_propagation) loop dbms_propagation_adm.drop_propagation(cur_rec.propagation_name); end loop; end; /
17 添加其它要传播表(源数据库上添加) connect scott/tiger@test45; create table test(id int primary key,name varchar2(20),log_time date); alter table test add supplemental log group log_group_test_pk (id) always; grant all on test to strmadmin;
25 流复制于逻辑备用库的区别? 流复制数据可以被updated,逻辑备用库不可以 流复制可以基于异构平台,逻辑备用库不可以 流复制可以与主站点有不同的字符集,逻辑备用库不可以 挖掘online log以减少传播时间 流复制可以有多于10份的拷贝,逻辑备用库不可以 流复制一次捕获LCRs,将可以发送到多个站点 流与逻辑备用库不可共存,如果希望他们共存,必须用Streams APIs创建与维护逻辑备用库. Standby SQL apply mode and Streams are not supported on the same database. RAC中的流复制只能从archived log中miner sql.
26 Best Practices for Streams High Availability Environments Configuring Streams for High Availability Directly Connecting Every Database to Every Other Database Creating Hub and Spoke Configurations Configuring Oracle Real Application Clusters with Streams Recovering from Failures Reestablishing Database Links After a Failover Restarting Capture After a Failover Restarting Propagation After a Failover Restarting Apply After a Failover
27 检测正在进行捕获的表 column table_owner heading 'table owner' format a15 column table_name heading 'table name' format a15 column scn heading 'instantiation scn' format 999999999999 column timestamp heading 'time ready for|instantiation' select table_owner, table_name, scn, to_char(timestamp, 'hh24:mi:ss mm/dd/yy') timestamp from dba_capture_prepared_tables;
column log_group_name heading 'log group' format a20 column table_name heading 'table' format a20 column always heading 'type of log group' format a30 select log_group_name,table_name, decode(always,'always','unconditional',null,'conditional') always from dba_log_groups;
column owner heading 'owner' format a10 column name heading 'queue name' format a25 column queue_table heading 'queue table' format a20 column user_comment heading 'comment' format a20 select q.owner,q.name,t.queue_table,q.user_comment from dba_queues q, dba_queue_tables t where t.object_type = 'sys.anydata' and q.queue_table = t.queue_table and q.owner = t.owner;
column 'source queue' format a35 column 'destination queue' format a35 select p.source_queue_owner ||'.'|| p.source_queue_name ||'@'|| g.global_name "source queue", p.destination_queue_owner ||'.'|| p.destination_queue_name ||'@'|| p.destination_dblink "destination queue" from dba_propagation p, global_name g where propagation_name = upper('test45_to_test44');
28 如果完全清除流复制的字典信息 col object_name format a32 select object_name from dba_objects where object_name like '%APPLY%' and object_type='TABLE'; select object_name from dba_objects where object_name like '%STREAM%' and object_type='TABLE'; 清除SYS中的字典表中的信息即可.
29 ORA-26701: STREAMS process APPLY_XXX不存在的处理 -- remove all the rules associated with the apply process begin dbms_streams_adm.remove_rule( rule_name => null, streams_type => 'apply', streams_name => 'APPLY_SIMP'); end; / -- stop the apply process. begin dbms_apply_adm.stop_apply( apply_name => 'apply_simp', force => true); end; / -- drop the apply process. begin dbms_apply_adm.drop_apply(apply_name => 'apply_simp'); end;
30 ORA-26666: cannot alter STREAMS process APPLY_SIMP的处理方法 connect strmadmin/strmadminpw@test46; begin dbms_apply_adm.stop_apply( apply_name => 'apply_simp'); dbms_apply_adm.set_parameter( apply_name => 'apply_simp', parameter => 'disable_on_error', value => 'n'); dbms_apply_adm.start_apply( apply_name => 'apply_simp'); end; /
1 Instance Setup (参与stream replication的实例) alter system set job_queue_processes=1; alter system set aq_tm_processes=1; alter system set global_names=true; alter system set compatible='9.2.0' scope=spfile; alter system set log_parallelism=1 scope=spfile; shutdown immediate; startup;
2 Archive log (源数据库必须为归档状态) alter system set log_archive_start=true scope=spfile; shutdown immediate; startup mount; alter database archivelog; alter database open;
3 Stream Administrator Setup (在源数据库上创建) conn sys/oracle@test45 as sysdba create tablespace orastream datafile '/oradata/orastream01.dbf' size 100m autoextend on;
create user strmadmin identified by strmadminpw default tablespace orastream quota unlimited on orastream; grant connect, resource, select_catalog_role to strmadmin;
grant execute on dbms_aqadm to strmadmin; grant execute on dbms_capture_adm to strmadmin; grant execute on dbms_propagation_adm to strmadmin; grant execute on dbms_streams_adm to strmadmin; grant execute on dbms_apply_adm to strmadmin; grant execute on dbms_flashback to strmadmin;
create database link testdbc connect to strmadmin identified by strmadminpw using 'testdbc'
4 Stream Administrator Setup (在目标数据库上创建) conn sys/oracle@test46 as sysdba create tablespace orastream datafile '/data2/orastream01.dbf' size 100m autoextend on;
conn sys/oracle@test46 as sysdba create user strmadmin identified by strmadminpw default tablespace orastream quota unlimited on orastream; grant connect, resource, select_catalog_role to strmadmin;
grant execute on dbms_aqadm to strmadmin; grant execute on dbms_capture_adm to strmadmin; grant execute on dbms_propagation_adm to strmadmin; grant execute on dbms_streams_adm to strmadmin; grant execute on dbms_apply_adm to strmadmin; grant execute on dbms_flashback to strmadmin;
create database link testdb2 connect to strmadmin identified by strmadminpw using 'testdb2' 说明:必须确保双方的数据库链是可以连通.
5 创建测试模式并授权(源数据库与目标数据库都做) connect / as sysdba; create user scott identified by tiger default tablespace orastream quota unlimited on orastream; grant connect,resource to scott;
connect scott/tiger; create table dept(id int primary key,name varchar2(20)); grant all on dept to strmadmin;
删除目标数据库的附加日志 conn sys/oracle@test46 as sysdba alter table scott.dept drop supplemental log group log_group_dept_pk;
11 Alternatively the instantiation SCN can be set using the DBMS_APPLY_ADM package: connect strmadmin/strmadminpw@test45 declare v_scn number; begin v_scn := dbms_flashback.get_system_change_number(); dbms_apply_adm.set_table_instantiation_scn@testdbc( source_object_name => 'scott.dept', source_database_name => 'testdb2', instantiation_scn => v_scn); end; / 12 Configure Apply Process (目标数据库上配置应用进程) connect strmadmin/strmadminpw@test46; begin dbms_streams_adm.add_table_rules( table_name => 'scott.dept', streams_type => 'apply', streams_name => 'apply_simp', queue_name => 'strmadmin.streams_queue', include_dml => true, include_ddl => true, source_database => 'testdb2'); end; / 13 Start Apply Process (在目标数据库上启动应用进程) connect strmadmin/strmadminpw@test46; begin dbms_apply_adm.set_parameter( apply_name => 'apply_simp', parameter => 'disable_on_error', value => 'n'); dbms_apply_adm.start_apply( apply_name => 'apply_simp'); end; / 14 Start Capture Process (在源数据库上启动捕获进程) connect strmadmin/strmadminpw@test45 begin dbms_capture_adm.start_capture( capture_name => 'capture_simp'); end; / 15 测试(不支持truncate table...) begin for i in 1..10000 loop insert into dept values(i,to_char(i)); if mod(i,100)=0 then commit; end if; end loop; commit; end;
create sequence test_pk; create sequence dept_pk; create or replace procedure up_test_stream as begin for i in 1..10000 loop insert into dept values(dept_pk.nextval,to_char(i)); insert into test values(dept_pk.nextval,to_char(i),sysdate); if mod(i,100)=0 then commit; end if; end loop; commit; end; / variable job number; exec dbms_job.submit(:job,'up_test_stream;',sysdate,'sysdate+1/14400');
16 清除测试过程 select s.user_data.gettypename() from streams_queue_table s;
set serveroutput on declare v_anydata sys.anydata; v_lcr sys.lcr$_row_record; v_row_list sys.lcr$_row_list; v_result pls_integer; begin select user_data into v_anydata from strmadmin.streams_queue_table where rownum < 2; v_result := anydata.getobject( self => v_anydata, obj => v_lcr); dbms_output.put_line('command type : ' || v_lcr.get_command_type); dbms_output.put_line('object owner : ' || v_lcr.get_object_owner); dbms_output.put_line('object name : ' || v_lcr.get_object_name); dbms_output.put_line('source database name : ' || v_lcr.get_source_database_name); end; / begin for cur_rec in (select rule_owner, rule_name from dba_rules) loop dbms_rule_adm.drop_rule( rule_name => cur_rec.rule_owner || '.' || cur_rec.rule_name, force => true); end loop; end; / begin for cur_rec in (select capture_name from dba_capture) loop dbms_capture_adm.stop_capture( capture_name => cur_rec.capture_name); dbms_capture_adm.drop_capture( capture_name => cur_rec.capture_name); end loop; for cur_rec in (select apply_name from dba_apply) loop dbms_apply_adm.stop_apply( apply_name => cur_rec.apply_name); dbms_apply_adm.drop_apply( apply_name => cur_rec.apply_name); end loop; end; / begin dbms_streams_adm.purge_source_catalog( source_database => 'testdbc', source_object_name => 'scott.dept', source_object_type => 'table'); end; /
17 添加其它要传播表(源数据库上添加) connect scott/tiger@test45; create table test(id int primary key,name varchar2(20),log_time date); alter table test add supplemental log group log_group_test_pk (id) always; grant all on test to strmadin;
25 流复制于逻辑备用库的区别? 流复制数据可以被updated,逻辑备用库不可以 流复制可以基于异构平台,逻辑备用库不可以 流复制可以与主站点有不同的字符集,逻辑备用库不可以 挖掘online log以减少传播时间 流复制可以有多于10份的拷贝,逻辑备用库不可以 流复制一次捕获LCRs,将可以发送到多个站点 流与逻辑备用库不可共存,如果希望他们共存,必须用Streams APIs创建与维护逻辑备用库. Standby SQL apply mode and Streams are not supported on the same database. RAC中的流复制只能从archived log中miner sql.
26 Best Practices for Streams High Availability Environments Configuring Streams for High Availability Directly Connecting Every Database to Every Other Database Creating Hub and Spoke Configurations Configuring Oracle Real Application Clusters with Streams Recovering from Failures Reestablishing Database Links After a Failover Restarting Capture After a Failover Restarting Propagation After a Failover Restarting Apply After a Failover
27 检测正在进行捕获的表 column table_owner heading 'table owner' format a15 column table_name heading 'table name' format a15 column scn heading 'instantiation scn' format 999999999999 column timestamp heading 'time ready for|instantiation' select table_owner, table_name, scn, to_char(timestamp, 'hh24:mi:ss mm/dd/yy') timestamp from dba_capture_prepared_tables;
column log_group_name heading 'log group' format a20 column table_name heading 'table' format a20 column always heading 'type of log group' format a30 select log_group_name,table_name, decode(always,'always','unconditional',null,'conditional') always from dba_log_groups;
column owner heading 'owner' format a10 column name heading 'queue name' format a25 column queue_table heading 'queue table' format a20 column user_comment heading 'comment' format a20 select q.owner, q.name, t.queue_table, q.user_comment from dba_queues q, dba_queue_tables t where t.object_type = 'sys.anydata' and q.queue_table = t.queue_table and q.owner = t.owner;
column 'source queue' format a35 column 'destination queue' format a35 select p.source_queue_owner ||'.'|| p.source_queue_name ||'@'|| g.global_name "source queue", p.destination_queue_owner ||'.'|| p.destination_queue_name ||'@'|| p.destination_dblink "destination queue" from dba_propagation p, global_name g where propagation_name = upper('test45_to_test46');
然后配置主从三台机器的tns,配置完毕后,进入rac的node1, 发现该RAC已经有一个standby机啦,暂以db212为代号吧,所以 偶就理所当然地去修改log_archive_dest_3. ALTER SYSTEM SET log_archive_dest_3='SERVICE=db213' 修改完后查alter_sid.log文件发现一个错误: ORA-16040: standby destination archive log file is locked
QL> connect scott/tiger Connected. SQL> desc a1@testdbc ERROR: ORA-02085: database link TESTDBC connects to TESTDB1
SQL> host oerr ora 2085 02085, 00000, "database link %s connects to %s" // *Cause: a database link connected to a database with a different name. // The connection is rejected. // *Action: create a database link with the same name as the database it // connects to, or set global_names=false.
实际上在网络中已经没有叫TESTDB1的数据库啦,但由于该db_name 以前是TESTDB1,后来用nid修改db_name为TESTDBC,结果每次测试 db link时还是要求连接到修改前的数据库名. 查metalink,发现global_name字典中的停息并没有被一起修改 SQL> select * from global_name; GLOBAL_NAME ------------------------------- TESTDB1 用alter database rename global_name to TESTDBC; 然后再用desc a1@testdbc测试,一切正常.
nid DBNEWID: Release 9.2.0.6.0 - Production Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
Keyword Description (Default) ---------------------------------------------------- TARGET Username/Password (NONE) DBNAME New database name (NONE) LOGFILE Output Log (NONE) REVERT Revert failed change NO SETNAME Set a new database name only NO APPEND Append to output log NO HELP Displays these messages NO 通常情况下,如果你用nid修改了db_name,然后你可以用revert=y来取消, 如果某文件没有扩展名,该文件将不可以被打开.且不可以用revert=y来取消
NID-00100: Cannot open datafile "/opt/oradata/testdb2/tbs_auc_p1_2"
Streams Oracle Streams are a generic mechanism for sharing data which can be used as the basis of many processes including messaging, replication and warehouse ETL processes. They are an extension of a number of existing technologies including Advanced Queuing, LogMinor and Job Scheduling. This article presents a simple replication scenario as an example of their use:
Architecture Instance Setup Stream Administrator Setup LogMinor Tablespace Setup Supplemental Logging Configure Propagation Process Configure Capture Process Configure Instantiation SCN Configure Apply Process Start Apply Process Start Capture Process Test It Clean Up Basic Architecture
The processing of streams is divided into three main processes (Capture, Staging and Apply):
The capture process is an optional background process that mines DDL and DML changes from the redo logs and wraps them up as Logical Change Records (LCRs). In addition to the default capture mechanism user defined events can be enqueued directly. Staging involves storing the LCRs in queues of datatype SYS.AnyData. LCRs can be propogated between a source and destination staging area in different databases if necessary. Propagation is scheduled using job queues. The apply process is an optional background process that dequeues LCRs and either applies them directly or for user-defined messages passes them as parameters to user-defined packages. Both the capture and apply processes can use table, schema and database level rules to determine their actions.
Instance Setup In order to begin the following parameters should be set in the spfiles of participating databases:
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=1; ALTER SYSTEM SET AQ_TM_PROCESSES=1; ALTER SYSTEM SET GLOBAL_NAMES=TRUE; ALTER SYSTEM SET COMPATIBLE='9.2.0' SCOPE=SPFILE; ALTER SYSTEM SET LOG_PARALLELISM=1 SCOPE=SPFILE; SHUTDOWN IMMEDIATE; STARTUP; In addition, any databases involved in capture (DBA1) must be in ARCHIVELOG mode.
Stream Administrator Setup Next we create a stream administrator, a stream queue table and a database link on the source database:
CREATE USER strmadmin IDENTIFIED BY strmadminpw DEFAULT TABLESPACE users QUOTA UNLIMITED ON users;
GRANT CONNECT, RESOURCE, SELECT_CATALOG_ROLE TO strmadmin;
GRANT EXECUTE ON DBMS_AQADM TO strmadmin; GRANT EXECUTE ON DBMS_CAPTURE_ADM TO strmadmin; GRANT EXECUTE ON DBMS_PROPAGATION_ADM TO strmadmin; GRANT EXECUTE ON DBMS_STREAMS_ADM TO strmadmin; GRANT EXECUTE ON DBMS_APPLY_ADM TO strmadmin; GRANT EXECUTE ON DBMS_FLASHBACK TO strmadmin;
CREATE DATABASE LINK dba2 CONNECT TO strmadmin IDENTIFIED BY strmadminpw USING 'DBA2'; This process must be repeated on the destination database (DBA2). The reverse database link is not necessary in this example but the following grant must be added:
GRANT ALL ON scott.dept TO strmadmin; LogMinor Tablespace Setup Next we create a new tablespace to hold the logminor tables on the source database:
CREATE TABLESPACE logmnr_ts DATAFILE '/u01/app/oracle/oradata/DBA1/logmnr01.dbf' SIZE 25 M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
EXECUTE DBMS_LOGMNR_D.SET_TABLESPACE('logmnr_ts'); Supplemental Logging The apply process requires additional information for some actions so we must configure suplimental logging of primary key information for tables of interest:
CONN sys/password@DBA1 AS SYSDBA ALTER TABLE scott.dept ADD SUPPLEMENTAL LOG GROUP log_group_dept_pk (deptno) ALWAYS; Configure Propagation Process Configure the propagation process on DBA1:
CONNECT strmadmin/strmadminpw@DBA1 BEGIN DBMS_STREAMS_ADM.ADD_TABLE_PROPAGATION_RULES( table_name => 'scott.dept', streams_name => 'dba1_to_dba2', source_queue_name => 'strmadmin.streams_queue', destination_queue_name => 'strmadmin.streams_queue@dba2', include_dml => true, include_ddl => true, source_database => 'dba1'); END; / The propagation is performed using a job which can be monitored using:
SELECT job, TO_CHAR(last_date, 'DD-Mon-YYYY HH24:MI:SS') last_date, TO_CHAR(next_date, 'DD-Mon-YYYY HH24:MI:SS') next_date, what FROM dba_jobs; Configure Capture Process Configure the capture process on DBA1:
CONNECT strmadmin/strmadminpw@DBA1 BEGIN DBMS_STREAMS_ADM.ADD_TABLE_RULES( table_name => 'scott.dept', streams_type => 'capture', streams_name => 'capture_simp', queue_name => 'strmadmin.streams_queue', include_dml => true, include_ddl => true); END; / Configure Instantiation SCN The instantiation SCN of the source table must be configured in the destination table before the apply process will work. If the destination table is already present this can be accomplished using a metadata only export/import:
exp userid=scott/tiger@dba1 FILE=dept_instant.dmp TABLES=dept OBJECT_CONSISTENT=y ROWS=n imp userid=scott/tiger@dba2 FILE=dept_instant.dmp IGNORE=y COMMIT=y LOG=import.log STREAMS_INSTANTIATION=y During the transfer of the meta information the supplematal logging was also transferred. Since no capture is done on DBA2 this can be removed:
CONN sys/password@DBA2 AS SYSDBA ALTER TABLE scott.dept DROP SUPPLEMENTAL LOG GROUP log_group_dept_pk; Alternatively the instantiation SCN can be set using the DBMS_APPLY_ADM package:
CONNECT strmadmin/strmadminpw@dba1 DECLARE v_scn NUMBER; BEGIN v_scn := DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER(); DBMS_APPLY_ADM.SET_TABLE_INSTANTIATION_SCN@DBA2( source_object_name => 'scott.dept', source_database_name => 'dba1', instantiation_scn => v_scn); END; / Configure Apply Process Configure the apply process on the destination database (DBA2):
CONNECT strmadmin/strmadminpw@DBA2 BEGIN DBMS_STREAMS_ADM.ADD_TABLE_RULES( table_name => 'scott.dept', streams_type => 'apply', streams_name => 'apply_simp', queue_name => 'strmadmin.streams_queue', include_dml => true, include_ddl => true, source_database => 'dba1'); END; / Start Apply Process Start the apply process on destination database (DBA2) and prevent errors stopping the process:
CONNECT strmadmin/strmadminpw@DBA2 BEGIN DBMS_APPLY_ADM.SET_PARAMETER( apply_name => 'apply_simp', parameter => 'disable_on_error', value => 'n');
DBMS_APPLY_ADM.START_APPLY( apply_name => 'apply_simp'); END; / Start Capture Process Start the capture process on the source database (DBA1):
CONNECT strmadmin/strmadminpw@DBA1 BEGIN DBMS_CAPTURE_ADM.START_CAPTURE( capture_name => 'capture_simp'); END; / Test It With the streams activated we can see that DML changes to the source table are visible in the destination table:
DEPTNO DNAME LOC ---------- -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON 99 Test Dept UK
DEPTNO DNAME LOC ---------- -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON 99 Test Dept UK
5 rows selected. We can also see that DDL changes to the source table are reflected in the destination table:
Name Null? Type ---------------------------- -------- -------------- DEPTNO NOT NULL NUMBER(2) DNAME VARCHAR2(14) LOC VARCHAR2(13) NEW_COL NUMBER(10) The contents of the streams can be viewed using statements like:
SELECT s.user_data.getTypeName() FROM streams_queue_table s;
SET SERVEROUTPUT ON DECLARE v_anydata SYS.ANYDATA; v_lcr SYS.LCR$_ROW_RECORD; v_row_list SYS.LCR$_ROW_LIST; v_result PLS_INTEGER; BEGIN
SELECT user_data INTO v_anydata FROM strmadmin.streams_queue_table WHERE rownum < 2;
DBMS_OUTPUT.PUT_LINE('Command Type : ' || v_lcr.Get_Command_Type); DBMS_OUTPUT.PUT_LINE('Object Owner : ' || v_lcr.Get_Object_Owner); DBMS_OUTPUT.PUT_LINE('Object Name : ' || v_lcr.Get_Object_Name); DBMS_OUTPUT.PUT_LINE('Source Database Name : ' || v_lcr.Get_Source_Database_Name); END; / Clean Up All rules can be identified and removed using the following statements:
BEGIN FOR cur_rec IN (SELECT rule_owner, rule_name FROM dba_rules) LOOP DBMS_RULE_ADM.DROP_RULE( rule_name => cur_rec.rule_owner || '.' || cur_rec.rule_name, force => TRUE); END LOOP; END; / All capture and apply processes can be identified, stopped and dropped using:
BEGIN FOR cur_rec IN (SELECT capture_name FROM dba_capture) LOOP DBMS_CAPTURE_ADM.STOP_CAPTURE( capture_name => cur_rec.capture_name); DBMS_CAPTURE_ADM.DROP_CAPTURE( capture_name => cur_rec.capture_name); END LOOP;
FOR cur_rec IN (SELECT apply_name FROM dba_apply) LOOP DBMS_APPLY_ADM.STOP_APPLY( apply_name => cur_rec.apply_name); DBMS_APPLY_ADM.DROP_APPLY( apply_name => cur_rec.apply_name); END LOOP; END; / All streams information relating to a specific object can be purged using:
BEGIN DBMS_STREAMS_ADM.PURGE_SOURCE_CATALOG( source_database => 'dba1', source_object_name => 'scott.dept', source_object_type => 'TABLE'); END; / For further information see:
Oracle9i Streams Release 2 (9.2) Monitoring a Streams Environment Oracle9i Supplied PL/SQL Packages and Types Reference Release 2 (9.2)
Timing buffer-cache reads: 128 MB in 2.75 seconds = 46.55 MB/sec Timing buffered disk reads: 64 MB in 3.20 seconds = 20.00 MB/sec
由以上的数据,可以看得出来,硬盘 DMA 是否开启,对读取效率影响很大。
二、关闭多馀的系统服务。
这是老生常谈的题目了,一般我们当作桌上型工作站的时候,只需要激活几个基本的?Service 即可,其他的不但没用,一方面会占用系统资源,另一方面则会有安全上的顾虑,我平常只用来连网、打打文件、听听音乐、看看电影,多半时间只是一个 Client 端,实在没必要激活 Server 端的服务,所以,我在 Setup System Services时,只留下以下几个 Service,其馀的都关闭。
我习惯操作 KDE ,对 GNOME 不熟,所以,以下是都是面向 KDE而设,GNOME 的使用者,我想,应该也差不多啦!
1、颜色数设为 16 Bit 就有很好的效果了,24 Bit 除了浪费资源,看不出有何好处。 2、不要使用屏幕保护程序。 3、取消动画窗口功能。 4、尽量使用同一种字型。 5、浏览器用 Mozilla 不要用 Netscape。 6、不要激活音效服务器 artd
Speed Up X by Managing Font Setting 在你抱怨 X 跑得不够快之前, 先检查字型设定, 很可能就是影响效能的一大元凶。 先看一下 /etc/X11/XF86Config-4 档案里的 FontPath 设定值, 如果是 如下∶ Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
# Multiple FontPath entries are allowed (they are concatenated together) # By default, Mandrake 6.0 and later now use a font server independent of # the X server to render fonts.
# Multiple FontPath entries are allowed (they are concatenated together) # By default, Mandrake 6.0 and later now use a font server independent of # the X server to render fonts.
原本的 FontPath "unix/:-1" 将字型由 X Font Server 来提供, 一般使用者未蒙其利、先受其害, 可以考虑等熟悉 X Font Server 功能後再使用。 如此就可以关掉xfs了 ps:试用时不要用默认开机直接进x-window,若不行会卡在x-window ps:引用自http://twopensource.org/~marr/xfont_tip.html 六、调整应用程序优先权。
[root@NEWLFS mnt]#mke2fs -j /dev/lvm_vg/lv_opt mke2fs 1.35 (28-Feb-2004) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 262144 inodes, 524288 blocks 26214 blocks (5.00%) reserved for the super user First data block=0 16 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912
[root@NEWLFS mnt]#lvreduce -L -1G /dev/lvm_vg/lv_home WARNING: Reducing active logical volume to 2.00 GB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce lv_home? [y/n]: y Reducing logical volume lv_home to 2.00 GB Logical volume lv_home successfully resized 然后减小LV大小, -L -1G 减去1个G 与文件系统保持一致。
[root@NEWLFS ~]#umount /mnt/lvm_opt/ 首先卸载文件系统 [root@NEWLFS ~]#mke2fs -n /dev/lvm_vg/lv_opt mke2fs 1.35 (28-Feb-2004) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 262144 inodes, 786432 blocks 26214 blocks (5.00%) reserved for the super user First data block=0 16 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 [root@NEWLFS ~]# 因为必须知道减少后卷的块数,所以通过mke2fs -n 列出块大小
减小FS大小: [root@NEWLFS ~]#resize2fs /dev/lvm_vg/lv_opt 524288 resize2fs 1.35 (28-Feb-2004) Resizing the filesystem on /dev/lvm_vg/lv_var to 524288 (1k) blocks. The filesystem on /dev/lvm_vg/lv_var is now 524288 blocks long. 减少LV大小: [root@NEWLFS mnt]#lvreduce -L -1G /dev/lvm_vg/lv_var WARNING: Reducing active logical volume to 2.00 GB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce lv_var? [y/n]: y Reducing logical volume lv_var to 2.00 GB Logical volume lv_var successfully resized ok,成功缩小了1G,再重新mount上吧。
[root@NEWLFS mnt]#mount /dev/lvm_vg/lv_var lvm_var/ [root@NEWLFS mnt]#df .......... /dev/mapper/lvm_vg-lv_var 2.0G 33M 1.9G 2% /mnt/lvm_var 下面再来看看如何删除LV,VG : 删除LV: [root@NEWLFS mnt]#umount /dev/lvm_vg/lv_opt 必须先关闭LV才可以删除它。 [root@NEWLFS mnt]#lvremove /dev/lvm_vg/lv_opt Do you really want to remove active logical volume "lv_opt"? [y/n]: y Logical volume "lv_opt" successfully removed [root@NEWLFS mnt] 使用lvremove命令删除一个逻辑卷,这里删除了lv_opt.
然后需要在系统启动脚本中加入激活LVM的命令 并且必须在挂载/etc/fstab中的文件系统之前激活LVM,不然怎么挂载阿。^_^ 我写在了/etc/rc.d/init.d/mountfs这个脚本中,它的作用是 在fsck检查各个分区后,将/分区及其他分区重新挂载成read-write的 /sbin/vgscan -------->需要加入的两行 /sbin/vgchange -a y
mountfs脚本主要内容是:(传递start参数) echo "Remounting root file system in read-write mode..." mount -n -o remount,rw / echo "Recording existing mounts in /etc/mtab..." > /etc/mtab mount -f / || failed=1 mount -f /proc || failed=1 if grep -q '[[:space:]]sysfs' /proc/mounts ; then mount -f /sys || failed=1 fi echo "Mounting remaining file systems..." ##############LVM############## /sbin/vgscan #------->在挂载其他文件系统之前 /sbin/vgchange -a y #---->就激活了LVM,随后就挂载上啦 mount -a -O no_netdev #--->依照/etc/fstab挂载FS
这样系统启动时,就会激活LVM,并自动挂载上。
一篇关于LVM的文章中说,将这两条命令加在了检查文件系统脚本中,但是我加在那里 不成功,可能因为在checkfs时,系统是read-only的,而vgchange -a y 需要写入数据却无法写入,所以不行.
udev服务先于checkfs启动,并且通过mount -n -t ramfs ramfs /dev 将/dev挂载成ramfs,完全在内存中活动,无论根分区是否可写,/dev都是可写的。 莫非vgchange -a y 还要向其他位置写入数据?有待研究:)
安装device-mapper库,lvm2 tools : device-mapper-stable.tgz使用如下命令安装: tar zxvf device-mapper-stable.tgz && cd device-mapper.1.00.21/ && ./configure && make && make install
安装好device-mapper后安装lvm2.0-stable.tgz : tar zxvf LVM2.0-stable.tgz && cd LVM2.2.00.33 && ./configure && make install
内核中支持device-mapper : 就是这里,害我编译内核十几次,我使用的是2.6.10-mm3支持ReiserFS 4.0的内核 Device Drivers ---> [*] Multiple devices driver support (RAID and LVM) ----> <*> Device mapper support < > Crypt target support < > Snapshot target (EXPERIMENTAL) < > Mirror target (EXPERIMENTAL) < > Zero target (EXPERIMENTAL)
VG (Volume Group 卷组): 卷组是LVM中最高抽象层,是由一个或多个物理卷所组成的存储器池。
从图中可以看出,卷组是由一个或几个物理卷组成,然后分支成若干个LV.
LV (Logical Volume 逻辑卷): 逻辑卷相当于非LVM系统中的分区,它在卷组上建立 是一个标准的块设备,可以在其上建立文件系统。 +-- Volume Group --------------------------------+ | | | +----------------------------------------+ | | PV | PE | PE | PE | PE | PE | PE | PE | PE | | | +----------------------------------------+ | | . . . . | | . . . . | | +----------------------------------------+ | | LV | LE | LE | LE | LE | LE | LE | LE | LE | | | +----------------------------------------+ | | . . . . | | . . . . | | +----------------------------------------+ | | PV | PE | PE | PE | PE | PE | PE | PE | PE | | | +----------------------------------------+ | | | +------------------------------------------------+
PE (Physical Extent物理块): 物理卷按大小相等的"块"为单位存储,块的大小与卷组中逻辑卷块的大小相同。
LE (Logical Extent 逻辑块): 逻辑卷按"块"为单位存储,在一卷组中的所有逻辑卷的块大小是相同的。
[root@NEWLFS mnt]#pvcreate /dev/hda5 Physical volume "/dev/hda5" successfully created [root@NEWLFS mnt]#
使用 pvdisplay 查看PV详细信息:
[root@NEWLFS mnt]#pvdisplay --- Physical volume --- PV Name /dev/hda5 VG Name lvm_vg PV Size 20.85 GB / not usable 0 Allocatable yes PE Size (KByte) 4096 Total PE 5338 Free PE 4076 Allocated PE 1262 PV UUID y5LlEs-iBIY-t3PU-gTaT-ZIUt-iDmE-b9J9aC
[root@NEWLFS mnt]#
2.创建卷组,并将PV加入到卷组中:
使用vgcreate VGNAME PV1 [PV2......]创建卷组
[root@NEWLFS mnt]#vgcreate lvm_vg /dev/hda5 Volume group "lvm_vg" successfully created [root@NEWLFS mnt]#
使用vgdisplay 查看VG详细信息:
[root@NEWLFS mnt]#vgdisplay --- Volume group --- VG Name lvm_vg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 20.85 GB PE Size 4.00 MB Total PE 5338 Alloc PE / Size 1262 / 4.93 GB Free PE / Size 4076 / 15.92 GB VG UUID TFjqOG-5aHq-6SUz-q96N-Lu20-GrrP-Qvh2WM
[root@NEWLFS mnt]#
当重新启动或执行vgchange -a n 后,需要重新激活VG,才可以访问VG,LV
[root@NEWLFS mnt]#vgchange -a y lvm_vg 1 logical volume(s) in volume group "lvm_vg" now active [root@NEWLFS mnt]#
当关机或不再使用VG时,使用 vgchage -a n VGNAME 使VG不可用。
[root@NEWLFS mnt]#vgchange -a n lvm_vg 0 logical volume(s) in volume group "lvm_vg" now active [root@NEWLFS mnt]#
Event 10013 - Monitor Transaction Recovery This event can be used to trace transaction recovery during startup For example ALTER SESSION SET EVENTS '10013 trace name context forever, level 1'; Event 10015 - Dump Undo Segment Headers This event can be used to dump undo segment headers before and after transaction recovery For example ALTER SESSION SET EVENTS '10015 trace name context forever, level 1'; Event 10032 - Dump Sort Statistics This event can be used to dump sort statistics. Level 10 is the most detailed For example ALTER SESSION SET EVENTS '10032 trace name context forever, level 10'; Event 10033 - Dump Sort Intermediate Run Statistics This event can be used to dump sort intermediate run statistics. Level 10 is the most detailed For example ALTER SESSION SET EVENTS '10033 trace name context forever, level 10'; Event 10045 - Trace Free List Management Operations This event can be used to trace free list management operations For example ALTER SESSION SET EVENTS '10045 trace name context forever, level 1'; Event 10046 - Enable SQL Statement Trace This event can be used to dump SQL statements executed by a session with execution plans and statistics. Bind variable and wait statistics can optionally be included. Level 12 is the most detailed. For example ALTER SESSION SET EVENTS '10046 trace name context forever, level 12'; Levels are Level Action 1 Print SQL statements, execution plans and execution statistics 4 As level 1 plus bind variables 8 As level 1 plus wait statistics 12 As level 1 plus bind variables and wait statistics
Event 10053 - Dump Optimizer Decisions This event can be used to dump the decisions made by the optimizer when parsing a statement. Level 1 is the most detailed For example ALTER SESSION SET EVENTS '10053 trace name context forever, level 1'; Levels are Level Action 1 Print statistics and computations 2 Print computations only
Event 10060 - Dump Predicates This event can be used to force the optimizer to dump predicates to a table It is available in Oracle 7.1.3 and above, and was still working in Oracle 9.2. This event requires the following table to be created in the schema of the user parsing the statement CREATE TABLE kkoipt_table ( c1 INTEGER, c2 VARCHAR2(80) ); To enable this event use ALTER SESSION SET EVENTS '10060 trace name context forever, level 1'; This example uses the following object CREATE TABLE t1 (c01 NUMBER, c02 NUMBER); With event 10060 set to level 1, when the following statement is executed for the first time SELECT c01 FROM t1 WHERE c02 = 0; It is parsed and the results written to kkoipt_table The results can be selected using the statement SELECT c1,c2 FROM kkoipt_table ORDER BY c1; C1 C2 1 Table: 2 T1 3 frofand 4 "T1"."C02"=0
The following table summarises the various operations that can be reported by this event Operation Description fptconst Folding constants fptrnum Remove ROWNUM predicates fptwhr Remove all WHERE predicates except remaining ROWNUM predicates frofkks (rowid lookup) ROWID lookup frofkks[i] (and-equal lookup) start key frofkke[i] (and-equal lookup) end key froiand index-only predicate frofkksm[i] (sort-merge) sort-merge key frosand (sort-merge) sort-merge predicates frojand (sort-merge) join predicates frofkks[i] (index start key) index start key frofkke[i] (index stop key) index end key frofand (hash part) table predicate (hash) froiand (index only filter) index only predicate frofand table predicate froutand outer join predicates
Event 10065 - Restrict Library Cache Dump Output for State Object Dumps The amount of library cache dump output for state object dumps can be limited using event 10065 ALTER SESSION SET EVENTS '10065 trace name context forever, level level'; where level is one of the following
Level Description 1 Address of library object only 2 As level 1 plus library object lock details 3 As level 2 plus library object handle and library object
Level 3 is the default Event 10079 - Dump SQL*Net Statistics This event can be used to SQL*Net statistics. Level 2 is the most detailed For example ALTER SESSION SET EVENTS '10079 trace name context forever, level 2'; Event 10081 - Trace High Water Mark Changes This event can be used to trace high water mark changes For example ALTER SESSION SET EVENTS '10081 trace name context forever, level 1'; Event 10104 - Dump Hash Join Statistics This event can be used to hash join statistics. Level 10 is the most detailed For example ALTER SESSION SET EVENTS '10104 trace name context forever, level 10'; Event 10128 - Dump Partition Pruning Information This event can be used to partition pruning information For example ALTER SESSION SET EVENTS '10128 trace name context forever, level level'; Levels are Level Action 0x0001 Dump pruning descriptor for each partitioned object 0x0002 Dump partition iterators 0x0004 Dump optimizer decisions about partition-wise joins 0x0008 Dump ROWID range scan pruning information
There are further levels (up to 4096?) In Oracle 9.0.1 and above, a table must be created before level 2 of this event can be set. The table definition is as follows CREATE TABLE kkpap_pruning ( partition_count NUMBER, iterator VARCHAR2(32), partition_level VARCHAR2(32), order_pt VARCHAR2(12), call_time VARCHAR2(12), part# NUMBER, subp# NUMBER, abs# NUMBER ); Event 10200 - Dump Consistent Reads This event can be used to dump consistent reads ALTER SESSION SET EVENTS '10200 trace name context forever, level 1'; Event 10201 - Dump Consistent Read Undo Application This event can be used to dump consistent read undo application ALTER SESSION SET EVENTS '10201 trace name context forever, level 1'; Event 10220 - Dump Changes to Undo Header This event can be used to dump changes to the undo header (transaction table) ALTER SESSION SET EVENTS '10220 trace name context forever, level 1'; Event 10221 - Dump Undo Changes This event can be used to dump undo changes applied. Level 7 is the most detailed ALTER SESSION SET EVENTS '10221 trace name context forever, level 7'; Event 10224 - Dump Index Block Splits / Deletes This event can be used to dump index block splits and deletes detailed ALTER SESSION SET EVENTS '10224 trace name context forever, level 1'; Event 10225 - Dump Changes to Dictionary Managed Extents This event can be used to dump changes to dictionary-managed extents made in the row cache ALTER SESSION SET EVENTS '10225 trace name context forever, level 1'; Event 10241 - Dump Remote SQL Execution This event can be used to dump remotely executed SQL statements ALTER SESSION SET EVENTS '10241 trace name context forever, level 1'; Event 10246 - Trace PMON Process This event can be used to trace the actions of the PMON background process This event can only be enabled in the init.ora file using event = "10246 trace name context forever, level 1" The ALTER SYSTEM command does not appear to work for this event There only appears to be one level for this event (levels 5 and 10 appear to generate the same output as level 1) Event 10248 - Trace Dispatcher Processes This event can be used to trace dispatcher processes This event can be enabled in the init.ora file using event = "10248 trace name context forever, level 10" In Oracle 9.2 (Windows 2000) the trace is written to a file in the udump directory with a name in the format ServiceName_dDispatcherNumber_ThreadNumber.trc e.g. JD92001_d000_1234.trc Valid levels are 1 to 10 (Metalink Note) Event 10249 - Trace Shared Server (MTS) Processes This event can be used to trace shared server (MTS) processes This event can be enabled in the init.ora file using event = "10249 trace name context forever, level 10" In Oracle 9.2 (Windows 2000) the trace is written to a file in the udump directory with a name in the format ServiceName_sSharedServerNumber_ThreadNumber.trc e.g. JD92001_s000_5678.trc Valid levels are 1 to 10 (Metalink Note) Event 10270 - Debug Shared Cursors This event can be used to enable debugging code in shared cursor management modules event = "10270 trace name context forever, level 10" Event 10299 - Debug Prefetching This event can be used to enable debugging code for table and index block prefetching. It also enables dumping of trace by the CKPT process. event = "10299 trace name context forever, level 1" Event 10357 - Debug Direct Path This event can be used to enable debugging code for direct path ALTER SESSION SET EVENTS '10357 trace name context forever, level 1'; Event 10390 - Dump Parallel Execution Slave Statistics This event can be used to dump parallel slave statistics ALTER SESSION SET EVENTS '10390 trace name context forever, level level';
Levels are (from messages) Level Action 0x0001 Slave-side execution messages 0x0002 Coordinator-side execution messages 0x0004 Slave context state changes 0x0008 Slave ROWID range bind variables and xty 0x0010 Slave fetched rows as enqueued to TQ 0x0020 Coordinator wait reply handling 0x0040 Coordinator wait message buffering 0x0080 Slave dump timing 0x0100 Coordinator dump timing 0x0200 Slave dump allocation file number 0x0400 Terse format for debug dumps 0x0800 Trace CRI random sampling 0x1000 Trace signals 0x2000 Trace parallel execution granule operations 0x4000 Force compilation by slave 0
Event 10391 - Dump Parallel Execution Granule Allocation This event can be used to dump parallel granule allocation/assignment statistics ALTER SESSION SET EVENTS '10391 trace name context forever, level level'; Levels are (from messages) Level Action 0x0001 Dump summary of each object scanned in parallel 0x0002 Full dump of each object except extent map 0x0004 Full dump of each object including extent map 0x0010 Dump summary of each granule generators 0x0020 Full dump of granule generators except granule instances 0x0040 Full dump of granule generators including granule instances 0x0080 Dump system information 0x0100 Dump reference object for the query 0x0200 Gives timing in kxfralo 0x0400 Trace affinity module 0x0800 Trace granule allocation during query execution 0x1000 Trace object flush 0x2000 Unknown
Event 10393 - Dump Parallel Execution Statistics This event can be used to dump kxfp statistics after each parallel query ALTER SESSION SET EVENTS '10393 trace name context forever, level 1'; Note that in Oracle 9.2 for parallel execution trace is written to files with names of the format ServiceName_pServerNumber_ThreadNumber.trc This is an example of the output for this event. The output has been modified for readability kxfpdst dumping statistics --------------------------- Query Sessions 1 Total Messages Sent 0 Data Messages Sent 948 Stream Messages Sent 917 Dialog Messages Sent 26 Null Messages Sent 0 Fast Shared Memory Streams 669 Fast Distributed Stream 0 Stream Mode Credit Ping 0 Unknown Credit Pings 0 Single Credit Pings 252 Double Credit Pings 0 Triple Credit Pings 0 Multiple Credit Pings 0 Total Messages Dequeued 0 Data Messages Dequeued 31 Null Messages Dequeued 0 Immediate Dequeues 1 Posted Dequeues 31 Timed-out Dequeues 0 Implicit Dequeues 255 Total Dequeue Waits 85 Total Dequeue Timeouts 44 Dequeues for Credit (geb) 77 Dequeues for Credit (free) 0 Dequeues for Credit (enq) 39 Event 10500 - Trace SMON Process This event can be used to trace the actions of the SMON background process This event can be enabled in the init.ora file using event = "10500 trace name context forever, level 1" Event 10608 - Trace Bitmap Index Creation This event traces bitmap index creation. ALTER SESSION SET EVENTS '10608 trace name context forever, level 10'; Event 10704 - Trace Enqueues This event dumps information about which enqueues are being obtained When enabled it prints out arguments to calls to ksqcmi and ksqlrl and the return values ALTER SESSION SET EVENTS '10704 trace name context forever, level 1'; Event 10706 - Trace Global Enqueue Manipulation This event allows RAC global enqueue manipulation to be trace ALTER SESSION SET EVENTS '10706 trace name context forever, level 1'; The amount of output can be limited using the unsupported parameter '_ksi_trace'. This parameter specifies the lock types that should be included e.g. TM, TX etc. They are specified as a string e.g. 'TMTX' The parameter '_ksi_trace' can only be set in the initialisation file. Event 10708 - Trace RAC Buffer Cache This event allows RAC buffer cache activity to be traced ALTER SESSION SET EVENTS '10708 trace name context forever, level 10'; This diagnostic applies only to RAC clusters (not single-instance) Event 10710 - Trace Bitmap Index Access This event traces bitmap index access. It displays the start ROWID and end ROWID of each bitmap ALTER SESSION SET EVENTS '10710 trace name context forever, level 1'; Event 10711 - Trace Bitmap Index Merge Operation This event traces the bitmap index merge operation. ALTER SESSION SET EVENTS '10711 trace name context forever, level 1'; Event 10712 - Trace Bitmap Index OR Operation This event traces the bitmap index OR operation. ALTER SESSION SET EVENTS '10712 trace name context forever, level 1'; Event 10713 - Trace Bitmap Index AND Operation This event traces the bitmap index AND operation. ALTER SESSION SET EVENTS '10713 trace name context forever, level 1'; Event 10714 - Trace Bitmap Index MINUS Operation This event traces the bitmap index MINUS operation. ALTER SESSION SET EVENTS '10714 trace name context forever, level 1'; Event 10715 - Trace Bitmap Index Conversion to ROWIDs Operation This event traces the bitmap index conversion to ROWIDs operation ALTER SESSION SET EVENTS '10715 trace name context forever, level 1'; Event 10716 - Trace Bitmap Index Compress/Decompress This event traces the bitmap index compress/decompress ALTER SESSION SET EVENTS '10716 trace name context forever, level 1'; Event 10717 - Trace Bitmap Index Compaction This event traces the bitmap index compaction. ALTER SESSION SET EVENTS '10717 trace name context forever, level 1'; Event 10719 - Trace Bitmap Index DML This event traces the bitmap index DML. ALTER SESSION SET EVENTS '10719 trace name context forever, level 1'; Event 10730 - Trace Fine Grained Access Predicates This event traces find grained access (RLS) predicates ALTER SESSION SET EVENTS '10730 trace name context forever, level 1'; Event 10731 - Trace CURSOR Statements This event traces CURSOR statements ALTER SESSION SET EVENTS '10731 trace name context forever, level level'; Levels are Level Action 1 Print parent query and subquery 2 Print subquery only
Event 10928 - Trace PL/SQL Execution This event traces PL/SQL execution ALTER SESSION SET EVENTS '10928 trace name context forever, level 1'; Event 10938 - Dump PL/SQL Execution Statistics This event dumps PL/SQL execution statistics. ALTER SESSION SET EVENTS '10938 trace name context forever, level 1'; This event currently generates the following output --NOTICE --------------------------------------- --PL/SQL TRACE INFORMATION IS NOW IN THE DATABASE -- To create the trace tables, use the script -- -- rdbms/admin/tracetab.sql under ORACLE_HOME --
Every event has a number which is in the Oracle error message range e.g.
event 10046 is ORA-10046 Each event has one or more levels which can be
range e.g. 1 to 10
bitmask e.g. 0x01 0x02 0x04 0x08 0x10
flag e.g. 0=off; 1=on
identifier e.g. object id, memory address etc
Note that events change from one release to another. As existing events become deprecated and then obsolete, the event number is frequently reused for a new event. Note also that the message file sometimes does not reflect the events in the current release.
Many events change the behaviour of the database. Some testing events may cause the database to crash. Never set an event on a production database without obtaining permission from Oracle support. In addition, never set an event on a development database without first making a backup.
Enabling Events
Events can be enabled at instance level in the init.ora file using
event='event trace name context forever, level level';
Multiple events can be enabled in one of two ways
1 - Use a colon to separate the event text e.g.
event = "10248 trace name context forever,level 10:10249 trace name context forever,level 10"
2 - List events on consecutive lines e.g.
event = "10248 trace name context forever, level 10"
event = "10249 trace name context forever, level 10"
Note that in some versions of Oracle, the keyword "event"
must be in the same case (i.e. always uppercase or always lowercase).
Events can also be enabled at instance level using the ALTER SYSTEM command
ALTER SYSTEM SET EVENTS
'event trace name context forever, level level';
Events are disabled at instance level using
ALTER SYSTEM SET EVENTS
'event trace name context off';
Events can also be enabled at session level using the
ALTER SESSION command
ALTER SESSION SET EVENTS
'event trace name context forever, level level';
Events are disabled at session level using
ALTER SESSION SET EVENTS
'event trace name context off';
Events can be enabled in other sessions using ORADEBUG
To enable an event in a process use
ORADEBUG EVENT event TRACE NAME CONTEXT FOREVER, LEVEL level
For example to set event 10046, level 12 in Oracle process 8 use
ORADEBUG SETORAPID 8
ORADEBUG EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12
To disable an event in a process use
ORADEBUG EVENT event TRACE NAME CONTEXT OFF
To enable an event in a session use
ORADEBUG SESSION_EVENT event TRACE NAME CONTEXT FOREVER, LEVEL level
For example
ORADEBUG SESSION_EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12
To disable an event in a session use
ORADEBUG SESSION_EVENT event TRACE NAME CONTEXT OFF
Events can be also enabled in other sessions using
DBMS_SYSTEM.SETEV ,The SID and the serial number of the target session
must be obtained from V$SESSION. For example to enable event 10046
level 8 in a session with SID 9 and serial number 29 use
EXECUTE dbms_system.set_ev (9,29,10046,8,'');
To disable event 10046 in the same session use
EXECUTE dbms_system.set_ev (9,29,10046,0,'');
Listing All Events
Most events are numbered in the range 10000 to 10999.
To dump all event messages in this range use
SET SERVEROUTPUT ON DECLARE
err_msg VARCHAR2(120); BEGIN dbms_output.enable (1000000); FOR err_num IN 10000..10999 LOOP err_msg := SQLERRM (-err_num); IF err_msg NOT LIKE '%Message '||err_num||' not found%' THEN dbms_output.put_line (err_msg); END IF; END LOOP; END; / On Unix systems event messages are in the formatted text file
$ORACLE_HOME/rdbms/mesg/oraus.msg
To print detailed event messages (Unix only)
use the following script
event=10000
while [ $event -ne 10999 ]
do
event=`expr $event + 1`
oerr ora $event
done
Listing Enabled Events
To check which events are enabled in the current session
SET SERVEROUTPUT ON DECLARE l_level NUMBER; BEGIN FOR l_event IN 10000..10999 LOOP dbms_system.read_ev (l_event,l_level); IF l_level > 0 THEN dbms_output.put_line ('Event '||TO_CHAR (l_event)|| ' is set at level '||TO_CHAR (l_level)); END IF; END LOOP; END; /
如何从一个rdb求出file_id与block_id? select to_number('&RDB_HEX','xxxxxxxx') from dual; select dbms_utility.data_block_address_file(&RDB_DEC) from ; select dbms_utility.data_block_address_block(&RDB_DEC) from dual; select dbms_utility.make_data_block_address(&file_id,&block_id) from dual;
从alter system dump ....... 出的信息中将rdb分解成file_id与block_id
Red Hat lacks integrated virtualization features like those found in SUSE Linux Enterprise Server 9 and Solaris 10, and it's more than three times the price of the comparably featured Mandrakelinux Corporate Server 3.0. But Red Hat's most dangerous competition may not be from outside companies, but from its own community distribution. We won't do an in-depth comparison with these distros, as their usefulness is dependent on your specific situation, preference, training, and infrastructure.
Manufacturer Red Hat Inc. Architectures i386, IA64, AMD64/EM64T, IBM zSeries, S/390 series, and POWER series License GNU General Public License Market Enterprise computing, from desktops up to high-end servers Price (retail) Varies dependent on edition and subscription length Previous version Red Hat Enterprise Linux 3 Product Web site http://www.redhat.com/software/rhel/
---- Red Hat Enterprise Linux 4.0--The Enterprise Gets An Update
By: Bill von Hagen Monday, February 14, 2005 12:05:15 AM EST URL: http://www.linuxplanet.com/linuxplanet/reviews/5745/1/
Enterprise Linux and Red Hat
Red Hat is not only one of the oldest and best known Linux distributions, but is probably the one that has the most traction in the business community thanks to smart people, clever marketing, a steady stream of advertisements, and the introduction of some of the concepts that people take for granted in the commercial Linux space. Many Linux distributions, such as Red Hat, SUSE, Mandrakelinux, and even the ill-fated Caldera Linux distribution, have offered server and desktop products for years, but Red Hat was the first to make a lot of noise about "Linux for the Enterprise," pioneering the label, if not the concept.
Enterprise Linux vendors have to walk the tightrope between providing stable and up-to-date versions of the software packages required in enterprise deployments. Stability is an interesting notion in the Open Source world. On the one hand, you have the legions of dedicated and capable developers who are continually identifying and fixing problems in Open Source software.
On the other hand, you have Linux distribution vendors who are doing the same thing themselves, either by committing resources directly to supporting various software packages or by incorporating patches from the Open Source community. Either way, this is still a net win over proprietary software with a single possible source, a black-box approach to software deployment, and painfully slow release and update cycles.
Red Hat's focus on the Enterprise has had different effects on the desktop and enterprise communities. Desktop users who had previously committed to Red Hat have been split into two communities. One of these is made up of users who feel rejected, are disconcerted about desktop support, and have therefore largely gone elsewhere for supported desktop Linux products.
The flip side of this is the users who are taking advantage of the momentum of the Fedora project and the expertise of its contributors to keep moving forward with the descendant of a popular and widely-used distribution. In enterprise deployments, there's always Red Hat EL Desktop, which is attractive for support reasons and little else.
In the enterprise, most large organizations, except perhaps those with a huge existing commitment to the distribution formerly known as Red Hat N (now end-of-lifed), have seen Red Hat's Enterprise focus as a tremendous win because this has brought enterprise applications vendors such as Oracle into the Linux fold. Businesses can count on Red Hat for enterprise-caliber support and can therefore safely commit to adopting Linux as the heart of their infrastructure without having to worry that they may always have to retain legions of hackers chained in the basement.
Conservative release cycles and a more exhaustive test cycle make Red Hat Enterprise Linux a safer bet for the business community--they don't have to chase the release of the week. And finally, Red Hat's well-known and thoroughly advertised certification and training programs guarantee a certain level of competency and provide the kinds of data points that HR personnel and MIS/IT managers can identify on during the hiring process even if they don't personally know the right questions to ask.
Summary of Red Hat Enterprise Products
Red Hat provides four different products for the Enterprise. Their different server products are identified by two-letter combinations that are supposedly not acronyms, but which I will expand anyway because it's easier to remember them if you have some sort of mnemonic. At the top of the pyramid is Red Hat Enterprise Linux AS, which I think of as their Application server product. Red Hat AS supports systems with up to 16 CPUs and 64GB of main memory. We received a pre-release of the 4.0 version of this product for this review. Red Hat AS is server-rich and comes with various Java bells and whistles that are discussed later in this review.
Moving down the Enterprise Linux food chain is Red Hat Enterprise ES, which I think of as their Enterprise Server product. It supports systems with up to 2 CPUs and 8GB of main memory, and is targeted towards small or medium-sized business server systems who use it to run network, file, print, mail, and Web servers. Next, crossing into the desktop space, is Red Hat Enterprise Linux WS, which I think of as Red Hat Workstation.
WS supports systems with up to 2 CPUs, but does not provide many of the software servers that the higher-level products include. The list of missing servers include FTP, OpenLDAP, DNS/bind, TFTP, PXE, and INN. At the bottom of the Enterprise line comes the RHEL Desktop product, which is sold in quantities of 10, 50, and presumably higher numbers if you'd like. This is designed to run on single-CPU systems with up to 4GB of memory. It includes the things you expect to see on Linux equivalent of a Windows desktop--a mail client (evolution), an office productivity suite (OpenOffice), an instant messenger client (GAIM), a Web browser (Mozilla, currently), and other standards like Adobe Acrobat, Real Player, MacroMedia Flash support, and so on.
Installing RHEL 4
Red Hat Enterprise Linux 4 features a graphically updated version of the familiar Red Hat installation process consisting of two phases. In the first phase, you supply basic information about your system's location and nationalization, specify disk partitioning, select the basic type of installation that you want to perform and any additional packages that you want to install. In the second phase, you confirm the date and time, create user accounts, register with Red Hat Network in order to receive updates, and optionally install additional packages from CD #5, the Red Hat Extras CD. Figure 1 shows the Welcome screen from the RHEL AS 4.0 installer.
One exceptionally clever notion adopted from the Fedora Project is the use of logical volumes in RHEL's default disk partitioning suggestions. Figure 2 shows the default partitioning scheme proposed by the installer on a small system disk. I've appreciated this in Fedora, but it makes even more sense in enterprise deployments where disk space requirements almost always expand and downtime for adding disk space must be kept to a minimum. Using logical volumes by default makes it easy to bring down a system for scheduled maintenance, add new disk drives, and dynamically integrate the space that they provide once the system is running again. The alternative of manually cloning the contents of a partition to another and swapping the partitions during additional downtime is painfully primitive by comparison. More Linux distributions should take this enlightened, sysadmin-sensitive approach to default disk allocation and assignment.
Unlike the Red Hat N products of old, Red Hat EL AS doesn't provide a variety of default installation configurations, which is understandable because of its more focused audience. Your choices are to install the default set of packages or to customize the list of packages that you're installing. I typically do the latter and select "Everything" as my package list because disk space is much cheaper than my time when I find that I'm missing some package on my application server and have to hunt down the CDs, install and configure, and so on.
The Extras CD provided with Red Hat EL AS features an interesting choice of third-party packages divided into three sections--Java and Java Utilities, Multimedia, and Miscellaneous. Your Java choices consist of various selections that make up the IBM Runtime environment and Development kit and the BEA's WebLogic JRockit management console, plugins, and runtime. The Multimedia section contains Adobe Acrobat, Real's RealPlayer, and and Macromedia's Flash plugin. The Miscellaneous section contains Agfa Monotype fonts, the Citrix ICA client for Unix, firmware for the Intel 2100 and 2200 wireless adapters, and AT&T's Korn shell. Miscellaneous, indeed!
What's in the Box
One complaint commonly raised against RHEL is that it lags far behind the state-of-the-art in terms of Linux software. Conservative, well-tested releases are a requirement of a true enterprise Linux distribution, both so that no inconsistencies or problems are introduced into corporate infrastructure and to facilitate the longer product support provided for enterprise editions. At the same time, enterprise distributions need to provide a mechanism for keeping up with fundamental improvements in system software. Some of the versions of software provided with RHEL 3.0, such as OpenLDAP, were old enough that they did not support new and up-to-date features that system administrators need to use this in enterprise deployments. RHEL 4.0 corrects most of these sorts of problems, including a move to the more scalable and powerful 2.6 Linux kernel, but the underlying update/upgrade problem still needs to be addressed beyond vulnerability and bug fixes, which Red Hat seems to do a good job of keeping up with.
The following table shows the versions of some of the most popular GNU/Linux software packages found in Red Hat Enterprise Linux 4.0. For those perhaps new to Linux, this table lists the versions of commonly-used applications and system services such the Common Unix Print Server (CUPS) Evolution mail client, the GCC and GDB packages for compilation and debugging, the GNOME desktop system and the underlying X Window System, the Perl, Python, and Ruby scripting languages, authentication and security packages such as OpenLDAP and OpenSSL, the Open Office desktop office software package, the Linux kernel itself. Package RHEL 4.0 Version CUPS 1.1.22 Evolution 2.0.2 Firefox 1.0 GCC 3.4.3 GDB 6.1 GNOME 2.8.0 KDE 3.3.1 Kernel 2.6.9 OpenOffice 1.1.2 OpenLDAP 2.2.13 OpenSSL 0.9.7a Perl 5.8.5 Python 2.3.14 Ruby 1.8.1 X11(X.org) 6.8.1
Figure 3 shows the default GNOME 2.8 desktop provided by Red Hat Enterprise Linux 4.
From the Web server point of view, RHEL4 provides httpd (Apache) version 2.0.52, with version 4.3.9 of the PHP scripting language and version 2.01 of the cool webalizer software for analyzing web logs and displaying traffic statistics. I didn't try any of the well-known exploits against PHP 4.3.9, but I suspect that an update will be coming soon for that particular package if Red Hat hasn't already patched them into their version. You should do some testing of this before some random Root Crew shows up and gives your brand new site an unwanted face lift.
From the file server point of view, RHEL 4 supports NFS V4, version 4.1 of the autmounter, and version 1.0.6 of the NFS support utilities. It provides Samba version 3.0.10 and supports version 2.00 of the updated Logical Volume Manager LVM2. I was somewhat disappointed with the fact that RHEL 4.0 does not include the utilities for managing the JFS, ReiserFS, or XFS journaling filesystems on local storage. Apparently, Red Hat believes that EXT3 is the only journaling filesystem suitable for managing local storage in the Enterprise. This is clearly untrue, but RHEL doesn't seem to provide any alternatives if you still want to get product support.
Open Source database fans should be happy that RHEL 4.0 provides MySQL 4.1.7 and Postgresql 7.4.6, along with modern versions of the ODBC connectors for each. RHEL 4.0 is also replete with a rich assortment of mail servers, providing Cyrus IMAPD 2.2.10, exim 4.43, Postfix 2.1.5, and Sendmail 8.13. Associated software includes version 3.0.1 of spamassassin for anyone who is deploying any of these mail servers, and includes version 2.1.5 of mailman for creating and managing mailing lists.
As a side note, if you do a custom install of RHEL4 and install everything, it installs a ton of games, which is somewhat surprising in the enterprise Linux Application Server market. However, if your 32-GB 8-CPU application server is under-utilized, you can always play a mean game of battleship (Kbattleship) on the console while configuring services and run-levels, as shows in Figure 4.
RHEL4 and 2.6 Kernel Notes for Sysadmins
The 2.6 Linux kernel has brought many general improvements to Linux system performance, capabilities, and capacity. The most commonly-noted of these are performance and responsiveness improvements, support for greater amounts of memory, better processor utilization and scaling in SMP environments, and integrated support for newer devices and interfaces such as Serial ATA. However, beyond these pleasant and immediately-noticeable improvements, many internal and system-level changes have occurred that enterprise system administrators should be aware of. RHEL4 and the 2.6 kernel provide many other improvements to administrative tools and capabilities - this section highlights my favorites.
Some of the most immediately visible and important changes introduced by the 2.6 Linux kernel are changes to loadable kernel module (LKM) naming conventions, internals, and build models. LKMs now end with the .ko extension (kernel object) to differentiate them from standard object files, have a simpler Makefile/build structure, and can more easily be built outside the kernel source by simply referring to the base location of a writable kernel source tree. If you are currently using devices whose drivers were supplied by a hardware or software vendor, you will need to obtain 2.6 versions of those drivers (assuming that they have not been folded into the official 2.6 kernel source).
Beyond server improvements and enhancements, RHEL4 and the 2.6 kernel give system administrators new levels of access control and system event monitoring. By using a recent version of the 2.6 kernel, RHEL4 introduces support for the light-weight auditing framework that provides interfaces that lower the overhead of providing audit information from the kernel and system applications. I couldn't find the audit daemon or associated applications on RHEL4, but at least the framework is present in the kernel--mechanisms for taking advantage of it can be distributed and RHEL4 updates, I suppose.
More importantly (and usable immediately), RHEL4 supports Security-Enhanced Linux (SELinux), which can be deactivated during the install process but is active by default. SELinux provides a variety of mechanisms for implementing and enforcing access control policies, including those based on the type of object being accessed (type-based) or on the role of the user attempting to access an object (role-based, commonly known as Role-Based Access Control, RBAC). SELinux access control policies operate outside the standard Linux protection and access control mechanisms, and are designed to limit user programs and system servers to the minimum privileges that they require in order to perform their tasks. A correct SELinux policy implementation can go a long way towards limiting the potential damage that can be done by exploiting server or application vulnerabilities through common techniques such as buffer overflows.
Wrapping Up
RHEL4 is a huge step forward for Red Hat and should be a breath of fresh air to businesses who require the stability and support associated with and enterprise Linux distribution, but desperately needed or wanted new versions of the kernel, servers, and applications. If you were waiting for newer features or software to appear in the Enterprise Linux space, Red Hat Enterprise Linux 4 is well worth a look. If you're already a RHEL customer, run, don;t walk, to your support representative for an upgrade.
Bill von Hagen is the author of numerous books and articles on Linux. For more information about Bill, see http://www.vonhagen.org.
Tables can be partitioned into up to 64,000 separate partitions. Any table can be partitioned except those tables containing columns with LONG or LONG RAW datatypes. You can, however, use tables containing columns with CLOB or BLOB datatypes. 查看全文
sqlo_exec(dbh, "DROP PACKAGE BODY SQLORA_TEST"); sqlo_exec(dbh, "DROP PACKAGE SQLORA_TEST"); return 1; } /*====================================================== * main *==================================================*/ int main (int argc, char * argv[]) { int status; int dbh[MAX_LOOPS]; char * cstr; int i; printf("--------------------------------------nn");
cstr = argv[1]; else cstr = "scott/tiger"; status = sqlo_init(0); if (SQLO_SUCCESS != status) { printf ("sql_init failed. Exitingn"); exit(1); } for (i = 0; i < MAX_LOOPS; i++) { status = sqlo_connect(&dbh, cstr); if (SQLO_SUCCESS == status) printf("Connected. dbh=%dn", dbh); else { printf("connect failed with status: %d, %sn", status , sqlo_geterror(dbh)); exit(1); } if (!test_plsql(dbh)) exit(1); if (!test_insert(dbh)) exit(1); if (!test_array_insert(dbh)) /* bind by name */
exit(1); if (!test_array_insert2(dbh)) /* bind by pos */ exit(1); if (!test_exists(dbh)) exit(1); if (!test_count(dbh)) exit(1); if (!test_reopen(dbh)) exit(1); if (!test_select2(dbh)) exit(1); cleanup(dbh); if (SQLO_SUCCESS != (status = sqlo_rollback(dbh))) printf("rollback failed (%d): %sn", status, sqlo_geterror(dbh)); } for (i = 0; i < MAX_LOOPS; i++) { if (SQLO_SUCCESS != sqlo_finish(dbh)) { printf("sql_finish failed for dbh: %dn%sn", dbh, sqlo_geterror(dbh)); exit(1); } } return (0); }
RBO首先从下往上察看WHERE子句,按照以下10个标准(删掉了原文中关于CLUSTER的部分,因为很少用到),为每个子句打分: 1. Single row by ROWID 4. Single row by unique index 8. Composite key 9. Single-column non-unique index 10. Bounded range search on indexed columns 11. Unbounded range search on indexed columns 12. Sort-merge join 13. MAX or MIN of indexed column 14. ORDER BY on indexed columns 15. Full table-scan
比如这个值变化 x ,系统等待时间减少 y 要使系统变化时间减少到 2y ,绝对无法量化出 这个值该为多少这个时候除了依赖于类似环境的经验,或者说在不同值下长期稳定运行观察性能以积累经验,是没有什么其他办法的 你查询的这个值,跟这个参数本身,应该是有影响关系的,这个参数影响到全表扫描和索引扫描之间的比例,但如果说全表扫描和索引扫描的等待时间,却并不和这个比例有简单的线性关系,想用初等数学的方法来描述是不现实的
INSERT INTO city_populations (city_name, census_year, population) SELECT city_name, 1990, pop_1990 FROM city_populations_ext WHERE pop_1990 IS NOT NULL UNION ALL SELECT city_name, 2000, pop_2000 FROM city_populations_ext WHERE pop_2000 IS NOT NULL;
CREATE OR REPLACE PACKAGE census_package AS TYPE pop_cursor_type IS REF CURSOR RETURN city_populations_ext%ROWTYPE; FUNCTION census_transform ( indata IN pop_cursor_type) RETURN city_populations_table PARALLEL_ENABLE (PARTITION indata BY ANY) PIPELINED; END; /
函数中的PARALLEL_ENABLE子句使数据库可并行执行函数。PARTITION indata BY ANY子句指出输入行可被分割为任意数量的数据桶,然后便可对其进行并行处理。PIPELINED子句使函数能递增地返回结果集,同时其他输入数据仍能得到处理。在调用函数的查询执行期间,可设想数据行都“经过(flowing through)”此函数。在清单1中,在包主体(PACKAGE BODY)中定义的函数代码负责将每个输入行转换成要求的两个输出行。
ALTER SESSION ENABLE PARALLEL DML; INSERT /*+ APPEND PARALLEL (t,4) */ INTO city_populations t SELECT * FROM TABLE(census_package. census_transform( CURSOR(SELECT city_name, pop_1990, pop_2000 FROM city_populations_ext)));
MERGE INTO city_populations dest USING (SELECT * FROM TABLE (census_package.census_transform( CURSOR(SELECT city_name, pop_1990, pop_2000 FROM city_populations_ext)))) src ON (dest.city_name = src.city_name AND dest.census_year = src.census_year) WHEN MATCHED THEN UPDATE SET dest.population = src.population WHEN NOT MATCHED THEN INSERT (city_name, census_year, population) VALUES (src.city_name, src.census_year, src.population);
2: 在定位到底使用哪个日志文件的时候,并不是用数据文件中的 low scn 去框,在日志文件的low scn and next scn 之间就利用该日志文件。而是在数据文件头中有 RBA 的记录,RBA 包含了日志序号、block number 、slot number 。这样可以直接定位到日志文件(归档日志文件)和具体的位置
There is little point comparing an execution plan to the RBO plan and being surprised if you get a different execution plan. Hopefully it is fairly clear by now that the CBO uses relative 'costs' of execution plans to determine an execution plan.
- All hints (except RULE) cause you to use the CBO. Hence, it is not a good idea to use hints unless the tables are analyzed or you are fully hinting the query.
Tables A & B both have indexes on the nullable IND_COL column. A hint has been supplied suggesting that these indexes should be used. The VALUE column in both tables is unindexed.
If we drive the query from A, then we cannot use the index on A.IND_COL as the column is nullable as we may miss some rows. Hence the 'index(A)' hint is invalid and is ignored. The index on B can be used as it is a valid way to access table B.
#srds number of single block reads sreadtm single block read time #mrds number of multi block reads mreadtm multi block read time #CPUCycles number of CPU Cycles CPUspeed CPU cycles per second
create or replace procedure test1 as numLoop number := 0; begin for i in 1 .. 100000 loop numLoop := numLoop + 1; if mod(numLoop,1000) = 0 then null; end if; end loop; end; / create or replace procedure test2 as numLoop number := 0; begin for i in 1 .. 100000 loop numLoop := numLoop + 1; if numLoop = 1000 then null; numLoop := 0; end if; end loop; end; / set line 5000 serveroutput on size 1000000 declare v_run number; begin dbms_profiler.start_profiler(run_number=>v_run); test1; dbms_profiler.stop_profiler; dbms_profiler.start_profiler(run_number=>v_run); test2; dbms_profiler.stop_profiler; end; / @?/plsql/demo/profsum
set linesize 131 col text format a24 col run_comment format a12 col run_system_info format a12 col run_comment1 format a12 col run_owner format a12 col spare1 format a12 select * from plsql_profiler_runs order by 1;
col unit_type format a18 col unit_owner format a12 col unit_name format a18 select * from plsql_profiler_units order by 1;
declare v_run number; begin dbms_profiler.start_profiler(run_number=>v_run); &procedure_name; dbms_profiler.stop_profiler; dbms_profiler.rollup_run(v_run); prof_report_utilities.print_run(v_run); end;
如果输出信息混乱,清在plsql/demo/profsum.sql中添加如下内容 column owner format a11 column unit_name format a14 column text format a40 column runid format 9999 column secs format 99999.99 column hsecs format 999999.99 column grand_total format 9999.99 column run_comment format a40 column line# format 99999 column pct format 999.9 column unit_owner format a11
UNIT_OWNER UNIT_NAME SECONDS PERCENTAG ----------- -------------- --------- --------- SCOTT TEST1 .36 60.35 SCOTT TEST2 .24 39.63 .00 .02
Elapsed: 00:00:00.01 to_char(p1.max_time/p1.min_time,'999999.99') as "Max/min", * ERROR at line 9: ORA-01476: divisor is equal to zero
Elapsed: 00:00:00.06
no rows selected
Elapsed: 00:00:00.07
SECONDS UNIT_OWNER UNIT_NAME LINE# TEXT -------- ----------- -------------- ------ ------------------------------------ .2 SCOTT TEST1 7 if mod(numLoop,1000) = 0 then .1 SCOTT TEST1 5 for i in 1 .. 100000 loop .1 SCOTT TEST1 6 numLoop := numLoop + 1; .1 SCOTT TEST2 6 numLoop := numLoop + 1; .1 SCOTT TEST2 7 if numLoop = 1000 then .1 SCOTT TEST2 5 for i in 1 .. 100000 loop
6 rows selected.
Elapsed: 00:00:00.08
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.04
no rows selected
Elapsed: 00:00:00.01
no rows selected
Elapsed: 00:00:00.00
LINES_EXECUTED -------------- 0
Elapsed: 00:00:00.01
LINES_PRESENT ------------- 0
Elapsed: 00:00:00.00 ==================trace info================= ========Results for run #30 made on 29-JAN-05 19:05:54 ======= (29-JAN-05) Run total time: .64 seconds Unit #1: . - Total time: .00 seconds Unit #2: SCOTT.TEST1 - Total time: .36 seconds 1 0 .000007 procedure test1 2 as 3 1 .000001 .000001 numLoop number := 0; 4 begin 5 100,001 .095427 .00000095 for i in 1 .. 100000 loop 6 100,000 .089174 .00000089 numLoop := numLoop + 1; 7 100,000 .178602 .00000178 if mod(numLoop,1000) = 0 then 8 null; 9 end if; 10 end loop; 11 1 .000001 .000001 end ========Results for run #31 made on 29-JAN-05 19:05:55 ====== (29-JAN-05) Run total time: .50 seconds Unit #1: . - Total time: .00 seconds Unit #2: SCOTT.TEST2 - Total time: .24 seconds 1 0 .000007 procedure test2 2 as 3 1 .000001 .000001 numLoop number := 0; 4 begin 5 100,001 .07694 .00000076 for i in 1 .. 100000 loop 6 100,000 .083937 .00000083 numLoop := numLoop + 1; 7 100,000 .077514 .00000077 if numLoop = 1000 then 8 null; 9 100 .000081 .00000081 numLoop := 0; 10 end if; 11 end loop; 12 1 .000001 .000001 end ================================================
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.07 ========= Profiler report - all runs rolled up ======== Unit .: Unit SCOTT.TEST1: 1 0 .000007 procedure test1 2 as 3 1 .000001 .000001 numLoop number := 0; 4 begin 5 100,001 .095427 .00000095 for i in 1 .. 100000 loop 6 100,000 .089174 .00000089 numLoop := numLoop + 1; 7 100,000 .178602 .00000178 if mod(numLoop,1000) = 0 then 8 null; 9 end if; 10 end loop; 11 1 .000001 .000001 end Unit SCOTT.TEST2: 1 0 .000007 procedure test2 2 as 3 1 .000001 .000001 numLoop number := 0; 4 begin 5 100,001 .07694 .00000076 for i in 1 .. 100000 loop 6 100,000 .083937 .00000083 numLoop := numLoop + 1; 7 100,000 .077514 .00000077 if numLoop = 1000 then 8 null; 9 100 .000081 .00000081 numLoop := 0; 10 end if; 11 end loop; 12 1 .000001 .000001 end =======================================
如图四所示,SQL1执行了40w次以上,使用了总CPU资源的33.6%,SQL2/SQL3虽然执行次数不是很多,但它的Get per Exec较大,每次19w个logical reads左右;这3个SQL共使用CPU资源的33.6+26.4+26.1=86.1%,如果优化合适的话,应该可以将它们消耗的CPU资源降到40%左右,那如图三中所示的CPU time总的等待时间就会大幅下降;也就是说数据库任何坏的征兆,都会在多个地方体现,调优的首要工作,就是找出主要矛盾,然后分析该SQL的执行计划,找出较恰当的执行效果。
在9204上dbv如果不带blocksize这个参数将会输出所有的块都是坏块 dbv file='/home/oracle/oradata/esal/undotbs01.dbf' DBVERIFY: Release 9.2.0.4.0 - Production on Fri Jan 21 17:24:20 2005 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. DBVERIFY - Verification starting : FILE = /home/oracle/oradata/esal/undotbs01.dbf Page 1 is marked corrupt *** Corrupt block relative dba: 0x000000f9 (file 0, block 1) Bad header found during dbv: Data in bad block - type: 0 format: 7 rdba: 0x00b631c2 last change scn: 0x320c.c4000523 seq: 0xb flg: 0x15 consistency value in tail: 0x5f000000 check value in block header: 0x4, computed block checksum: 0x5450 spare1: 0x5c, spare2: 0x2, spare3: 0x5d3e ***
在9205中,如果dbv不带blocksize参数,将会直接报dbv-00103并终止 dbv file='/home/oracle/esal/ITEM.dbf' DBVERIFY: Release 9.2.0.5.0 - Production on Fri Jan 21 17:29:45 2005 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. DBV-00103: Specified BLOCKSIZE (2048) differs from actual (8192)
如果在dbv带了blocksize参数,在9204/9205中都是正确的 dbv file='/home/oracle/oradata/esal/undotbs01.dbf' blocksize=8192 DBVERIFY: Release 9.2.0.4.0 - Production on Fri Jan 21 17:24:20 2005 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. DBVERIFY - Verification starting : FILE = /home/oracle/oradata/esal/undotbs01.dbf
dbv file='/home/oracle/esal/ITEM.dbf' blocksize=8192 DBVERIFY: Release 9.2.0.5.0 - Production on Fri Jan 21 17:30:31 2005 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. DBVERIFY - Verification starting : FILE = /home/oracle/esal/ITEM.dbf
表的访问SQL如下: select a.*,sysdate now,to_char(sysdate,'D') as week from agent_settime_onself a where ((start_time_1_enabled = 'Y' OR start_time_2_enabled = 'Y' OR start_time_3_enabled = 'Y' OR start_time_4_enabled = 'Y' OR start_time_5_enabled = 'Y' OR start_time_6_enabled = 'Y' OR start_time_7_enabled = 'Y') OR (stop_time_1_enable = 'Y' OR stop_time_2_enable = 'Y' OR stop_time_3_enable = 'Y' OR stop_time_4_enable = 'Y' OR stop_time_5_enable = 'Y' OR stop_time_6_enable = 'Y' OR stop_time_7_enable = 'Y'))
这么多用于判断的字段,如果都创建索引也是不合理的,再说这些字段的数据分布不均匀, 如何对这样的表结构进行优化呢?优化后的表结构如下: create table agent_settime_onself ( agent_settime_onself_id number(11,0), agent_card_type_id number(11,0) not null enable, start_time_1 char(5) default '00:00' not null enable, start_time_enabled char(7) default 'NNNNNNN', stop_time_1 char(5) default '23:59' not null enable, stop_time_enable char(7) default 'NNNNNNN', start_time_2 char(5) default '00:00' not null enable, stop_time_2 char(5) default '23:59' not null enable, start_time_3 char(5) default '00:00' not null enable, stop_time_3 char(5) default '23:59' not null enable, start_time_4 char(5) default '00:00' not null enable, stop_time_4 char(5) default '23:59' not null enable, start_time_5 char(5) default '00:00' not null enable, stop_time_5 char(5) default '23:59' not null enable, start_time_6 char(5) default '00:00' not null enable, stop_time_6 char(5) default '23:59' not null enable, start_time_7 char(5) default '00:00' not null enable, stop_time_7 char(5) default '23:59' not null enable)
create index idx_aso_sta_enabled on agent_settime_onself(start_time_enabled); create index idx_aso_sto_enabled on agent_settime_onself(stop_time_enabled);
那以后访问该表的SQL如下: select a.*,sysdate now,to_char(sysdate,'D') as week from agent_settime_onself a where start_time_enabled = 'YYYYYYY'
select a.*,sysdate now,to_char(sysdate,'D') as week from agent_settime_onself a where stop_time_enabled = 'YYYYYYY'
/home/oracle/product/9.2.0/bin/sqlplus -s aaa/bbb@ccc<<! set head off set timing off spool /home/oracle/sql/backup/snap_begin.lst select min(snap_id) snap_id from stats$snapshot where snap_time between trunc(sysdate) and trunc(sysdate)+1; spool off spool /home/oracle/sql/backup/snap_end.lst select max(snap_id) snap_id from stats$snapshot where snap_time between trunc(sysdate) and trunc(sysdate)+1; spool off exit !
Oracle9i offers a variety of indexing methods including b-tree, bitmapped, and function-based indexes. Regardless of the index structure, an Oracle index can be thought of as a pair bond of a symbolic key, paired with a ROWID.
The goal of Oracle index access is to gather the ROWIDs required to quickly retrieve the desired rows from the table.Within Oracle, we see the following types of index access.
关于对表及索引monitoring的使用. 除了logmnr及audit之外,如何才能监控对表的若干操作呢? 大家可以试试表的monitoring.表的monitoring与索引的 monitoring稍有区别.可以看出table及index的monitoring功能都很弱,如果相做到精细监控,还是用audit比较好。 表的monitoring主要记录针对的一些操作,如truncate/delete/update/insert等 索引的monitoring主要记录索引是否被使用过. 如何监控/取消监控表呢? alter table &table_name monitoring; alter table &table_name nomonitoring; 如何监控/取消监控索引呢? alter index &index_name monitoring usage; alter index &index_name nomonitoring usage;
@connect_sys Enter value for passwd: oracle Connected. 16:27:08 SQL> desc DBA_TAB_MODIFICATIONS Name Null? Type ----------------------------------------------------------------- -------- --------------------------------------------- TABLE_OWNER VARCHAR2(30) TABLE_NAME VARCHAR2(30) PARTITION_NAME VARCHAR2(30) SUBPARTITION_NAME VARCHAR2(30) INSERTS NUMBER UPDATES NUMBER DELETES NUMBER TIMESTAMP DATE TRUNCATED VARCHAR2(3)
16:27:13 SQL> select count(*) from DBA_TAB_MODIFICATIONS ;
COUNT(*) ---------- 0
1 row selected.
create table test monitoring as select count(*) as rns from all_users ;
create table test1(test_id number(9),id number(9),log_time date) partition by range(log_time) (partition t1_01 values less than (to_date('2004-02-01','yyyy-mm-dd')), partition t1_02 values less than (to_date('2004-03-01','yyyy-mm-dd')), partition t1_03 values less than (to_date('2004-04-01','yyyy-mm-dd')), partition t1_04 values less than (to_date('2004-05-01','yyyy-mm-dd')), partition t1_05 values less than (to_date('2004-06-01','yyyy-mm-dd')), partition t1_06 values less than (to_date('2004-07-01','yyyy-mm-dd')), partition t1_07 values less than (to_date('2004-08-01','yyyy-mm-dd')), partition t1_08 values less than (to_date('2004-09-01','yyyy-mm-dd')), partition t1_09 values less than (to_date('2004-10-01','yyyy-mm-dd')), partition t1_10 values less than (to_date('2004-11-01','yyyy-mm-dd')), partition t1_11 values less than (to_date('2004-12-01','yyyy-mm-dd')), partition t1_12 values less than (to_date('2005-01-01','yyyy-mm-dd')));
create index idx_test1_logtime on test1(log_time) local; create index idx_test1_testid on test1(test_id) local; create index idx_test1_id on test1(id) local;
create index idx_test2_logtime on test2(log_time); create index idx_test2_testid on test2(test_id); create index idx_test2_id on test2(id);
关于分区表与非分区表的测试 begin for i in 1 .. 1000 loop for j in 1 .. 12 loop for k in 1 .. 28 loop insert into test1 values(seq_t1.nextval,i,to_date('2004-'||to_char(j)||'-'||to_char(k),'yyyy-mm-dd')); end loop; end loop; end loop; end; / begin for i in 1 .. 1000 loop for j in 1 .. 12 loop for k in 1 .. 28 loop insert into test2 values(seq_t2.nextval,i,to_date('2004-'||to_char(j)||'-'||to_char(k),'yyyy-mm-dd')); end loop; end loop; end loop; end; /
SQL> select count(*) from test1;
COUNT(*) ---------- 336000
Elapsed: 00:00:00.02
Statistics ---------------------------------------------------------- 0 recursive calls 0 db block gets 1104 consistent gets 0 physical reads 0 redo size 394 bytes sent via SQL*Net to client 508 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed
SQL> select count(*) from test2;
COUNT(*) ---------- 336000
Elapsed: 00:00:00.02
Statistics ---------------------------------------------------------- 0 recursive calls 0 db block gets 1067 consistent gets 0 physical reads 0 redo size 394 bytes sent via SQL*Net to client 508 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed
统计显示,分区表在全表扫描时将比非分区表需要更多的逻辑读
SQL> select count(*) from test1 where test_id = 1000;
COUNT(*) ---------- 1
Statistics ---------------------------------------------------------- 0 recursive calls 0 db block gets 24 consistent gets 0 physical reads 0 redo size 393 bytes sent via SQL*Net to client 508 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed
SQL> select count(*) from test2 where test_id = 337000;
COUNT(*) ---------- 1
Statistics ---------------------------------------------------------- 0 recursive calls 0 db block gets 2 consistent gets 0 physical reads 0 redo size 393 bytes sent via SQL*Net to client 508 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed
在没有与分区字段组合查询时,分区表需要更多的逻辑读
SQL> select count(*) 2 from test1 3 where id = 1000 4 and log_time between to_date('2004-11-01','yyyy-mm-dd') and to_date('2004-11-30 23:59:59','yyyy-mm-dd hh24:mi:ss');
COUNT(*) ---------- 28
Elapsed: 00:00:00.01
Statistics ---------------------------------------------------------- 0 recursive calls 0 db block gets 3 consistent gets 0 physical reads 0 redo size 393 bytes sent via SQL*Net to client 508 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk)
SQL> select count(*) 2 from test2 3 where id = 1000 4 and log_time between to_date('2004-11-01','yyyy-mm-dd') and to_date('2004-11-30 23:59:59','yyyy-mm-dd hh24:mi:ss');
COUNT(*) ---------- 28
Elapsed: 00:00:00.00
Statistics ---------------------------------------------------------- 0 recursive calls 0 db block gets 5 consistent gets 0 physical reads 0 redo size 393 bytes sent via SQL*Net to client 508 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed
create or replace trigger tri_test_insert before insert on test for each row begin if :new.age > 999 then rollback; end if; end; /
10:41:39 SQL> insert into test values(1,'abc',1000); insert into test values(1,'abc',1000) * ERROR at line 1: ORA-04092: cannot ROLLBACK in a trigger ORA-06512: at "TEST.TRI_TEST_INSERT", line 3 ORA-04088: error during execution of trigger 'TEST.TRI_TEST_INSERT'
create or replace trigger tri_test_insert before insert on test for each row begin if :new.age > 999 then raise_application_error(-20100,'please insert a positive value'); end if; end; /
10:42:33 SQL> insert into test values(1,'abc',1000); insert into test values(1,'abc',1000) * ERROR at line 1: ORA-20100: please insert a positive value ORA-06512: at "TEST.TRI_TEST_INSERT", line 3 ORA-04088: error during execution of trigger 'TEST.TRI_TEST_INSERT'
Elapsed: 00:00:00.02 10:42:39 SQL> host oerr ora 20100
10:43:03 SQL> select * from test;
从这里可以发现,oracle的触发器与mssqlserver的触发器差别是很大的,
mssqlserver允许在触发器内部使用rollback的.还有说是mssqlserver的
instead of触发器可以在表上,也可以在视图上,而oracle的instead of
触发器只能作用于视图上。
--触发器中的自治事务及动态DDL -- create a main table and its shadow table create table parts (pnum number(4), pname varchar2(15)); create table parts_log (pnum number(4), pname varchar2(15)); -- create an autonomous trigger that inserts into the -- shadow table before each insert into the main table create trigger parts_trig before insert on parts for each row declare pragma autonomous_transaction; begin insert into parts_log values(:new.pnum, :new.pname); commit; end; -- insert a row into the main table, and then commit the insert insert into parts values (1040, 'head gasket'); commit; -- insert another row, but then roll back the insert insert into parts values (2075, 'oil pan'); rollback; -- show that only committed inserts add rows to the main table select * from parts order by pnum; pnum pname ------- --------------- 1040 head gasket -- show that both committed and rolled-back inserts add rows -- to the shadow table select * from parts_log order by pnum; pnum pname ------- --------------- 1040 head gasket 2075 oil pan --在触发器中执行DDL. create trigger bonus_trig after update on bonus declare pragma autonomous_transaction; -- enables trigger to perform ddl begin execute immediate 'drop table temp_bonus'; end;
AAAF2F68 685266707 .00 .18 61327.00 1 2004-12-13/14:48:35 select a.user_name,b.* from reseller_base a,reseller_user b where a.reseller_id=b.reseller_id and a.user_name=:"SYS_B_0" order by reseller_user_id
表a,b数据量都在10,0000左右,而且a.user_name是唯一索引,这个地方a,b是一对多的关系, 如果a.user_name=:"SYS_B_0"有数据返回的话,记录集也会很小,但它们的逻辑读竟然达到 61327,虽然该SQL存在问题。 explain plan for select a.user_name,b.* from reseller_base a,reseller_user b where a.reseller_id=b.reseller_id and a.user_name=:"SYS_B_0" order by reseller_user_id;
16:16:30 SQL> select * from table(dbms_xplan.display);
发现在b表上存在index full scan,也就是说优化器选择了用reseller_user_id字段上的索引, 而没有选择reseller_id上的索引.
@list_index Enter value for 1: reseller_user old 3: where a.index_name=b.index_name and a.table_name=upper('&1') new 3: where a.index_name=b.index_name and a.table_name=upper('reseller_user')
OWNER INDEX_NAME COLUMN_NAME STATUS INDEX_TYPE CP ---------- ------------------------ -------------------------------- ---------- --------------------- --- CYBERCAFE IDX_RU_LAST_LOGIN LAST_LOGIN_IPADDR VALID NORMAL 1 CYBERCAFE IDX_RU_LAST_LOGIN LAST_LOGIN_TIME VALID NORMAL 2 CYBERCAFE IDX_RU_MCID MCID VALID NORMAL 1 CYBERCAFE IDX_RU_RESELLER_ID RESELLER_ID VALID NORMAL 1 CYBERCAFE IDX_RU_RUID RESELLER_USER_ID VALID NORMAL 1 CYBERCAFE IDX_RU_USERNAME USERNAME VALID NORMAL 1
explain plan for select /*+ index(b idx_ru_reseller_id) */ a.user_name,b.* from reseller_base a,reseller_user b where a.reseller_id=b.reseller_id and a.user_name=:"SYS_B_0" order by reseller_user_id;
--自动重编译对象 create or replace procedure timer_auto_recompile_objs as cursor objects_list is select object_name,object_type from user_objects where status='INVALID'; begin for v_object in objects_list loop if v_object.object_type='PROCEDURE' then execute immediate 'alter procedure '||v_object.object_name||' compile'; elsif v_object.object_type='VIEW' then execute immediate 'alter view '||v_object.object_name||' compile'; elsif v_object.object_type='MATERIALIZED VIEW' then execute immediate 'alter materialized view '||v_object.object_name||' compile'; end if; end loop; end;
[oracle@data1 oracle]$ crontab -l # DO NOT EDIT THIS FILE - edit the master and reinstall. # (/tmp/crontab.21703 installed on Mon Nov 22 09:46:47 2004) # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $) 00 05 * * * /home/oracle/sql/backup/auto_collect_disk.sh >> /home/oracle/sql/backup/tmp.lst 2>&1
[oracle@www1 sql]$ more backup/auto_send_disk.sh #!/bin/sh . ~oracle/.bash_profile
/home/oracle/product/9.2.0/bin/sqlplus -s xxxx/yyyy@zzzz<<! set timing off spool /home/oracle/sql/backup/disk_status.lst set linesize 81 col used_status format a69 select to_char(snap_id,'yyyy-mm-dd') snap_id,used_status from disk_status where snap_id = trunc(sysdate);
set linesize 101 set pagesize 999 col "表空间名" format a12 col mbytes format 9999.99 col "已使用空间(M)" format 99999.99 col 使用比 format a8 col "空闲空间(M)" format 9999.99 col "最大块(M)" format 9999.99 SELECT F.TABLESPACE_NAME "表空间名", D.TOT_GROOTTE_MB "表空间大小(M)", D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)", TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES)/D.TOT_GROOTTE_MB*100,2),'990.99') 使用比, F.TOTAL_BYTES "空闲空间(M)",F.MAX_BYTES "最大块(M)" FROM (SELECT TABLESPACE_NAME,ROUND(SUM(BYTES)/(1024*1024),2) TOTAL_BYTES,ROUND(MAX(BYTES)/(1024*1024),2) MAX_BYTES FROM SYS.DBA_FREE_SPACE GROUP BY TABLESPACE_NAME) F, (SELECT DD.TABLESPACE_NAME,ROUND(SUM(DD.BYTES)/(1024 * 1024), 2) TOT_GROOTTE_MB FROM SYS.DBA_DATA_FILES DD GROUP BY DD.TABLESPACE_NAME) D WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME ORDER BY 4 DESC;
spool off exit !
mail -s "磁盘信息发布" ####@###.## < /home/oracle/sql/backup/disk_status.lst rm /home/oracle/sql/backup/disk_status.lst
[oracle@www1 sql]$crontab -l # DO NOT EDIT THIS FILE - edit the master and reinstall. # (/tmp/crontab.32619 installed on Mon Nov 22 09:51:02 2004) # (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $) 30 05 * * * /home/oracle/sql/backup/auto_send_disk.sh >> /home/oracle/sql/backup/disk.lst 2>&1
--如何自动生成statspack的报表将发邮件到指定人的邮箱 [oracle@www1 sql]$ more backup/auto_send_perf.sh #!/bin/sh . ~oracle/.bash_profile
/home/oracle/product/9.2.0/bin/sqlplus -s perfstat/xxxx@yyyy<<! set head off set timing off spool /home/oracle/sql/backup/snap_begin.lst select min(snap_id) snap_id from stats$snapshot where snap_time between trunc(sysdate) and trunc(sysdate)+1; spool off spool /home/oracle/sql/backup/snap_end.lst select max(snap_id) snap_id from stats$snapshot where snap_time between trunc(sysdate) and trunc(sysdate)+1; spool off exit !
create materialized view mv_sellstatbyprovince_200411 build immediate refresh complete on demand as select a.province_id as pro_id,a.name as p_name,e.name as c_name,f.name as g_name,e.game_card_type_id,f.game_id, sum(c.transaction_amount) as s_money,sum(c.game_card_num) as s_num,sum(game_card_cost) as cost from province a,city b,game f,game_card_type e,reseller_base d,v_sale_tmp_log c where a.province_id = b.province_id and d.city_id = b.city_id and c.reseller_id = d.reseller_id and c.game_card_type_id = e.game_card_type_id and e.game_id = f.game_id and c.log_time between to_date('2004-11-01','yyyy-mm-dd') and to_date('2004-12-01','yyyy-mm-dd') and c.is_success = 'Y' group by a.province_id,a.name,f.game_id,f.name,e.game_card_type_id,e.name; 将这个SQL封装在存储过程中执行时报错:
create or replace procedure timer_sellstatbyprovince_cmv as v_begin varchar2(30); v_end varchar2(30); v_sql varchar2(2000); v_mvname varchar2(30); v_success varchar2(3); v_format varchar2(36); begin v_format := 'yyyy-mm-dd hh24:mi:ss'; v_mvname := to_char(add_months(sysdate,-1),'yyyymm'); v_success := ''''||'Y'||''''; v_begin := v_mvname||'01'; v_mvname := upper('mv_sellstatbyprovince_'||v_mvname); v_end := to_char(last_day(to_date(v_begin,v_format))+86399/86400,v_format); v_sql := 'create materialized view '||v_mvname||' '; v_sql := v_sql||'build immediate refresh complete on demand as '; v_sql := v_sql||'select a.province_id as pro_id,a.name as p_name,e.name as c_name,f.name as g_name,e.game_card_type_id,f.game_id,'; v_sql := v_sql||'sum(c.transaction_amount) as s_money,sum(c.game_card_num) as s_num,sum(game_card_cost) as cost '; v_sql := v_sql||'from province a,city b,game f,game_card_type e,reseller_base d,v_sale_tmp_log c '; v_sql := v_sql||'where a.province_id = b.province_id and d.city_id = b.city_id and c.reseller_id = d.reseller_id '; v_sql := v_sql||'and c.game_card_type_id = e.game_card_type_id and e.game_id = f.game_id '; v_sql := v_sql||'and c.log_time between to_date('||''''||v_begin||''''||','''||v_format||''') '; v_sql := v_sql||'and to_date('||''''||v_end||''''||','''||v_format||''') and c.is_success = '||v_success||' '; v_sql := v_sql||'group by a.province_id,a.name,f.game_id,f.name,e.game_card_type_id,e.name'; execute immediate v_sql; end; /
Elapsed: 00:00:00.04 16:51:16 SQL> exec TIMER_SELLSTATBYPROVINCE_CMV; BEGIN TIMER_SELLSTATBYPROVINCE_CMV; END;
* ERROR at line 1: ORA-01031: insufficient privileges ORA-06512: at "CYBERCAFE.TIMER_SELLSTATBYPROVINCE_CMV", line 26 ORA-06512: at line 1
Elapsed: 00:00:00.05 16:51:22 SQL> connect sys/xxxxxx@yyyyyy as sysdba Connected. 16:51:39 SQL> grant create materialized view to cybercafe;
begin for i in 1..10000 loop insert into test4 values(i,to_char(i,'00000'),mod(i,2)); end loop; end;
SQL> show parameter cursor_sharing
NAME TYPE VALUE ------------------------------------ -------------------------------- ------------------------------ cursor_sharing string SIMILAR SQL> select * from test4 where id = 9;
ID NAME AGE ---------- -------------------- ---------- 9 00009 1
Elapsed: 00:00:00.02 SQL> select sql_text from v$sql where sql_text like 'select * from test4%';
SQL_TEXT ------------------------------------------------------------------------------------------------------------------------- select * from test4 where id = :"SYS_B_0"
Elapsed: 00:00:00.03 SQL> select * from test4 where id = 10;
ID NAME AGE ---------- -------------------- ---------- 10 00010 0
Elapsed: 00:00:00.01 SQL> select sql_text from v$sql where sql_text like 'select * from test4%';
SQL_TEXT ------------------------------------------------------------------------------------------------------------------------- select * from test4 where id = :"SYS_B_0" select * from test4 where id = :"SYS_B_0"
Elapsed: 00:00:00.12 13:09:06 SQL> begin 13:09:14 2 for i in 1..10000 loop insert into test4 values(i,to_char(i,'00000'),mod(i,2)); 13:09:14 3 end loop; 13:09:14 4 end; 13:09:14 5 13:09:14 6 13:09:15 7 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.73 13:09:17 SQL> show parameter cursor_sharing
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ cursor_sharing string EXACT 13:09:24 SQL> select * from test4 where id = 1;
ID NAME AGE ---------- ------------------------------------------------------ ---------- 1 00001 1
1 row selected.
13:11:16 SQL> select * from test4 where id = 2;
ID NAME AGE ---------- ------------------------------------------------------ ---------- 2 00002 0
1 row selected.
13:11:26 SQL> select sql_text from v$sql where sql_text like 'select * from test4%';
SQL_TEXT ------------------------------------------------------------------------------------------------------------------------- select * from test4 where id = 2 select * from test4 where id = 1
2 rows selected.
Elapsed: 00:00:00.24 13:11:50 SQL> alter session set cursor_sharing=force;
Session altered.
Elapsed: 00:00:00.00 13:12:01 SQL> select * from test4 where id = 3;
ID NAME AGE ---------- ------------------------------------------------------ ---------- 3 00003 1
1 row selected.
Elapsed: 00:00:00.02 13:12:05 SQL> select * from test4 where id = 4;
ID NAME AGE ---------- ------------------------------------------------------ ---------- 4 00004 0
1 row selected.
Elapsed: 00:00:00.01 13:12:08 SQL> select sql_text from v$sql where sql_text like 'select * from test4%';
SQL_TEXT ------------------------------------------------------------------------------------------------------------------------- select * from test4 where id = 2 select * from test4 where id = 1 select * from test4 where id = :"SYS_B_0"
3 rows selected.
Elapsed: 00:00:00.36 13:12:11 SQL> alter session set cursor_sharing=similar;
Session altered.
Elapsed: 00:00:00.00 13:12:20 SQL> select * from test4 where id = 5;
ID NAME AGE ---------- ------------------------------------------------------ ---------- 5 00005 1
1 row selected.
Elapsed: 00:00:00.01 13:12:24 SQL> select * from test4 where id = 6;
ID NAME AGE ---------- ------------------------------------------------------ ---------- 6 00006 0
1 row selected.
Elapsed: 00:00:00.01 13:12:27 SQL> select sql_text from v$sql where sql_text like 'select * from test4%';
SQL_TEXT ------------------------------------------------------------------------------------------------------------------------- select * from test4 where id = 2 select * from test4 where id = 1 select * from test4 where id = :"SYS_B_0"
3 rows selected.
Elapsed: 00:00:00.22 13:12:30 SQL> analyze table test4 compute statistics for all columns size 32;
Table analyzed.
Elapsed: 00:00:00.27 13:13:44 SQL> select * from test4 where id = 7;
ID NAME AGE ---------- ------------------------------------------------------ ---------- 7 00007 1
1 row selected.
Elapsed: 00:00:00.02 13:13:54 SQL> select * from test4 where id = 8;
ID NAME AGE ---------- ------------------------------------------------------ ---------- 8 00008 0
1 row selected.
Elapsed: 00:00:00.01 13:13:57 SQL> select sql_text from v$sql where sql_text like 'select * from test4%';
SQL_TEXT ------------------------------------------------------------------------------------------------------------------------- select * from test4 where id = 2 select * from test4 where id = :"SYS_B_0" select * from test4 where id = :"SYS_B_0"
3 rows selected.
Elapsed: 00:00:00.43 13:14:00 SQL> select * from test4 where id = 9;
ID NAME AGE ---------- ------------------------------------------------------ ---------- 9 00009 1
1 row selected.
Elapsed: 00:00:00.02 13:14:46 SQL> select * from test4 where id = 10;
ID NAME AGE ---------- ------------------------------------------------------ ---------- 10 00010 0
1 row selected.
Elapsed: 00:00:00.01 13:14:49 SQL> select sql_text from v$sql where sql_text like 'select * from test4%';
SQL_TEXT ------------------------------------------------------------------------------------------------------------------------- select * from test4 where id = 2 select * from test4 where id = :"SYS_B_0" select * from test4 where id = :"SYS_B_0" select * from test4 where id = :"SYS_B_0" select * from test4 where id = :"SYS_B_0"
5 rows selected.
Elapsed: 00:00:00.25 13:14:52 SQL> alter session set cursor_sharing=force;
Session altered.
Elapsed: 00:00:00.00 13:15:04 SQL> select * from test4 where id = 11;
ID NAME AGE ---------- ------------------------------------------------------ ---------- 11 00011 1
1 row selected.
Elapsed: 00:00:00.02 13:15:08 SQL> select * from test4 where id = 12;
ID NAME AGE ---------- ------------------------------------------------------ ---------- 12 00012 0
1 row selected.
Elapsed: 00:00:00.01 13:15:10 SQL> select sql_text from v$sql where sql_text like 'select * from test4%';
SQL_TEXT ------------------------------------------------------------------------------------------------------------------------- select * from test4 where id = 2 select * from test4 where id = :"SYS_B_0" select * from test4 where id = :"SYS_B_0" select * from test4 where id = :"SYS_B_0" select * from test4 where id = :"SYS_B_0" select * from test4 where id = :"SYS_B_0" select * from test4 where id = :"SYS_B_0"
begin for i in 1 .. 100 loop for j in 1 .. 12 loop for k in 1 .. 28 loop if mod(i,2) = 0 then insert into test values(i,to_date('2004-'||to_char(j)||'-'||to_char(k),'yyyy-mm-dd'),32,'RW'); else insert into test values(i,to_date('2004-'||to_char(j)||'-'||to_char(k),'yyyy-mm-dd'),32,'RS'); end if; end loop; end loop; end loop; end;
create materialized view log on test with rowid (id,log_time,qty,type) including new values; create materialized view mv_test refresh fast on commit enable query rewrite as select to_char(log_time,'yyyy-mm') as log_time,count(*) as qty_c,sum(qty) qty_s from test group by to_char(log_time,'yyyy-mm');
在10.1.0.2上 select count(*),sum(qty) from test where log_time >= to_date('2004-09-01','yyyy-mm-dd') and log_time <= to_date('2004-09-30 23:59:59','yyyy-mm-dd hh24:mi:ss');
SQL> set autot on SQL> select count(*),sum(qty) from test 2 where log_time >= to_date('2004-09-01','yyyy-mm-dd') and log_time <= to_date('2004-09-30 23:59:59','yyyy-mm-dd hh24:mi:ss');