Oracle enqueue informations

Oracle enqueue informations

CF enqueue – The CF enqueue is a Control File enqueue (a.k.a. enq: CF – contention) and happens during parallel access 6to the control files.
The CF enqueue can be seen during any action that requires reading the control file, such as redo log archiving, redo log switches and begin backup commands.

CI Enqueue – The CI enqueue is the Cross Instance enqueue (a.k.a. enq: US – contention) and 
happens when a session executes a cross instance call such as a query over a database link.

FB enqueue – This is the Format Block enqueue, used only when data blocks are using ASSM (Automatic Segment Space Management or bitmapped freelists).  
As we might expect, common FB enqueue relate to buffer busy conditions, especially since ASSM tends to cause performance problems under heavily DML loads.

HV enqueue – The HV enqueue (a.k.a. enq: HV – contention) is similar to the HW enqueue but for parallel direct path INSERTs. 

HW enqueue – The HW High Water enqueue (a.k.a. enq: HW – contention) occurs 
when competing processing are inserting into the same table and are trying to increase the high water mark of a table simultaneously. 
The HW enqueue can sometimes be removed by adding freelists or moving the segment to ASSM.

KO enqueue – The KO enqueue (a.k.a. enq: KO – fast object checkpoint) is seem in Oracle STAR transformations 
and high enqueue waits can indicate a sub-optimal DBWR background process.

PE enqueue – The PE enqueue (a.k.a. enq: PE – contention) is the Parameter Enqueue, 
which happens after alter system or alter session statements.

PS enqueue – The PS enqueue is the Parallel Slave synchronization enqueue (a.k.a enq: PS – contention), 
which is only seen with Oracle parallel query.  The PS enqueue happens when pre-processing problems occur when allocating the factotum (slave) processes for OPQ.

RO Enqueue – The RO enqueue is the Reuse Object enqueue and is a cross-instance enqueue related to truncate table and drop table DDL operations.
SQ enqueue – The SQ enqueue is the Sequence Cache enqueue (a.k.a. enq: SQ – contention) is used to serialize access to Oracle sequences.
SS enqueue – The SS enqueue is the Sort Segment enqueue (a.k.a. enq:SS – contention) and these are related to the sorting of large result sets.
SS enqueue – The SS enqueues are Sort Segment enqueues (a.k.a. enq: SS – contention), and occur when a process is performing a large sort operation. 
ST enqueue – The ST enqueue can be seen in a partitioned environment when a large number of partitions are created simultaneously.
TC enqueue – The TC enqueue is related to the DBWR background process and occur when -alter tablespace- commands are issued.  
You will also see the TC enqueue when doing parallel full-table scans where rows are accessed directly, without being loaded into the data buffer cache.

TM enqueue – The TM enqueue related to Transaction Management (a.k.a. enq: TM – contention) and can be seen when tables are explicitly locked with 
reorganization activities that require locking of a table.

TQ enqueue – The TQ enqueue is the Queue Table enqueue (a.k.a. enq: TQ – DDL contention) and happens during Data ump (export import) operations.
TS enqueue – The TS enqueue is the temporary segment enqueue (a.k.a. enq: TS – contention) and these enqueues happen during disk sort operations.  
TT enqueue – The TT enqueue (a.k.a. enq: TT – contention) is used to avoid deadlocks in parallel tablespace operations.  
The TT enqueue can be seen with parallel create tablespace and parallel point in time recovery (PITR)

TX runqueue – The TX enqueue is the transaction enqueue (a.k.a. enq: TX – contention) and is commonly related to buffer busy waits, 
in conditions where multiple transaction attempt to update the same data blocks.

UL enqueue – The UL enqueue is a User Lock enqueue (a.k.a. enq: UL – contention) and happens when a lock is requested in dbms_lock.request. 
 The UL enqueue can be seen in Oracle Data Pump.
 
US Enqueue – The US enqueue happens with Oracle automatic UNDO management was undo segments are moved online and offline.

11gR2 Silent install database software

OS:RHEL6.5
All parameter and rpm package installed.

