Thursday, August 25, 2011

Table Reorganization (reclaim space)

This shows that "alter table x move" reclaims the space.
As seen here in: http://www.dba-oracle.com/t_alter_table_move_shrink_space.htm
It says it doesn't change the table size.


SQL> begin
2 for i in 1..1000000 loop
3 insert into audadm.t1 values (i);
4 end loop;
5 commit;
6 end;
7 /

PL/SQL procedure successfully completed.

SQL> analyze table audadm.t1 compute statistics;

Table analyzed.

SQL> select blocks,empty_blocks,num_rows from dba_tables where table_name='T1';

BLOCKS EMPTY_BLOCKS NUM_ROWS
---------- ------------ ----------
2276 1819 1500000

SQL> select blocks, extents from dba_segments where segment_name='T1';

BLOCKS EXTENTS
---------- ----------
4096 2

SQL> select sum(bytes) from dba_segments where segment_name = 'T1';

SUM(BYTES)
----------
33554432

SQL> delete from audadm.t1 where mod(x,2)=0;

500000 rows deleted.

SQL> commit;

Commit complete.

SQL> analyze table audadm.t1 compute statistics;

Table analyzed.

SQL> select blocks,empty_blocks,num_rows from dba_tables where table_name='T1';

BLOCKS EMPTY_BLOCKS NUM_ROWS
---------- ------------ ----------
2276 1819 1000000

SQL> select blocks, extents from dba_segments where segment_name='T1';

BLOCKS EXTENTS
---------- ----------
4096 2

SQL> select sum(bytes) from dba_segments where segment_name = 'T1';

SUM(BYTES)
----------
33554432

SQL> alter table audadm.t1 move;

Table altered.

SQL> analyze table audadm.t1 compute statistics;

Table analyzed.

SQL> select blocks,empty_blocks,num_rows from dba_tables where table_name='T1';

BLOCKS EMPTY_BLOCKS NUM_ROWS
---------- ------------ ----------
1520 527 1000000

SQL> select blocks, extents from dba_segments where segment_name='T1';

BLOCKS EXTENTS
---------- ----------
2048 1

SQL> select sum(bytes) from dba_segments where segment_name = 'T1';

SUM(BYTES)
----------
16777216

SQL>

Table Reorganization

SQL> select banner from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

SQL> create table t
2 as
3 select * from all_objects;

Table created.

SQL> insert into t select * from t;

75458 rows created.

SQL> insert into t select * from t;

150916 rows created.

SQL> commit;

Commit complete.

SQL> create index idx_t on t(OBJECT_ID);

Index created.

Index is valid:

SQL> select index_name,index_type,status
2 from user_indexes
3 where index_name='IDX_T';

INDEX_NAME INDEX_TYPE STATUS
------------------------------ --------------------------- --------
IDX_T NORMAL VALID

SQL> set linesize 200;
SQL> set autotrace traceonly explain;
SQL> select * from t where object_id=9;

Execution Plan
----------------------------------------------------------
Plan hash value: 1594971208

-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 4 | 632 | 7 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 4 | 632 | 7 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IDX_T | 4 | | 3 (0)| 00:00:01 |
-------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

2 - access("OBJECT_ID"=9)

Note
-----
- dynamic sampling used for this statement (level=2)

SQL> set autotrace off;

SQL> analyze table t compute statistics;

Table analyzed.

Check the HWM:

SQL> select blocks, extents from dba_segments where segment_name='T';

BLOCKS EXTENTS
---------- ----------
4352 49

SQL> select blocks,empty_blocks,num_rows from dba_tables where table_name='T';

BLOCKS EMPTY_BLOCKS NUM_ROWS
---------- ------------ ----------
4292 59 301832


SQL> delete from t where mod(OBJECT_ID,2)=0;

150920 rows deleted.

Issue the move command to lower high water mark:

SQL> alter table t move;

Table altered.

Index will become unusable, need to rebuild:

SQL>
SQL> select index_name,index_type,status
2 from user_indexes
3 where index_name='IDX_T';

INDEX_NAME INDEX_TYPE STATUS
------------------------------ --------------------------- --------
IDX_T NORMAL UNUSABLE

SQL> set autotrace traceonly explain;
SQL> select * from t where object_id=9;

Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873

--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 4 | 400 | 1167 (1)| 00:00:15 |
|* 1 | TABLE ACCESS FULL| T | 4 | 400 | 1167 (1)| 00:00:15 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

1 - filter("OBJECT_ID"=9)

SQL> set autotrace off;

High water mark gets lowered:

SQL> select blocks, extents from dba_segments where segment_name='T';

BLOCKS EXTENTS
---------- ----------
2176 32

SQL> select blocks,empty_blocks,num_rows from dba_tables where table_name='T';

BLOCKS EMPTY_BLOCKS NUM_ROWS
---------- ------------ ----------
4292 59 301832

Rebuild index:

SQL> alter index idx_t rebuild;

Index altered.

SQL> set autotrace traceonly explain;
SQL> select * from t where object_id=9;

Execution Plan
----------------------------------------------------------
Plan hash value: 1594971208

-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 4 | 400 | 3 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 4 | 400 | 3 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IDX_T | 4 | | 1 (0)| 00:00:01 |
-------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

2 - access("OBJECT_ID"=9)

SQL> set autotrace off;





Aside, when trying to shrink table, it complains that tablespace segment type is wrong.
Looks like it will work if segment type is AUTO.


SQL> alter table t enable row movement ;

Table altered.

SQL> alter table t shrink space cascade;
alter table t shrink space cascade
*
ERROR at line 1:
ORA-10635: Invalid segment or tablespace type


SQL> alter table t disable row movement ;

Table altered.

SQL>

Monday, August 22, 2011

Installing Oracle 9.2.0.4 on linux 64-bit problems

While installing the oracle binaries for linux 64-bit, 9.2.0.4, the installer hangs at about 17%.

It hangs on the file: naeet.o

I followed another source from user CharlesC.

---
1. Make sure Java libraries are up to date..
2. Do not start installation from the 9204 base installation- Oracle Universal Installer has problem
2.1 Install first the OUI "only" from the 9206 patchset (p3948480_9206_Linux-x86-64.zip)
using the Oracle_Home youve just decided
2.2 In ../Disk1/install/oraparam.ini edit the Linux value under [Certified Versions]
Linux=redhat-2.1AS,redhat-2.1,redhat-3,redhat-4,redhat-5,UnitedLinux-1.0,SuSE-9,SuSE-
* value must include redhat-5 inorder to suppress the error message for OS version incompat.
2.3 After completion of OUI install, edit again ../product/9204/oui/oraparam.ini as instructed
in step 2.2
2.4 Now install the 9204 base using the OUI from 9206. Run ../product/9204/oui/runInstaller BUT
this time, select the "products.jar" from 9204 base installation set.
(ex: /u01/app/oracle/Disk1/stage/products.jar)
2.5 From here u should be able to install the SOFTWARE ONLY option. DO NOT create a database yet.
---

Another problem I saw relates to launching x-windows.

Initializing Java Virtual Machine from /tmp/OraInstall2011-08-16_02-41-34PM/jre/bin/java. Please wait...
Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/OraInstall2011-08-16_02-41-34PM/jre/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory

Solve it be installing following packages:

libX11.i686
libXext.i686
libXt.i686
xorg-x11-deprecated-libs-6.8.1-12.i386.rpm
libXtst.i686

Sunday, June 19, 2011

Starting database resource

[grid@rac2 ~]$ crsctl status resource