Now,we configure the reponse file(/database/response/db_install.rsp) and modify any parameter in the response file,as follows:

[oracle@trsen response]$ more db_install.rsp 
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=trsen
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.config.starterdb.characterSet=AL32UTF8

#——————————————————————————
# Specify whether user doesn't want to configure Security Updates.
# The value for this variable should be true if you don't want to configure
# Security Updates, false otherwise. 
#
# The value can be either true or false. If left blank it will be assumed
# to be false.
#
# Example    : DECLINE_SECURITY_UPDATES=false
#——————————————————————————
DECLINE_SECURITY_UPDATES=true


Then, we can runing command.

[oracle@trsen database]$  ./runInstaller -silent -force -ignoreSysPrereqs -responseFile /tmp/database/response/db_install.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 11103 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 4095 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2016-12-03_06-20-04PM. Please wait ...[oracle@trsen database]$ [WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
   CAUSE: The Central Inventory is located in the Oracle base.
   ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
[WARNING] [INS-13014] Target environment do not meet some optional requirements.
   CAUSE: Some of the optional prerequisites are not met. See logs for details. /tmp/OraInstall2016-12-03_06-20-04PM/installActions2016-12-03_06-20-04PM.log
   ACTION: Identify the list of failed prerequisite checks from the log: /tmp/OraInstall2016-12-03_06-20-04PM/installActions2016-12-03_06-20-04PM.log. Then either from the log file or from installation manual find th
e appropriate configuration to meet the prerequisites and fix it manually.
You can find the log of this install session at:
 /u01/app/oracle/oraInventory/logs/installActions2016-12-03_06-20-04PM.log
The installation of Oracle Database 11g was successful.
Please check '/u01/app/oracle/oraInventory/logs/silentInstall2016-12-03_06-20-04PM.log' for more details.

As a root user, execute the following script(s):
        1. /u01/app/oracle/oraInventory/orainstRoot.sh
        2. /u01/app/oracle/product/11.2.0/db_1/root.sh

Successfully Setup Software.

[oracle@trsen database]$ exit
logout
[root@trsen response]#  /u01/app/oracle/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oracle/oraInventory to oinstall.
The execution of the script is complete.
[root@trsen response]# /u01/app/oracle/product/11.2.0/db_1/root.sh
Check /u01/app/oracle/product/11.2.0/db_1/install/root_trsen.zr.hpay_2016-12-03_18-22-29.log for the output of root script
[root@trsen response]# more  /u01/app/oracle/product/11.2.0/db_1/install/root_trsen.zr.hpay_2016-12-03_18-22-29.log
Performing root user operation for Oracle 11g 

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/product/11.2.0/db_1
   Copying dbhome to /usr/local/bin ...
   Copying oraenv to /usr/local/bin ...
   Copying coraenv to /usr/local/bin ...

Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
Finished product-specific root actions.

configure the listener.

[oracle@trsen ~]$ netca -silent -responsefile /tmp/database/response/netca.rsp 

Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /tmp/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Running Listener Control: 
      /u01/app/oracle/product/11.2.0/db_1/bin/lsnrctl start LISTENER
    Listener Control complete.
    Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0


NOTE:
1.check all parameter configure and rpm package installed
2.check the OS env
3.add user and group
4.check directory privilege.

ORACLE 11Gr2 Interval Partitioning

ORACLE 11Gr2 Interval Partitioning
Interval partitioning is an extension of range partitioning which instructs the database to automatically create partitions of a specified interval when data inserted into the table exceeds all of the existing range partitions. 
You must specify at least one range partition. 
The range partitioning key value determines the high value of the range partitions, which is called the transition point, and the database creates interval partitions for data with values that are beyond that transition point. 
The lower boundary of every interval partition is the non-inclusive upper boundary of the previous range or interval partition.

When using interval partitioning, consider the following restrictions:
You can only specify one partitioning key column, and it must be of NUMBER or DATE type.
Interval partitioning is not supported for index-organized tables.
You cannot create a domain index on an interval-partitioned table.

You can create single-level interval partitioned tables and the following composite partitioned tables:
Interval-range
Interval-hash
Interval-list

@create_tab.sql,we can run the script file as follows:
for example 1:


create tablespace sales_tbs1 datafile '/u01/app/oracle/oradata/PROD3/salestbs1.dbf' size 10m;
create tablespace sales_tbs2 datafile '/u01/app/oracle/oradata/PROD3/salestbs2.dbf' size 10m;
create tablespace sales_tbs3 datafile '/u01/app/oracle/oradata/PROD3/salestbs3.dbf' size 10m;
create tablespace sales_tbs4 datafile '/u01/app/oracle/oradata/PROD3/salestbs4.dbf' size 10m;
CREATE TABLE interval_sales
    ( prod_id        NUMBER(6)
    , cust_id        NUMBER
    , time_id        DATE
    , channel_id     CHAR(1)
    , promo_id       NUMBER(6)
    , quantity_sold  NUMBER(3)
    , amount_sold    NUMBER(10,2)
    ) 
  PARTITION BY RANGE (time_id) 
  INTERVAL(NUMTOYMINTERVAL(1, 'YEAR'))store in (SALES_TBS1,SALES_TBS2,SALES_TBS3,SALES_TBS4)
    ( PARTITION p0 VALUES LESS THAN (TO_DATE('1-1-2008', 'DD-MM-YYYY')),
      PARTITION p1 VALUES LESS THAN (TO_DATE('1-1-2009', 'DD-MM-YYYY')),
      PARTITION p2 VALUES LESS THAN (TO_DATE('1-7-2009', 'DD-MM-YYYY')),
      PARTITION p3 VALUES LESS THAN (TO_DATE('1-1-2010', 'DD-MM-YYYY')));
      
insert into interval_sales values(908005,105,to_date('2007-11-14','yyyy-mm-dd'),'a',88005,100,500); 
insert into interval_sales values(908006,106,to_date('2008-12-10','yyyy-mm-dd'),'b',88006,101,600); 
insert into interval_sales values(908007,107,to_date('2012-11-14','yyyy-mm-dd'),'b',88007,100,520);  
insert into interval_sales values(908009,109,to_date('2015-12-10','yyyy-mm-dd'),'b',88009,101,600); 
insert into interval_sales values(908010,110,to_date('2017-11-14','yyyy-mm-dd'),'b',88010,100,520); 
insert into interval_sales values(908012,112,to_date('2018-10-10','yyyy-mm-dd'),'b',88012,100,520); 

we can verify interval partition's detail informations ,as follow:
SQL> SELECT partition_name,tablespace_name,interval,high_value from user_Tab_partitions where table_name='INTERVAL_SALES';

PARTITION_NAME                 TABLESPACE_NAME                INT HIGH_VALUE
------------------------------ ------------------------------ --- --------------------------------------------------------------------------------
P0                             USERS                          NO  TO_DATE(' 2008-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
P1                             USERS                          NO  TO_DATE(' 2009-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
P2                             USERS                          NO  TO_DATE(' 2009-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
P3                             USERS                          NO  TO_DATE(' 2010-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SYS_P61                        SALES_TBS3                     YES TO_DATE(' 2013-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SYS_P62                        SALES_TBS2                     YES TO_DATE(' 2016-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SYS_P63                        SALES_TBS4                     YES TO_DATE(' 2018-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SYS_P81                        SALES_TBS1                     YES TO_DATE(' 2019-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA

for example 2:

 

CREATE TABLE interval_sales1
    ( prod_id        NUMBER(6)
    , cust_id        NUMBER
    , time_id        DATE
    , channel_id     CHAR(1)
    , promo_id       NUMBER(6)
    , quantity_sold  NUMBER(3)
    , amount_sold    NUMBER(10,2)
    )
  PARTITION BY RANGE (time_id)
  INTERVAL(NUMTOYMINTERVAL(1, 'YEAR'))store in (SALES_TBS1,SALES_TBS2,SALES_TBS3,SALES_TBS4)
    ( PARTITION p4 VALUES LESS THAN (TO_DATE('1-6-2008', 'DD-MM-YYYY')),
      PARTITION p5 VALUES LESS THAN (TO_DATE('1-12-2009', 'DD-MM-YYYY')),
      PARTITION p6 VALUES LESS THAN (TO_DATE('1-6-2010', 'DD-MM-YYYY')));

QL> sELECT partition_name,tablespace_name,interval,high_value from user_Tab_partitions where table_name='INTERVAL_SALES1';
PARTITION_NAME                 TABLESPACE_NAME                INT HIGH_VALUE
------------------------------ ------------------------------ --- --------------------------------------------------------------------------------
P4                             SYSTEM                         NO  TO_DATE(' 2008-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
P5                             SYSTEM                         NO  TO_DATE(' 2009-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
P6                             SYSTEM                         NO  TO_DATE(' 2010-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SYS_P88                        SALES_TBS2                     YES TO_DATE(' 2013-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SYS_P89                        SALES_TBS1                     YES TO_DATE(' 2016-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SYS_P90                        SALES_TBS3                     YES TO_DATE(' 2018-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SYS_P91                        SALES_TBS4                     YES TO_DATE(' 2019-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA

 

The INTERVAL clause of the CREATE TABLE statement establishes interval partitioning for the table.
You must specify at least one range partition using the PARTITION clause.
The range partitioning key value determines the high value of the range partitions,
which is called the transition point, and the database automatically creates interval partitions for data beyond that transition point.
The lower boundary of every interval partition is the non-inclusive upper boundary of the previous range or interval partition.

ORACLE 11g Incremental checkpoint

oracle中有很多检查点,例如Thread checkpoints,Tablespace and data file checkpoints,Incremental checkpoints等等并且这些checkpoint的更改可以直接反映到相关的视图
如v$database,v$datafile_header等。但是incremental checkpoint没有相关视图去校验到底checkpoint的改变值。或许通过
参数log_checkpoints_to_alert设置为true,在alert日志里会有如下信息:
Fri Jan 08 16:39:40 2016
Incremental checkpoint up to RBA [0x45.f14c.0], current log tail at RBA [0x45.f15d.0]
Incremental checkpoint up to RBA [0x45.f15e.0], current log tail at RBA [0x45.f15e.0]

incremental checkpoint:
oracle会将所有dirty块串成一个checkpoint queue,DBWR在checkpoint queue达到一定长度后会刷新部分dirty块到磁盘上(checkpoint queue长度触发写参数:log_checkpoint_interval\log_checkpoint_timeout\fast_start_mttr_target);
或者CKPT会根据参数及数据记录的IO情况,计算出来一个目标rba,DBWR会沿着检查点队列,将所有Target rba之前的脏块刷新到磁盘,当CKPT告诉DBWR目标rba后,CKPT任务结束;
CKPT进程也会定期检查checkpoint queue,CKPT每3秒一次将检查点位置记录进控制文件,当然同时被记录进控制文件还有心跳、RBA、SCN等其他信息;
incremental checkpoint不写数据文件及头信息,它只是刷部分dirty块,无法做到ctl文件,datafile header,block header里checkpoint scn一致,只是为了缩短恢复的时间。

incremental checkpoint无法像full checkpoint那样可以通过验证v$datafile_header.checkpoint_change#来说明系统做了full checkpoint,但我们可以通过如下方法
我们可以结合alert日志里的信息和x$kcccp视图来比对RBA,
与alert日志里
Tue Jan 12 14:18:09 2016
Incremental checkpoint up to RBA [0x5c.2277.0], current log tail at RBA [0x5c.2277.0]

SQL> select to_char(sysdate,’yyyy-mm-dd hh24:mi:ss’),cpdrt,to_char(cpodr_seq,’XX’)||’.’||to_char(cpodr_bno,’XXXX’)||’.’||to_char(cpodr_bof,’XX’)
2 from x$kcccp where cpodr_seq<>0 ;
TO_CHAR(SYSDATE,’YY CPDRT TO_CHAR(CPODR
——————- ———- ————-
2016-01-12 14:18:09 0 5C. 2277. 0

立刻查v$datafile_header.checkpoint_change#,v$database.checkpoint_change#,v$datafile_header.checkpoint_change#信息会发现SCN没有发生变化的,
此时我们看到ORACLE在默默的为我们做incremental checkpoint
alter system switch logfile动作是full checkpoint而非我们这里提到的Incremental checkpoint

SQL> select checkpoint_change# from v$datafile_header;====>>>>>记录数据文件头checkpoint scn的信息如下
CHECKPOINT_CHANGE#
——————
4121182
4121182
4121182
4121182
4121182
4121182
4121182
4121182
4121182
9 rows selected.

SQL> alter system flush buffer_cache;
System altered.

SQL> /
System altered.

SQL> select checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
——————
4121182====>>>>经过两次的flush buffer_cache动作,发现checkpoint scn并没有发生变化,说明alter system flush buffer_cache;不会触发数据文件头checkpoint的更新
4121182
4121182
4121182
4121182
4121182
4121182
4121182
4121182
9 rows selected.

SQL> alter system switch logfile;====>>>>>
System altered.

SQL> select checkpoint_change# from v$datafile_header;

CHECKPOINT_CHANGE#
——————
4121182===========>>>经过日志切换后也没有触发数据文件头checkpoint的更新
4121182
4121182
4121182
4121182
4121182
4121182
4121182
4121182
9 rows selected.

SQL> alter system flush buffer_cache;====>>>>flush buffer cache
System altered.

SQL> select checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
——————
4121322
4121322====>>>>>触发数据文件头checkpoint的更新
4121322
4121322
4121322
4121322
4121322
4121322
4121322
9 rows selected.

alert日志记录
Tue Jan 12 14:26:18 2016
ALTER SYSTEM: Flushing buffer cache
ALTER SYSTEM: Flushing buffer cache
Tue Jan 12 14:26:33 2016
Beginning log switch checkpoint up to RBA [0x63.2.10], SCN: 4121322
Thread 1 advanced to log sequence 99 (LGWR switch)
Current log# 3 seq# 99 mem# 0: /oradata/TRSEN/onlinelog/o1_mf_3_c6wp4qm5_.log
Tue Jan 12 14:26:33 2016
Archived Log entry 147 added for thread 1 sequence 98 ID 0xde8d5ddb dest 1:
Tue Jan 12 14:26:47 2016
ALTER SYSTEM: Flushing buffer cache
Tue Jan 12 14:26:48 2016
Completed checkpoint up to RBA [0x63.2.10], SCN: 4121322=====>>>记录了切换日志的更新数据文件头信息的更新

如果一轮日志切换结束后,再次“重新开始”时,会发现日志切花会立刻出发checkpoint动作,测试环境redo log groups为3组
SQL> set timing on;
SQL> select checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
——————
4121734
4121734
4121734
4121734
4121734
4121734
4121734
4121734
4121734
9 rows selected.
Elapsed: 00:00:00.00

SQL> alter system switch logfile;===>>第1次日志切换
System altered.
Elapsed: 00:00:00.01

SQL> select checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
——————
4121734
4121734
4121734
4121734
4121734
4121734
4121734
4121734
4121734
9 rows selected.
Elapsed: 00:00:00.00

SQL> alter system switch logfile;===>>第2次日志切换
System altered.
Elapsed: 00:00:00.01

SQL> select checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
——————
4121734
4121734
4121734
4121734
4121734
4121734
4121734
4121734
4121734
9 rows selected.
Elapsed: 00:00:00.00

SQL> alter system switch logfile;===>>第3次日志切换
System altered.
Elapsed: 00:00:00.21====>>>>从耗时来看,也有所变化

SQL> select checkpoint_change# from v$datafile_header;
CHECKPOINT_CHANGE#
——————
4121758
4121758
4121758
4121758
4121758
4121758
4121758
4121758
4121758
9 rows selected.
Elapsed: 00:00:00.00