NAME=ora.hongkong.db
TYPE=ora.database.type
TARGET=ONLINE , ONLINE
STATE=ONLINE on rac1, OFFLINE

[grid@rac2 ~]$ crsctl start resource -all

CRS-2672: Attempting to start 'ora.hongkong.db' on 'rac2'
ORA-01012: not logged on
CRS-2676: Start of 'ora.hongkong.db' on 'rac2' succeeded

[grid@rac2 ~]$ crsctl status resource ora.hongkong.db

NAME=ora.hongkong.db
TYPE=ora.database.type
TARGET=ONLINE , ONLINE
STATE=ONLINE on rac1, ONLINE on rac2

Monday, June 13, 2011

rac2 troubles

I had MANY problems with rac2 and spent hours installing, reinstalling grid. Here are some of the issues I encountered.

After installing the OS, and configuring the storage and asm, make sure you can see the disks after a clean reboot on all nodes. Especially on your rac2.

[root@rac2 crs]# oracleasm listdisks
CRSVOL
DATAVOL
FRAVOL

When grid has been installed, after a reboot, make sure you can see the asm disks (above). And also make sure the ocrcheck is valid.

[root@rac2 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2252
Available space (kbytes) : 259868
ID : 2022892366
Device/File Name : +CRSDG
Device/File integrity check succeeded

Device/File not configured

Device/File not configured

Device/File not configured

Device/File not configured

Cluster registry integrity check succeeded

Logical corruption check succeeded

[root@rac2 bin]#



Other issues are as follows.

symptom:
while running root.sh during installation, we get
/u01/app/11.2.0/grid/lib/libclntsh.so.11.1: cannot restore segment prot after reloc: Permission denied

fix:
deconfig, and run root.sh again
su - root (do this even if you are already root)
/u01/app/11.2.0/grid/crs/install/rootcrs.pl -verbose -deconfig -force
chcon -t textrel_shlib_t /u01/app/11.2.0/grid/lib/libclntsh.so.11.1
/u01/app/11.2.0/grid/root.sh


symptom:
after a reboot of rac2,
[root@rac2 alert]# cat /u01/app/grid/diag/asm/+asm/+ASM2/trace/+ASM2_ora_4644.trc

...
----- Error Stack Dump -----
ORA-27154: post/wait create failed
ORA-27300: OS system dependent operation:semget failed with status: 28
ORA-27301: OS failure message: No space left on device
ORA-27302: failure occurred at: sskgpsemsper

fix:
vi /etc/sysctl.conf
modify: kernel.sem = 250 100 -> kernel.sem = 250 32000 100
sysctl -p
reboot

stopping CRS

rac1

[root@rac1 bin]# ./crsctl stop crs
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'rac1'
CRS-2673: Attempting to stop 'ora.crsd' on 'rac1'
CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on 'rac1'
CRS-2673: Attempting to stop 'ora.rac1.vip' on 'rac1'
CRS-2673: Attempting to stop 'ora.LISTENER_SCAN1.lsnr' on 'rac1'
CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'rac1'
CRS-2673: Attempting to stop 'ora.CRSDG.dg' on 'rac1'
CRS-2677: Stop of 'ora.rac1.vip' on 'rac1' succeeded
CRS-2677: Stop of 'ora.LISTENER_SCAN1.lsnr' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.scan1.vip' on 'rac1'
CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.rac2.vip' on 'rac1'
CRS-2677: Stop of 'ora.scan1.vip' on 'rac1' succeeded
CRS-2677: Stop of 'ora.rac2.vip' on 'rac1' succeeded
CRS-2677: Stop of 'ora.CRSDG.dg' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'rac1'
CRS-2677: Stop of 'ora.asm' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.ons' on 'rac1'
CRS-2673: Attempting to stop 'ora.eons' on 'rac1'
CRS-2677: Stop of 'ora.ons' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.net1.network' on 'rac1'
CRS-2677: Stop of 'ora.net1.network' on 'rac1' succeeded
CRS-2677: Stop of 'ora.eons' on 'rac1' succeeded
CRS-2792: Shutdown of Cluster Ready Services-managed resources on 'rac1' has completed
CRS-2677: Stop of 'ora.crsd' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.mdnsd' on 'rac1'
CRS-2673: Attempting to stop 'ora.gpnpd' on 'rac1'
CRS-2673: Attempting to stop 'ora.cssdmonitor' on 'rac1'
CRS-2673: Attempting to stop 'ora.ctssd' on 'rac1'
CRS-2673: Attempting to stop 'ora.evmd' on 'rac1'
CRS-2673: Attempting to stop 'ora.asm' on 'rac1'
CRS-2677: Stop of 'ora.cssdmonitor' on 'rac1' succeeded
CRS-2677: Stop of 'ora.gpnpd' on 'rac1' succeeded
CRS-2677: Stop of 'ora.mdnsd' on 'rac1' succeeded
CRS-2677: Stop of 'ora.evmd' on 'rac1' succeeded
CRS-2677: Stop of 'ora.ctssd' on 'rac1' succeeded
CRS-2677: Stop of 'ora.asm' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'rac1'
CRS-2677: Stop of 'ora.cssd' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.diskmon' on 'rac1'
CRS-2673: Attempting to stop 'ora.gipcd' on 'rac1'
CRS-2677: Stop of 'ora.gipcd' on 'rac1' succeeded
CRS-2677: Stop of 'ora.diskmon' on 'rac1' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'rac1' has completed
CRS-4133: Oracle High Availability Services has been stopped.
[root@rac1 bin]#





rac2

[root@rac2 bin]# ./crsctl stop crs
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'rac2'
CRS-2673: Attempting to stop 'ora.crsd' on 'rac2'
CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on 'rac2'
CRS-2673: Attempting to stop 'ora.CRSDG.dg' on 'rac2'
CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'rac2'
CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'rac2' succeeded
CRS-2673: Attempting to stop 'ora.rac2.vip' on 'rac2'
CRS-2677: Stop of 'ora.rac2.vip' on 'rac2' succeeded
CRS-2672: Attempting to start 'ora.rac2.vip' on 'rac1'
CRS-2676: Start of 'ora.rac2.vip' on 'rac1' succeeded
CRS-2677: Stop of 'ora.CRSDG.dg' on 'rac2' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'rac2'
CRS-2677: Stop of 'ora.asm' on 'rac2' succeeded
CRS-2673: Attempting to stop 'ora.eons' on 'rac2'
CRS-2673: Attempting to stop 'ora.ons' on 'rac2'
CRS-2677: Stop of 'ora.ons' on 'rac2' succeeded
CRS-2673: Attempting to stop 'ora.net1.network' on 'rac2'
CRS-2677: Stop of 'ora.net1.network' on 'rac2' succeeded
CRS-2677: Stop of 'ora.eons' on 'rac2' succeeded
CRS-2792: Shutdown of Cluster Ready Services-managed resources on 'rac2' has completed
CRS-2677: Stop of 'ora.crsd' on 'rac2' succeeded
CRS-2673: Attempting to stop 'ora.gpnpd' on 'rac2'
CRS-2673: Attempting to stop 'ora.cssdmonitor' on 'rac2'
CRS-2673: Attempting to stop 'ora.ctssd' on 'rac2'
CRS-2673: Attempting to stop 'ora.evmd' on 'rac2'
CRS-2673: Attempting to stop 'ora.asm' on 'rac2'
CRS-2673: Attempting to stop 'ora.mdnsd' on 'rac2'
CRS-2677: Stop of 'ora.cssdmonitor' on 'rac2' succeeded
CRS-2677: Stop of 'ora.gpnpd' on 'rac2' succeeded
CRS-2677: Stop of 'ora.evmd' on 'rac2' succeeded
CRS-2677: Stop of 'ora.mdnsd' on 'rac2' succeeded
CRS-2677: Stop of 'ora.ctssd' on 'rac2' succeeded
CRS-2677: Stop of 'ora.asm' on 'rac2' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'rac2'
CRS-2677: Stop of 'ora.cssd' on 'rac2' succeeded
CRS-2673: Attempting to stop 'ora.diskmon' on 'rac2'
CRS-2673: Attempting to stop 'ora.gipcd' on 'rac2'
CRS-2677: Stop of 'ora.gipcd' on 'rac2' succeeded
CRS-2677: Stop of 'ora.diskmon' on 'rac2' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'rac2' has completed
CRS-4133: Oracle High Availability Services has been stopped.
[root@rac2 bin]#

Wednesday, June 8, 2011

Installing 2 node clusterware

root@rac1


[root@rac1 ~]# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
[root@rac1 ~]# /u01/app/11.2.0/grid/root.sh
Running Oracle 11g root.sh script...

The following environment variables are set as:
ORACLE_OWNER= grid
ORACLE_HOME= /u01/app/11.2.0/grid

Enter the full pathname of the local bin directory: [/usr/local/bin]:
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.sh script.
Now product-specific root actions will be performed.
2011-06-08 03:25:51: Parsing the host name
2011-06-08 03:25:51: Checking for super user privileges
2011-06-08 03:25:51: User has super user privileges
Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_p
Creating trace directory
LOCAL ADD MODE
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
root wallet
root wallet cert
root cert export
peer wallet
profile reader wallet
pa wallet
peer wallet keys
pa wallet keys
peer cert request
pa cert request
peer cert
pa cert
peer root cert TP
profile reader root cert TP
pa root cert TP
peer pa cert TP
pa peer cert TP
profile reader pa cert TP
profile reader peer cert TP
peer user cert
pa user cert
Adding daemon to inittab
CRS-4123: Oracle High Availability Services has been started.
ohasd is starting
FATAL: Module oracleoks not found.
FATAL: Module oracleadvm not found.
FATAL: Module oracleacfs not found.
acfsroot: ACFS-9121: Failed to detect /dev/asm/.asm_ctl_spec.

acfsroot: ACFS-9310: ADVM/ACFS installation failed.

acfsroot: ACFS-9311: not all components were detected after the installation.

CRS-2672: Attempting to start 'ora.gipcd' on 'rac1'
CRS-2672: Attempting to start 'ora.mdnsd' on 'rac1'
CRS-2676: Start of 'ora.gipcd' on 'rac1' succeeded
CRS-2676: Start of 'ora.mdnsd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.gpnpd' on 'rac1'
CRS-2676: Start of 'ora.gpnpd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.cssdmonitor' on 'rac1'
CRS-2676: Start of 'ora.cssdmonitor' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.cssd' on 'rac1'
CRS-2672: Attempting to start 'ora.diskmon' on 'rac1'
CRS-2676: Start of 'ora.diskmon' on 'rac1' succeeded
CRS-2676: Start of 'ora.cssd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.ctssd' on 'rac1'
CRS-2676: Start of 'ora.ctssd' on 'rac1' succeeded

ASM created and started successfully.

DiskGroup CRSDG created successfully.

clscfg: -install mode specified
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
CRS-2672: Attempting to start 'ora.crsd' on 'rac1'
CRS-2676: Start of 'ora.crsd' on 'rac1' succeeded
CRS-4256: Updating the profile
Successful addition of voting disk 7a60cf7206294fa4bf7e479c2d088ec8.
Successfully replaced voting disk group with +CRSDG.
CRS-4256: Updating the profile
CRS-4266: Voting file(s) successfully replaced
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE 7a60cf7206294fa4bf7e479c2d088ec8 (/dev/oracleasm/disks/CRSVOL) [CRSDG]
Located 1 voting disk(s).
CRS-2673: Attempting to stop 'ora.crsd' on 'rac1'
CRS-2677: Stop of 'ora.crsd' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'rac1'
CRS-2677: Stop of 'ora.asm' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.ctssd' on 'rac1'
CRS-2677: Stop of 'ora.ctssd' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.cssdmonitor' on 'rac1'
CRS-2677: Stop of 'ora.cssdmonitor' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'rac1'
CRS-2677: Stop of 'ora.cssd' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.gpnpd' on 'rac1'
CRS-2677: Stop of 'ora.gpnpd' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.gipcd' on 'rac1'
CRS-2677: Stop of 'ora.gipcd' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.mdnsd' on 'rac1'
CRS-2677: Stop of 'ora.mdnsd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.mdnsd' on 'rac1'
CRS-2676: Start of 'ora.mdnsd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.gipcd' on 'rac1'
CRS-2676: Start of 'ora.gipcd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.gpnpd' on 'rac1'
CRS-2676: Start of 'ora.gpnpd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.cssdmonitor' on 'rac1'
CRS-2676: Start of 'ora.cssdmonitor' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.cssd' on 'rac1'
CRS-2672: Attempting to start 'ora.diskmon' on 'rac1'
CRS-2676: Start of 'ora.diskmon' on 'rac1' succeeded
CRS-2676: Start of 'ora.cssd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.ctssd' on 'rac1'
CRS-2676: Start of 'ora.ctssd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.asm' on 'rac1'
CRS-2676: Start of 'ora.asm' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.crsd' on 'rac1'
CRS-2676: Start of 'ora.crsd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.evmd' on 'rac1'
CRS-2676: Start of 'ora.evmd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.asm' on 'rac1'
CRS-2676: Start of 'ora.asm' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.CRSDG.dg' on 'rac1'
CRS-2676: Start of 'ora.CRSDG.dg' on 'rac1' succeeded

rac1 2011/06/08 03:35:10 /u01/app/11.2.0/grid/cdata/rac1/backup_20110608_033510.olr
Preparing packages for installation...
cvuqdisk-1.0.7-1
Configure Oracle Grid Infrastructure for a Cluster ... succeeded
Updating inventory properties for clusterware
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB. Actual 3044 MB Passed
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /u01/app/oraInventory
'UpdateNodeList' was successful.
[root@rac1 ~]# ps -ef | grep smon
root 10829 16494 0 20:37 pts/1 00:00:00 grep smon
grid 26316 1 0 03:33 ? 00:00:02 asm_smon_+ASM1
You have new mail in /var/spool/mail/root
[root@rac1 ~]#



root@rac2


[root@rac2 ~]# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
You have new mail in /var/spool/mail/root
[root@rac2 ~]# /u01/app/11.2.0/grid/root.sh
Running Oracle 11g root.sh script...

The following environment variables are set as:
ORACLE_OWNER= grid
ORACLE_HOME= /u01/app/11.2.0/grid

Enter the full pathname of the local bin directory: [/usr/local/bin]:
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.sh script.
Now product-specific root actions will be performed.
2011-06-08 03:37:08: Parsing the host name
2011-06-08 03:37:08: Checking for super user privileges
2011-06-08 03:37:08: User has super user privileges
Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params
Creating trace directory
LOCAL ADD MODE
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Adding daemon to inittab
CRS-4123: Oracle High Availability Services has been started.
ohasd is starting
FATAL: Module oracleoks not found.
FATAL: Module oracleadvm not found.
FATAL: Module oracleacfs not found.
acfsroot: ACFS-9121: Failed to detect /dev/asm/.asm_ctl_spec.

acfsroot: ACFS-9310: ADVM/ACFS installation failed.

acfsroot: ACFS-9311: not all components were detected after the installation.

CRS-4402: The CSS daemon was started in exclusive mode but found an active CSS daemon on node rac1, number 1, and is terminating
An active cluster was found during exclusive startup, restarting to join the cluster
CRS-2672: Attempting to start 'ora.mdnsd' on 'rac2'
CRS-2676: Start of 'ora.mdnsd' on 'rac2' succeeded
CRS-2672: Attempting to start 'ora.gipcd' on 'rac2'
CRS-2676: Start of 'ora.gipcd' on 'rac2' succeeded
CRS-2672: Attempting to start 'ora.gpnpd' on 'rac2'
CRS-2676: Start of 'ora.gpnpd' on 'rac2' succeeded
CRS-2672: Attempting to start 'ora.cssdmonitor' on 'rac2'
CRS-2676: Start of 'ora.cssdmonitor' on 'rac2' succeeded
CRS-2672: Attempting to start 'ora.cssd' on 'rac2'
CRS-2672: Attempting to start 'ora.diskmon' on 'rac2'
CRS-2676: Start of 'ora.diskmon' on 'rac2' succeeded
CRS-2676: Start of 'ora.cssd' on 'rac2' succeeded
CRS-2672: Attempting to start 'ora.ctssd' on 'rac2'
CRS-2676: Start of 'ora.ctssd' on 'rac2' succeeded
CRS-2672: Attempting to start 'ora.asm' on 'rac2'
CRS-2676: Start of 'ora.asm' on 'rac2' succeeded
CRS-2672: Attempting to start 'ora.crsd' on 'rac2'
CRS-2676: Start of 'ora.crsd' on 'rac2' succeeded
CRS-2672: Attempting to start 'ora.evmd' on 'rac2'
CRS-2676: Start of 'ora.evmd' on 'rac2' succeeded

rac2 2011/06/08 03:42:59 /u01/app/11.2.0/grid/cdata/rac2/backup_20110608_034259.olr
Preparing packages for installation...
cvuqdisk-1.0.7-1
Configure Oracle Grid Infrastructure for a Cluster ... succeeded
Updating inventory properties for clusterware
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB. Actual 3133 MB Passed
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /u01/app/oraInventory
'UpdateNodeList' was successful.
[root@rac2 ~]# ps -ef | grep smon
root 12484 22717 1 20:37 pts/1 00:00:00 grep smon
grid 30532 1 0 03:42 ? 00:00:02 asm_smon_+ASM2
You have new mail in /var/spool/mail/root
[root@rac2 ~]#

Saturday, June 4, 2011

Creating ASM diskgroup

Rac1:

SQL> select name from v$asm_diskgroup;

NAME
------------------------------
CRSDG

SQL> select path from v$asm_disk;

PATH
--------------------------------------------------------------------------------
/dev/oracleasm/disks/FRAVOL
/dev/oracleasm/disks/DATAVOL
/dev/oracleasm/disks/CRSVOL

SQL> conn /as sysasm
Connected.
SQL> create diskgroup DATADG external REDUNDANCY disk '/dev/oracleasm/disks/DATAVOL';

Diskgroup created.

SQL> create diskgroup FRADG external REDUNDANCY disk '/dev/oracleasm/disks/FRAVOL';

Diskgroup created.

SQL>



Rac2:

SQL> select group_number,name,state,total_mb from v$asm_diskgroup;

GROUP_NUMBER NAME STATE TOTAL_MB
------------ ------------------------------ ----------- ----------
1 CRSDG MOUNTED 2205
0 FRADG DISMOUNTED 0
0 DATADG DISMOUNTED 0

SQL> alter diskgroup DATADG mount;

Diskgroup altered.

SQL> alter diskgroup FRADG mount;

Diskgroup altered.

SQL> select group_number,name,state,total_mb from v$asm_diskgroup;

GROUP_NUMBER NAME STATE TOTAL_MB
------------ ------------------------------ ----------- ----------
1 CRSDG MOUNTED 2205
3 FRADG MOUNTED 39839
2 DATADG MOUNTED 39839

SQL>



**Additionally

On one occasion, I notice the diskgroup was not available during database creation.
I checked the resources. FRADG was OFFLINE on rac2, even though I just created and mounted it.

NAME=ora.FRADG.dg
TYPE=ora.diskgroup.type
TARGET=ONLINE , OFFLINE
STATE=ONLINE on rac1, OFFLINE

Go back and remount it:

SQL> alter diskgroup FRADG dismount;

Diskgroup altered.

SQL> alter diskgroup FRADG mount;

Diskgroup altered.

And now, the resource shows ONLINE on rac2:

NAME=ora.FRADG.dg
TYPE=ora.diskgroup.type
TARGET=ONLINE , ONLINE
STATE=ONLINE on rac1, ONLINE on rac2

Tuesday, March 8, 2011

RMAN-04005, ORA-01017

rman catalog=rmanDB/rmanDB@rman target=sys/syspw@DB

Recovery Manager: Release 9.2.0.6.0 - 64bit Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04005: error from target database:
ORA-01017: invalid username/password; logon denied


the password in $ORACLE_HOME/dbs is wrong.
go and delete the file orapwDB
recreate it using correct password

bounce the database

and retry the rman command

Thursday, February 24, 2011

Restoring whole database after deleting a datafile

do a full backup

Starting backup at 24-FEB-11
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=17 RECID=19 STAMP=743104301
input archived log thread=1 sequence=21 RECID=20 STAMP=743155273
input archived log thread=1 sequence=22 RECID=21 STAMP=743911539
input archived log thread=1 sequence=23 RECID=22 STAMP=743913643
input archived log thread=1 sequence=24 RECID=23 STAMP=743929228
input archived log thread=1 sequence=25 RECID=24 STAMP=743965101
input archived log thread=1 sequence=26 RECID=25 STAMP=743965102
channel ORA_DISK_1: starting piece 1 at 24-FEB-11
channel ORA_DISK_1: finished piece 1 at 24-FEB-11
piece handle=/data/stage/toronto/backup/0cm5g0dg_1_1
tag=TAG20110224T165824 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/arch/toronto/1_17_742858742.dbf RECID=19 STAMP=743104301
archived log file name=/arch/toronto/1_21_742858742.dbf RECID=20 STAMP=743155273
archived log file name=/arch/toronto/1_22_742858742.dbf RECID=21 STAMP=743911539
archived log file name=/arch/toronto/1_23_742858742.dbf RECID=22 STAMP=743913643
archived log file name=/arch/toronto/1_24_742858742.dbf RECID=23 STAMP=743929228
archived log file name=/arch/toronto/1_25_742858742.dbf RECID=24 STAMP=743965101
archived log file name=/arch/toronto/1_26_742858742.dbf RECID=25 STAMP=743965102
Finished backup at 24-FEB-11

Starting backup at 24-FEB-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/toronto/toronto/system01.dbf
input datafile file number=00002 name=/data/toronto/toronto/sysaux01.dbf
input datafile file number=00003 name=/data/toronto/toronto/undotbs01.dbf
input datafile file number=00005 name=/data/toronto/toronto/toronto01.dbf
input datafile file number=00004 name=/data/toronto/toronto/users01.dbf
channel ORA_DISK_1: starting piece 1 at 24-FEB-11
channel ORA_DISK_1: finished piece 1 at 24-FEB-11
piece handle=/data/stage/toronto/backup/0dm5g0e0_1_1
tag=TAG20110224T165840 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:47
Finished backup at 24-FEB-11

Starting backup at 24-FEB-11
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=27 RECID=26 STAMP=743965167
channel ORA_DISK_1: starting piece 1 at 24-FEB-11
channel ORA_DISK_1: finished piece 1 at 24-FEB-11
piece handle=/data/stage/toronto/backup/0em5g0fh_1_1
tag=TAG20110224T165928 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/arch/toronto/1_27_742858742.dbf RECID=26 STAMP=743965167
Finished backup at 24-FEB-11

Starting Control File and SPFILE Autobackup at 24-FEB-11
piece handle=/u01/app/oracle/flash_recovery_area/TORONTO/autobackup/2011_02_24/o1_mf_s_743965170_6pfo63kg_.bkp
comment=NONE
Finished Control File and SPFILE Autobackup at 24-FEB-11

... exit RMAN

remove the datafile toronto01.dbf

shutdown and startup mount toronto

start RMAN again

restore the whole database

Starting restore at 24-FEB-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to
/data/toronto/toronto/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to
/data/toronto/toronto/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to
/data/toronto/toronto/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to
/data/toronto/toronto/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to
/data/toronto/toronto/toronto01.dbf
channel ORA_DISK_1: reading from backup piece
/data/stage/toronto/backup/0dm5g0e0_1_1
channel ORA_DISK_1: piece
handle=/data/stage/toronto/backup/0dm5g0e0_1_1 tag=TAG20110224T165840
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 24-FEB-11

... exit RMAN

shutdown and start toronto

check the datafile status, it should be offline

bring it online

verify you can select data from that datafile, in my case, it is table toronto

Thursday, February 17, 2011

Reverting new primary back to standby

The process is pretty much the same as if you are switching over from original primary database to physical standby.

Following our previous examples. We have H2 as the new primary.
We shall switch it back to the standby.

Check the contents of archive destination for boston (on H2)

/arch/boston
-rw-r----- 1 oracle oinstall 309248 Feb 8 10:16 1_19_741607100.dbf
-rw-r----- 1 oracle oinstall 5253120 Feb 8 10:16 1_18_741607100.dbf
-rw-r----- 1 oracle oinstall 2229248 Feb 8 11:20 1_20_741607100.dbf
-rw-r----- 1 oracle oinstall 9216 Feb 8 11:21 1_21_741607100.dbf
-rw-r----- 1 oracle oinstall 224256 Feb 8 11:22 1_17_741607100.dbf
-rw-r----- 1 oracle oinstall 471552 Feb 9 04:57 1_22_741607100.dbf
-rw-r----- 1 oracle oinstall 101376 Feb 9 04:57 1_23_741607100.dbf
-rw-r----- 1 oracle oinstall 8559616 Feb 9 06:15 1_24_741607100.dbf
-rw-r----- 1 oracle oinstall 116224 Feb 9 06:21 1_25_741607100.dbf
-rw-r----- 1 oracle oinstall 14848 Feb 9 06:21 1_26_741607100.dbf
-rw-r----- 1 oracle oinstall 12288 Feb 9 06:21 1_27_741607100.dbf
-rw-r----- 1 oracle oinstall 1024 Feb 9 06:26 1_28_741607100.dbf
-rw-r----- 1 oracle oinstall 41472 Feb 9 06:27 1_29_741607100.dbf
-rw-r----- 1 oracle oinstall 19968 Feb 9 06:27 1_30_741607100.dbf
-rw-r----- 1 oracle oinstall 209920 Feb 9 06:39 1_31_741607100.dbf
-rw-r----- 1 oracle oinstall 456704 Feb 9 06:55 1_32_741607100.dbf
-rw-r----- 1 oracle oinstall 1334272 Feb 9 07:15 1_33_741607100.dbf
-rw-r----- 1 oracle oinstall 50688 Feb 9 07:15 1_34_741607100.dbf
-rw-r----- 1 oracle oinstall 5035520 Feb 9 09:39 1_35_741607100.dbf
-rw-r----- 1 oracle oinstall 45088256 Feb 9 22:07 1_36_741607100.dbf
-rw-r----- 1 oracle oinstall 40347648 Feb 10 13:02 1_37_741607100.dbf
-rw-r----- 1 oracle oinstall 41274880 Feb 10 22:07 1_38_741607100.dbf
-rw-r----- 1 oracle oinstall 40055296 Feb 11 14:49 1_39_741607100.dbf
-rw-r----- 1 oracle oinstall 41124864 Feb 11 22:06 1_40_741607100.dbf
-rw-r----- 1 oracle oinstall 40373248 Feb 12 10:13 1_41_741607100.dbf
-rw-r----- 1 oracle oinstall 40055808 Feb 12 17:31 1_42_741607100.dbf
-rw-r----- 1 oracle oinstall 40054784 Feb 12 22:59 1_43_741607100.dbf
-rw-r----- 1 oracle oinstall 41642496 Feb 13 10:16 1_44_741607100.dbf
-rw-r----- 1 oracle oinstall 43699200 Feb 13 18:42 1_45_741607100.dbf
-rw-r----- 1 oracle oinstall 40054784 Feb 14 04:51 1_46_741607100.dbf
-rw-r----- 1 oracle oinstall 40991744 Feb 14 21:11 1_47_741607100.dbf
-rw-r----- 1 oracle oinstall 40881664 Feb 15 03:00 1_48_741607100.dbf

The status now should be

SWITCHOVER_STATUS
--------------------
TO STANDBY

Execute the switch over command. Then shutdown the database immediate and mount it.

ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;

Check the status again, it should be

SWITCHOVER_STATUS
--------------------
TO PRIMARY

DATABASE_ROLE DB_UNIQUE_NAME NAME
---------------- ------------------------------ ---------
PHYSICAL STANDBY boston CHICAGO

Go to the old standby database chicago now and execute switch over command.

ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

And open the database. Also, check the role.

DATABASE_ROLE DB_UNIQUE_NAME NAME
---------------- ------------------------------ ---------
PRIMARY chicago CHICAGO

On the new standby database, boston, turn on the recovery process. Then generate a new log file on primary.

/arch/chicago
-rw-r----- 1 oracle oinstall 4865536 Feb 7 05:12 1_5_741607100.dbf
-rw-r----- 1 oracle oinstall 32439808 Feb 7 06:03 1_6_741607100.dbf
-rw-r----- 1 oracle oinstall 48640 Feb 7 06:08 1_7_741607100.dbf
-rw-r----- 1 oracle oinstall 6873600 Feb 7 11:01 1_8_741607100.dbf
-rw-r----- 1 oracle oinstall 2055168 Feb 7 11:42 1_9_741607100.dbf
-rw-r----- 1 oracle oinstall 51200 Feb 7 11:42 1_10_741607100.dbf
-rw-r----- 1 oracle oinstall 40399872 Feb 7 22:03 1_11_741607100.dbf
-rw-r----- 1 oracle oinstall 22781440 Feb 8 04:08 1_12_741607100.dbf
-rw-r----- 1 oracle oinstall 269312 Feb 8 04:47 1_13_741607100.dbf
-rw-r----- 1 oracle oinstall 5327872 Feb 8 07:18 1_14_741607100.dbf
-rw-r----- 1 oracle oinstall 36864 Feb 8 07:19 1_15_741607100.dbf
-rw-r----- 1 oracle oinstall 69120 Feb 8 07:21 1_16_741607100.dbf
-rw-r----- 1 oracle oinstall 224256 Feb 8 07:36 1_17_741607100.dbf
-rw-r----- 1 oracle oinstall 5253120 Feb 8 10:02 1_18_741607100.dbf
-rw-r----- 1 oracle oinstall 309248 Feb 8 10:16 1_19_741607100.dbf
-rw-r----- 1 oracle oinstall 2229248 Feb 8 11:20 1_20_741607100.dbf
-rw-r----- 1 oracle oinstall 9216 Feb 8 11:21 1_21_741607100.dbf
-rw-r----- 1 oracle oinstall 471552 Feb 9 04:55 1_22_741607100.dbf
-rw-r----- 1 oracle oinstall 101376 Feb 9 04:57 1_23_741607100.dbf
-rw-r----- 1 oracle oinstall 8559616 Feb 9 06:15 1_24_741607100.dbf
-rw-r----- 1 oracle oinstall 116224 Feb 9 06:21 1_25_741607100.dbf
-rw-r----- 1 oracle oinstall 14848 Feb 9 06:21 1_26_741607100.dbf
-rw-r----- 1 oracle oinstall 12288 Feb 9 06:21 1_27_741607100.dbf
-rw-r----- 1 oracle oinstall 1334272 Feb 9 07:15 1_33_741607100.dbf
-rw-r----- 1 oracle oinstall 41472 Feb 9 07:15 1_29_741607100.dbf
-rw-r----- 1 oracle oinstall 19968 Feb 9 07:15 1_30_741607100.dbf
-rw-r----- 1 oracle oinstall 1024 Feb 9 07:15 1_28_741607100.dbf
-rw-r----- 1 oracle oinstall 456704 Feb 9 07:15 1_32_741607100.dbf
-rw-r----- 1 oracle oinstall 209920 Feb 9 07:15 1_31_741607100.dbf
-rw-r----- 1 oracle oinstall 50688 Feb 9 07:15 1_34_741607100.dbf
-rw-r----- 1 oracle oinstall 5035520 Feb 9 09:39 1_35_741607100.dbf
-rw-r----- 1 oracle oinstall 45088256 Feb 9 22:07 1_36_741607100.dbf
-rw-r----- 1 oracle oinstall 40347648 Feb 10 13:01 1_37_741607100.dbf
-rw-r----- 1 oracle oinstall 41274880 Feb 10 22:07 1_38_741607100.dbf
-rw-r----- 1 oracle oinstall 40055296 Feb 11 14:48 1_39_741607100.dbf
-rw-r----- 1 oracle oinstall 41124864 Feb 11 22:06 1_40_741607100.dbf
-rw-r----- 1 oracle oinstall 40373248 Feb 12 10:13 1_41_741607100.dbf
-rw-r----- 1 oracle oinstall 40055808 Feb 12 17:31 1_42_741607100.dbf
-rw-r----- 1 oracle oinstall 40054784 Feb 12 23:00 1_43_741607100.dbf
-rw-r----- 1 oracle oinstall 41642496 Feb 13 10:17 1_44_741607100.dbf
-rw-r----- 1 oracle oinstall 43699200 Feb 13 18:43 1_45_741607100.dbf
-rw-r----- 1 oracle oinstall 40054784 Feb 14 04:51 1_46_741607100.dbf
-rw-r----- 1 oracle oinstall 40991744 Feb 14 21:12 1_47_741607100.dbf
-rw-r----- 1 oracle oinstall 40881664 Feb 15 03:00 1_48_741607100.dbf
-rw-r----- 1 oracle oinstall 21595136 Feb 15 12:09 1_49_741607100.dbf
-rw-r----- 1 oracle oinstall 27136 Feb 15 12:10 1_50_741607100.dbf
-rw-r----- 1 oracle oinstall 14336 Feb 15 12:11 1_51_741607100.dbf
-rw-r----- 1 oracle oinstall 1024 Feb 15 12:17 1_52_741607100.dbf
-rw-r----- 1 oracle oinstall 2048 Feb 15 12:18 1_53_741607100.dbf
-rw-r----- 1 oracle oinstall 60928 Feb 15 12:23 1_54_741607100.dbf

Wait a short time, and go to standby database and check the logs.

/arch/boston
-rw-r----- 1 oracle oinstall 309248 Feb 8 10:16 1_19_741607100.dbf
-rw-r----- 1 oracle oinstall 5253120 Feb 8 10:16 1_18_741607100.dbf
-rw-r----- 1 oracle oinstall 2229248 Feb 8 11:20 1_20_741607100.dbf
-rw-r----- 1 oracle oinstall 9216 Feb 8 11:21 1_21_741607100.dbf
-rw-r----- 1 oracle oinstall 224256 Feb 8 11:22 1_17_741607100.dbf
-rw-r----- 1 oracle oinstall 471552 Feb 9 04:57 1_22_741607100.dbf
-rw-r----- 1 oracle oinstall 101376 Feb 9 04:57 1_23_741607100.dbf
-rw-r----- 1 oracle oinstall 8559616 Feb 9 06:15 1_24_741607100.dbf
-rw-r----- 1 oracle oinstall 116224 Feb 9 06:21 1_25_741607100.dbf
-rw-r----- 1 oracle oinstall 14848 Feb 9 06:21 1_26_741607100.dbf
-rw-r----- 1 oracle oinstall 12288 Feb 9 06:21 1_27_741607100.dbf
-rw-r----- 1 oracle oinstall 1024 Feb 9 06:26 1_28_741607100.dbf
-rw-r----- 1 oracle oinstall 41472 Feb 9 06:27 1_29_741607100.dbf
-rw-r----- 1 oracle oinstall 19968 Feb 9 06:27 1_30_741607100.dbf
-rw-r----- 1 oracle oinstall 209920 Feb 9 06:39 1_31_741607100.dbf
-rw-r----- 1 oracle oinstall 456704 Feb 9 06:55 1_32_741607100.dbf
-rw-r----- 1 oracle oinstall 1334272 Feb 9 07:15 1_33_741607100.dbf
-rw-r----- 1 oracle oinstall 50688 Feb 9 07:15 1_34_741607100.dbf
-rw-r----- 1 oracle oinstall 5035520 Feb 9 09:39 1_35_741607100.dbf
-rw-r----- 1 oracle oinstall 45088256 Feb 9 22:07 1_36_741607100.dbf
-rw-r----- 1 oracle oinstall 40347648 Feb 10 13:02 1_37_741607100.dbf
-rw-r----- 1 oracle oinstall 41274880 Feb 10 22:07 1_38_741607100.dbf
-rw-r----- 1 oracle oinstall 40055296 Feb 11 14:49 1_39_741607100.dbf
-rw-r----- 1 oracle oinstall 41124864 Feb 11 22:06 1_40_741607100.dbf
-rw-r----- 1 oracle oinstall 40373248 Feb 12 10:13 1_41_741607100.dbf
-rw-r----- 1 oracle oinstall 40055808 Feb 12 17:31 1_42_741607100.dbf
-rw-r----- 1 oracle oinstall 40054784 Feb 12 22:59 1_43_741607100.dbf
-rw-r----- 1 oracle oinstall 41642496 Feb 13 10:16 1_44_741607100.dbf
-rw-r----- 1 oracle oinstall 43699200 Feb 13 18:42 1_45_741607100.dbf
-rw-r----- 1 oracle oinstall 40054784 Feb 14 04:51 1_46_741607100.dbf
-rw-r----- 1 oracle oinstall 40991744 Feb 14 21:11 1_47_741607100.dbf
-rw-r----- 1 oracle oinstall 40881664 Feb 15 03:00 1_48_741607100.dbf
-rw-r----- 1 oracle oinstall 21595136 Feb 15 12:09 1_49_741607100.dbf
-rw-r----- 1 oracle oinstall 27136 Feb 15 12:10 1_50_741607100.dbf
-rw-r----- 1 oracle oinstall 14336 Feb 15 12:11 1_51_741607100.dbf
-rw-r----- 1 oracle oinstall 1024 Feb 15 12:20 1_52_741607100.dbf
-rw-r----- 1 oracle oinstall 2048 Feb 15 12:20 1_53_741607100.dbf
-rw-r----- 1 oracle oinstall 60928 Feb 15 12:23 1_54_741607100.dbf

SEQUENCE# APPLIED
---------- ---------
17 YES
18 YES
19 YES
20 YES
21 YES
22 YES
23 YES
24 YES
25 YES
26 YES
27 YES

SEQUENCE# APPLIED
---------- ---------
28 YES
28 YES
29 YES
29 YES
30 YES
30 YES
31 YES
31 YES
32 YES
32 YES
33 YES

SEQUENCE# APPLIED
---------- ---------
33 YES
34 YES
34 YES
35 YES
35 YES
36 YES
36 YES
37 YES
37 YES
38 YES
38 YES

SEQUENCE# APPLIED
---------- ---------
39 YES
39 YES
40 YES
40 YES
41 YES
41 YES
42 YES
42 YES
43 YES
43 YES
44 YES

SEQUENCE# APPLIED
---------- ---------
44 YES
45 YES
45 YES
46 YES
46 YES
47 YES
47 YES
48 YES
48 YES
49 YES
49 YES

SEQUENCE# APPLIED
---------- ---------
50 YES
50 NO
51 YES
51 NO
52 NO
53 NO
54 NO

Monday, February 14, 2011

Switching archive log destination

Generate a log file using default destination.

/arch/toronto
-rw-r----- 1 oracle oinstall 6656 Feb 14 17:40 1_16_742858742.dbf

Change the destination now, and generate another log file.

/arch/toronto_temp
-rw-r----- 1 oracle oinstall 10240 Feb 14 17:43 1_17_742858742.dbf

Switch the destination back to original, and generate another log file.

/arch/toronto
-rw-r----- 1 oracle oinstall 6656 Feb 14 17:40 1_16_742858742.dbf
-rw-r----- 1 oracle oinstall 2560 Feb 14 17:43 1_18_742858742.dbf

Run a backup of archive logs.

Starting backup at 14-FEB-11
current log archived
...
archived log file name=/arch/toronto/1_16_742858742.dbf RECID=14 STAMP=743103604
archived log file name=/arch/toronto_temp/1_17_742858742.dbf RECID=15 STAMP=743103792
archived log file name=/arch/toronto/1_18_742858742.dbf RECID=16 STAMP=743103834
archived log file name=/arch/toronto/1_19_742858742.dbf RECID=17 STAMP=743104161
archived log file name=/arch/toronto/1_20_742858742.dbf RECID=18 STAMP=743104162
Finished backup at 14-FEB-11

We will see both the original destination and temp destination archive logs are backed up and removed.

Now restore the log file sequence #17 to original location.

/arch/toronto
-rw-r----- 1 oracle oinstall 10240 Feb 14 17:51 1_17_742858742.dbf

We can view archive log details using rman.

List of Backup Sets
===================

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
51 119.51M DISK 00:00:05 12-FEB-11
BP Key: 54 Status: AVAILABLE Compressed: NO Tag: TAG20110212T201930
Piece Name: /data/stage/toronto/backup/01m4gnmj_1_1

List of Archived Logs in backup set 51
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 4 779391 11-FEB-11 800324 11-FEB-11
1 5 800324 11-FEB-11 823330 12-FEB-11
1 6 823330 12-FEB-11 841950 12-FEB-11

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
71 90.00K DISK 00:00:00 12-FEB-11
BP Key: 76 Status: AVAILABLE Compressed: NO Tag: TAG20110212T202027
Piece Name: /data/stage/toronto/backup/03m4gnoc_1_1

List of Archived Logs in backup set 71
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 7 841950 12-FEB-11 842048 12-FEB-11

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
137 265.18M DISK 00:00:41 14-FEB-11
BP Key: 140 Status: AVAILABLE Compressed: NO Tag: TAG20110214T163109
Piece Name: /data/stage/toronto/backup/05m4lj2f_1_1

List of Archived Logs in backup set 137
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 4 779391 11-FEB-11 800324 11-FEB-11
1 5 800324 11-FEB-11 823330 12-FEB-11
1 6 823330 12-FEB-11 841950 12-FEB-11
1 7 841950 12-FEB-11 842048 12-FEB-11
1 8 842048 12-FEB-11 847862 12-FEB-11
1 9 847862 12-FEB-11 869074 13-FEB-11
1 10 869074 13-FEB-11 891741 13-FEB-11
1 11 891741 13-FEB-11 916649 14-FEB-11
1 12 916649 14-FEB-11 916667 14-FEB-11

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
203 41.03M DISK 00:00:01 14-FEB-11
BP Key: 206 Status: AVAILABLE Compressed: NO Tag: TAG20110214T173236
Piece Name: /data/stage/toronto/backup/07m4lmlk_1_1

List of Archived Logs in backup set 203
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 5 800324 11-FEB-11 823330 12-FEB-11
1 13 916667 14-FEB-11 918073 14-FEB-11
1 14 918073 14-FEB-11 918159 14-FEB-11
1 15 918159 14-FEB-11 918179 14-FEB-11

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
260 35.00K DISK 00:00:00 14-FEB-11
BP Key: 263 Status: AVAILABLE Compressed: NO Tag: TAG20110214T174923
Piece Name: /data/stage/toronto/backup/09m4lnl3_1_1

List of Archived Logs in backup set 260
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 16 918179 14-FEB-11 918390 14-FEB-11
1 17 918390 14-FEB-11 918461 14-FEB-11
1 18 918461 14-FEB-11 918475 14-FEB-11
1 19 918475 14-FEB-11 918602 14-FEB-11
1 20 918602 14-FEB-11 918620 14-FEB-11

Running archive backup again.

Here, there is sequence #5 which had been already backed-up previously.  (Here)
We restored it back to this destination. A new log file also has been generated, file # 13.

-rw-r----- 1 oracle oinstall 41651200 Feb 14 16:47 1_5_742858742.dbf
-rw-r----- 1 oracle oinstall 1362432 Feb 14 17:29 1_13_742858742.dbf

We will run archive backup now and delete input to see what happens.

The result is, all of the archive logs are deleted from archive destination, including #5.

Backing up archive logs

Further our previous discussion (here) about setting up RMAN catalog, let's demo the removal of archive logs after backup.

Start up the rman session again.

Issue the rman command that backs up archives and also removes the inputs. While it's running, you have a moment to review the archive destination.

The archive destination is as follows

-rw-r----- 1 oracle oinstall 52023296 Feb 11 23:01 1_4_742858742.dbf
-rw-r----- 1 oracle oinstall 41651200 Feb 12 10:08 1_5_742858742.dbf
-rw-r----- 1 oracle oinstall 31639040 Feb 12 20:19 1_6_742858742.dbf
-rw-r----- 1 oracle oinstall 91136 Feb 12 20:20 1_7_742858742.dbf
-rw-r----- 1 oracle oinstall 41349632 Feb 12 22:32 1_8_742858742.dbf
-rw-r----- 1 oracle oinstall 41532416 Feb 13 10:07 1_9_742858742.dbf
-rw-r----- 1 oracle oinstall 44419584 Feb 13 22:21 1_10_742858742.dbf
-rw-r----- 1 oracle oinstall 25357312 Feb 14 16:31 1_11_742858742.dbf
-rw-r----- 1 oracle oinstall 1024 Feb 14 16:31 1_12_742858742.dbf

Just before the rman backup finishes, it will delete the backed up archives.

Check the backup location, and you will see the new file it just created

-rw-r----- 1 oracle oinstall 278062592 Feb 14 16:31 05m4lj2f_1_1

If we want to restore a particular archive log, we can do so.

For example, if we want log sequence #5, we can see it will bring it back:

-rw-r----- 1 oracle oinstall 41651200 Feb 14 16:47 1_5_742858742.dbf

Saturday, February 12, 2011

Configuring rman catalog

Create the tablespace and user rman first inside the rman catalog database.

1. create tablespace rman ...
2. create user rmantoronto ...
3. grant the role recovery_catalog_owner to this new user.

Connect to rman using this user now.
Create the catalog.

Register the catalog and configure parameters.
Connect to the target using the catalog.

connected to target database: TORONTO (DBID=3278972211)
connected to recovery catalog database

Register the database.

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

Also, do the following
1. set the retention
2. set the disk type
3. set auto backup control file
4. set format

Now do a full backup.

Starting backup at 12-FEB-11
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=4 RECID=1 STAMP=742863663
input archived log thread=1 sequence=5 RECID=2 STAMP=742903701
input archived log thread=1 sequence=6 RECID=3 STAMP=742940369
channel ORA_DISK_1: starting piece 1 at 12-FEB-11
channel ORA_DISK_1: finished piece 1 at 12-FEB-11
piece handle=/data/stage/toronto/backup/01m4gnmj_1_1 tag=TAG20110212T201930 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 12-FEB-11

Starting backup at 12-FEB-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/toronto/toronto/system01.dbf
input datafile file number=00002 name=/data/toronto/toronto/sysaux01.dbf
input datafile file number=00003 name=/data/toronto/toronto/undotbs01.dbf
input datafile file number=00004 name=/data/toronto/toronto/users01.dbf
channel ORA_DISK_1: starting piece 1 at 12-FEB-11
channel ORA_DISK_1: finished piece 1 at 12-FEB-11
piece handle=/data/stage/toronto/backup/02m4gnmr_1_1 tag=TAG20110212T201939 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:46
Finished backup at 12-FEB-11

Starting backup at 12-FEB-11
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=7 RECID=4 STAMP=742940426
channel ORA_DISK_1: starting piece 1 at 12-FEB-11
channel ORA_DISK_1: finished piece 1 at 12-FEB-11
piece handle=/data/stage/toronto/backup/03m4gnoc_1_1 tag=TAG20110212T202027 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 12-FEB-11

Starting Control File and SPFILE Autobackup at 12-FEB-11
piece handle=/u01/app/oracle/flash_recovery_area/TORONTO/autobackup/2011_02_12/o1_mf_s_742940430_6ogdgypg_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 12-FEB-11

RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 7 days
using channel ORA_DISK_1
no obsolete backups found

See the backed up files:

-rw-r----- 1 oracle oinstall 125314048 Feb 12 20:19 01m4gnmj_1_1
-rw-r----- 1 oracle oinstall 1001431040 Feb 12 20:20 02m4gnmr_1_1
-rw-r----- 1 oracle oinstall 92672 Feb 12 20:20 03m4gnoc_1_1

We can see the details of the backup:

List of Backup Sets
===================

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
51 119.51M DISK 00:00:05 12-FEB-11
BP Key: 54 Status: AVAILABLE Compressed: NO Tag: TAG20110212T201930
Piece Name: /data/stage/toronto/backup/01m4gnmj_1_1

List of Archived Logs in backup set 51
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 4 779391 11-FEB-11 800324 11-FEB-11
1 5 800324 11-FEB-11 823330 12-FEB-11
1 6 823330 12-FEB-11 841950 12-FEB-11

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
52 Full 955.03M DISK 00:00:43 12-FEB-11
BP Key: 55 Status: AVAILABLE Compressed: NO Tag: TAG20110212T201939
Piece Name: /data/stage/toronto/backup/02m4gnmr_1_1
List of Datafiles in backup set 52
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 841970 12-FEB-11 /data/toronto/toronto/system01.dbf
2 Full 841970 12-FEB-11 /data/toronto/toronto/sysaux01.dbf
3 Full 841970 12-FEB-11 /data/toronto/toronto/undotbs01.dbf
4 Full 841970 12-FEB-11 /data/toronto/toronto/users01.dbf

BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
71 90.00K DISK 00:00:00 12-FEB-11
BP Key: 76 Status: AVAILABLE Compressed: NO Tag: TAG20110212T202027
Piece Name: /data/stage/toronto/backup/03m4gnoc_1_1

List of Archived Logs in backup set 71
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 7 841950 12-FEB-11 842048 12-FEB-11

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
84 Full 9.36M DISK 00:00:00 12-FEB-11
BP Key: 86 Status: AVAILABLE Compressed: NO Tag: TAG20110212T202030
Piece Name: /u01/app/oracle/flash_recovery_area/TORONTO/autobackup/2011_02_12/o1_mf_s_742940430_6ogdgypg_.bkp
SPFILE Included: Modification time: 12-FEB-11
SPFILE db_unique_name: TORONTO
Control File Included: Ckp SCN: 842073 Ckp time: 12-FEB-11

Thursday, February 10, 2011

Switch over from primary to standby database

Assumptions before we begin this exercise.
1.  Primary and standby are running on two hosts, H1 and H2  (see previous post)

Check the status of the primary database.

SWITCHOVER_STATUS
--------------------
TO STANDBY

Issus the switch over command.

ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;

Then shutdown the primary database and start it up mount.

Check the status again

SWITCHOVER_STATUS
--------------------
TO PRIMARY

Confirm the database role of the new standby

DATABASE_ROLE    DB_UNIQUE_NAME                 NAME
---------------- ------------------------------ ---------
PHYSICAL STANDBY chicago                                      CHICAGO

On the new primary database, perform the following

ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

Then open the database.

Check the role of the new primary database now

DATABASE_ROLE    DB_UNIQUE_NAME                 NAME
---------------- ------------------------------ ---------
PRIMARY          boston                                            CHICAGO

Test out the log switching, goto the new standby and run a query on the archive logs

Start the standby recover process on the new standby

Issue a log switch from new primary

Check again the archive logs on the new standby

Creating a physical standby database

Some details about the set-up before we begin:

1. There are 2 servers running oracle binaries. (11gR2 in my case)
2. They can see each other on the network
3. Your primary database is already running on primary host
4. Primary database is in archive log mode

In this example, the primary host is called H1. And the standby host is called H2.
First thing to do is to set up the listeners on H1 and H2.

There are 2 databases, chicago on H1 and boston on H2. Test the connections.

Ping boston from H1

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = H2.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = boston)))

OK (10 msec)

Ping chicago from H2

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = H1.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = chicago)))

OK (70 msec)

Prepare the pfile from chicago and put it on the H2. Edit it when it is on H2.

Take note of all the paths that needs to be corrected and reflected from H2 now. Make sure those paths do exist before continuing. Connect to the database now. You will see it is in IDLE state. Create a spfile.

Now start boston with nomount.

We will backup chicago database.

backup device type disk format '/data/stage/%U' database plus archivelog;
backup device type disk format '/data/stage/%U' current controlfile for standby;

Send the files over to H2.
Once transmission is done, duplicate the database on H2.

duplicate target database for standby;

When that is complete, add the redo log files. Also, add standby redo logs.

Start the standby recover process on boston now:

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Check the archive logs now on boston.

Switch the log on chicago
Check again the archive logs on boston now.

Now, let's switch over to standby