Monday, October 10, 2011

Patchset Uitlity to check installed patchsets and Family Packs

Hello Everyone!!!

Here you have a good tool to know.

patchset.sh is quite a good tool to evaluate the currently installed Oracle Applications' patchsets and Family Packs.

Note 139684.1 provides in depth details about this utility.

Here is the simple example, when you need to use this tool.

1) You want to know what is the current AD level of your system.
2) whether your system is at ATG RUP4 or RUP5 or RUP6(yet to be released!!)

Note: Its advised to download the latest version of this tool from
ftp://ftp.oracle.com/support/outgoing/PATCHSET_COMPARE_TOOL/patchsets.sh

If the ftp link is not working, try manual ftp as follows:
NOTE: Put the full path in for the get.

ftp ftp.oracle.com
login as an anonymous user, and then:
get support/outgoing/PATCHSET_COMPARE_TOOL/patchsets.sh

and finally this script works perfectly for 10.7, 11.0.x, 11.5.x, and 12.0.x !!!

Hope this helps you better in many ways!!

Sunday, April 24, 2011

How to Drop Database in Oracle 10g?

In order to drop the database start the database in restrict mode and bring it in mount state as shown:
sqlplus / as sysdba
SQL> shutdown immediate;
oracle database closed
oracle database dismounted
oracle instance shutdown
SQL> startup restrict mount;
SQL> drop database;
Database dropped
SQL> exit
Thus u will find that all the files associated with the database will be deleted.

Wednesday, March 23, 2011

Configuring RMAN

RMAN can invoked from the command line on the database host machine like so:
C:\>rman target sys/sys_password
Recovery Manager: Release 9.2.0.1.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
Connected to target database: ORCL (DBID=1036216947)
RMAN> show all;

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'e:\backup\ctl_sp_bak_%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT 'e:\backup\%U.bak' MAXPIECESIZE 4G;
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT 'e:\backup\%U.bak' MAXPIECESIZE 4G;
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'C:\ORACLE\ORA92\DATABASE\SNCFORCL.ORA'; #
default
RMAN>
Retention Policy:
This instructs RMAN on the backups that are eligible for deletion.
For example: A retention policy with redundancy 2 would mean that two backups - the latest and the one prior to that - should be retained. All other backups are candidates for deletion.
Default Device Type:
This can be "disk" or "sbt" (system backup to tape). We will backup to disk and then have our OS backup utility copy the completed backup, and other supporting files, to tape.
Controlfile Autobackup:
This can be set to "on" or "off". When set to "on", RMAN takes a backup of the controlfile AND server parameter file each time a backup is performed. Note that "off" is the default.
Controlfile Autobackup Format:
This tells RMAN where the controlfile backup is to be stored. The "%F" in the file name instructs RMAN to append the database identifier and backup timestamp to the backup filename. The database identifier, or DBID, is a unique integer identifier for the database.
Parallelism:
This tells RMAN how many server processes you want dedicated to performing the backups.
Device Type Format:
This specifies the location and name of the backup files. We need to specify the
format for each channel. The "%U" ensures that Oracle appends a unique identifier to the backup file name. The MAXPIECESIZE attribute sets a maximum file size for each file in the backup set.
Any of the above parameters can be changed using the commands displayed by the "show all" command.
For example, one can turn off controlfile autobackups by issuing:
RMAN> configure controlfile autobackup off;
using target database controlfile instead of recovery catalog
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
new RMAN configuration parameters are successfully stored
RMAN>

Rman Cloning Oracle DB


You want to use RMAN to create a duplicate database on the same server by using RMAN backups.

My Source Database Name is MYTEST

Target (duplicate) Database name is MYDB

Step 1: Configure Listener.ora and tnsnames.ora files

tnsnames.ora file

MYTEST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = mytest)
)
)

MYDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = mydb)
)
)

listener.ora file

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = mytest)
(ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1)
(SID_NAME = mytest)
)
(SID_DESC =
(GLOBAL_DBNAME= mydb)
(ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1)
(SID_NAME = mydb)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
)

Step 2: create pfile for target database from source database

SQL> create pfile from spfile;

File created.

Step 3: modified parameter file for target database (duplicate) here log_file_name_convert and db_file_name_convert and control file location is important, further your choice.

*.audit_file_dest=’/home/oracle/oracle/product/10.2.0/db_1/admin/mydb/adump’
*.compatible=’10.2.0.1.0′
*.db_block_size=8192
*.db_domain=”
*.db_file_multiblock_read_count=16
*.db_name=’mydb’
*.control_files=’/home/oracle/oracle/product/10.2.0/oradata/mydb/control01.ctl’,'/home/oracle/oracle/product/10.2.0/oradata/mydb/control02.ctl’,'/home/oracle/oracle/product/10.2.0/oradata/mydb/control03.ctl’
*.db_file_name_convert=’/home/oracle/oracle/product/10.2.0/db_1/oradata/mytest’,'/home/oracle/oracle/product/10.2.0/oradata/mydb’
*.log_file_name_convert=’/home/oracle/oracle/product/10.2.0/db_1/oradata/mytest’,'/home/oracle/oracle/product/10.2.0/oradata/mydb’
*.db_recovery_file_dest=’/home/oracle/oracle/product/10.2.0/db_1/flash_recovery_area’
*.db_recovery_file_dest_size=2147483648
*.dispatchers=’(PROTOCOL=TCP) (SERVICE=mydbXDB)’
*.job_queue_processes=10
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile=’EXCLUSIVE’
*.sga_target=285212672
*.undo_management=’AUTO’
*.undo_tablespace=’UNDOTBS1′

Step 4: Create password file

[oracle@localhost ~]$orapwd file=orapwmydb password=oracle entries=5

Step 5: start your target database nomount stage

[oracle@localhost ~]$ export ORACLE_SID=mydb
[oracle@localhost ~]$ rlwrap sqlplus

SQL*Plus: Release 10.2.0.1.0 – Production on Tue May 25 18:22:09 2010

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Enter user-name: sys/oracle@mydb as sysdba

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – Production
With the Partitioning, OLAP and Data Mining options

SQL> startup nomount pfile=/home/oracle/oracle/product/10.2.0/db_1/dbs/initmydb.ora
ORACLE instance started.

Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 92276304 bytes
Database Buffers 188743680 bytes
Redo Buffers 2973696 bytes
SQL> exit

Step 6: From source database

SQL> alter system switch logfile;

System altered.

SQL>

Step 7: Backup database and archivelog Source database

[oracle@localhost root]$ rlwrap rman target sys/azar@mytest

Recovery Manager: Release 10.2.0.1.0 – Production on Tue May 25 19:56:10 2010

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: MYTEST (DBID=2419076664)

RMAN> backup database plus archivelog;

Starting backup at 25-MAY-10
current log archived

input datafile fno=00001 name=/home/oracle/oracle/product/10.2.0/db_1/oradata/mytest/system01.dbf
input datafile fno=00003 name=/home/oracle/oracle/product/10.2.0/db_1/oradata/mytest/sysaux01.dbf
input datafile fno=00002 name=/home/oracle/oracle/product/10.2.0/db_1/oradata/mytest/undotbs01.dbf
input datafile fno=00004 name=/home/oracle/oracle/product/10.2.0/db_1/oradata/mytest/users01.dbf
channel ORA_DISK_1: starting piece 1 at 25-MAY-10
channel ORA_DISK_1: finished piece 1 at 25-MAY-10

(skipped)

Starting Control File and SPFILE Autobackup at 25-MAY-10
piece handle=/home/oracle/oracle/product/10.2.0/db_1/flash_recovery_area/MYTEST/autobackup/2010_05_25/o1_mf_s_719956316_5zr01f85_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 25-MAY-10

Step 8: Connect auxiliary database

RMAN> connect auxiliary sys/oracle@mydb;

connected to auxiliary database: MYDB (not mounted)

Step 9: Create duplicate database.

RMAN> duplicate target database to mydb;

Starting Duplicate Db at 25-MAY-10
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=156 devtype=DISK

contents of Memory Script:
{
set until scn 470310;
set newname for datafile 1 to
“/home/oracle/oracle/product/10.2.0/oradata/mydb/system01.dbf”;
set newname for datafile 2 to
“/home/oracle/oracle/product/10.2.0/oradata/mydb/undotbs01.dbf”;
set newname for datafile 3 to
“/home/oracle/oracle/product/10.2.0/oradata/mydb/sysaux01.dbf”;
set newname for datafile 4 to
“/home/oracle/oracle/product/10.2.0/oradata/mydb/users01.dbf”;
restore
check readonly
clone database
;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 25-MAY-10
using channel ORA_AUX_DISK_1

skipping datafile 1; already restored to file /home/oracle/oracle/product/10.2.0/oradata/mydb/system01.dbf
skipping datafile 2; already restored to file /home/oracle/oracle/product/10.2.0/oradata/mydb/undotbs01.dbf
skipping datafile 3; already restored to file /home/oracle/oracle/product/10.2.0/oradata/mydb/sysaux01.dbf
skipping datafile 4; already restored to file /home/oracle/oracle/product/10.2.0/oradata/mydb/users01.dbf
restore not done; all files readonly, offline, or already restored
Finished restore at 25-MAY-10
sql statement: CREATE CONTROLFILE REUSE SET DATABASE “MYDB” RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( ‘/home/oracle/oracle/product/10.2.0/oradata/mydb/redo01.log’ ) SIZE 50 M REUSE,
GROUP 2 ( ‘/home/oracle/oracle/product/10.2.0/oradata/mydb/redo02.log’ ) SIZE 50 M REUSE,
GROUP 3 ( ‘/home/oracle/oracle/product/10.2.0/oradata/mydb/redo03.log’ ) SIZE 50 M REUSE
DATAFILE
‘/home/oracle/oracle/product/10.2.0/oradata/mydb/system01.dbf’
CHARACTER SET WE8ISO8859P1

contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script

released channel: ORA_AUX_DISK_1
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=719956582 filename=/home/oracle/oracle/product/10.2.0/oradata/mydb/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=719956582 filename=/home/oracle/oracle/product/10.2.0/oradata/mydb/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=719956582 filename=/home/oracle/oracle/product/10.2.0/oradata/mydb/users01.dbf

contents of Memory Script:
{
set until scn 470310;
recover
clone database
delete archivelog
;
}
executing Memory Script

executing command: SET until clause

Starting recover at 25-MAY-10
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=156 devtype=DISK

starting media recovery

archive log thread 1 sequence 9 is already on disk as file /home/oracle/oracle/product/10.2.0/db_1/flash_recovery_area/MYTEST/archivelog/2010_05_25/o1_mf_1_9_5zr01bl8_.arc
archive log filename=/home/oracle/oracle/product/10.2.0/db_1/flash_recovery_area/MYTEST/archivelog/2010_05_25/o1_mf_1_9_5zr01bl8_.arc thread=1 sequence=9
media recovery complete, elapsed time: 00:00:02
Finished recover at 25-MAY-10

contents of Memory Script:
{
shutdown clone;
startup clone nomount ;
}
executing Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 285212672 bytes

Fixed Size 1218992 bytes
Variable Size 92276304 bytes
Database Buffers 188743680 bytes
Redo Buffers 2973696 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE “MYDB” RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( ‘/home/oracle/oracle/product/10.2.0/oradata/mydb/redo01.log’ ) SIZE 50 M REUSE,
GROUP 2 ( ‘/home/oracle/oracle/product/10.2.0/oradata/mydb/redo02.log’ ) SIZE 50 M REUSE,
GROUP 3 ( ‘/home/oracle/oracle/product/10.2.0/oradata/mydb/redo03.log’ ) SIZE 50 M REUSE
DATAFILE
‘/home/oracle/oracle/product/10.2.0/oradata/mydb/system01.dbf’
CHARACTER SET WE8ISO8859P1

contents of Memory Script:
{
set newname for tempfile 1 to
“/home/oracle/oracle/product/10.2.0/oradata/mydb/temp01.dbf”;
switch clone tempfile all;
catalog clone datafilecopy “/home/oracle/oracle/product/10.2.0/oradata/mydb/undotbs01.dbf”;
catalog clone datafilecopy “/home/oracle/oracle/product/10.2.0/oradata/mydb/sysaux01.dbf”;
catalog clone datafilecopy “/home/oracle/oracle/product/10.2.0/oradata/mydb/users01.dbf”;
switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed temporary file 1 to /home/oracle/oracle/product/10.2.0/oradata/mydb/temp01.dbf in control file

cataloged datafile copy
datafile copy filename=/home/oracle/oracle/product/10.2.0/oradata/mydb/undotbs01.dbf recid=1 stamp=719956593

cataloged datafile copy
datafile copy filename=/home/oracle/oracle/product/10.2.0/oradata/mydb/sysaux01.dbf recid=2 stamp=719956593

cataloged datafile copy
datafile copy filename=/home/oracle/oracle/product/10.2.0/oradata/mydb/users01.dbf recid=3 stamp=719956593

datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=719956593 filename=/home/oracle/oracle/product/10.2.0/oradata/mydb/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=719956593 filename=/home/oracle/oracle/product/10.2.0/oradata/mydb/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=719956593 filename=/home/oracle/oracle/product/10.2.0/oradata/mydb/users01.dbf

contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished Duplicate Db at 25-MAY-10

RMAN>

Step 10: My duplicate database succesfully created.

Enter user-name: sys/oracle@mydb as sysdba

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – Production
With the Partitioning, OLAP and Data Mining options

SQL> select status from v$instance;

STATUS
————
OPEN

SQL> select name from V$database;

NAME
———
MYDB

SQL>

Friday, March 11, 2011

How to Flashback in oracle 10g

Oracle9i introduced the DBMS_FLASHBACK package to allow queries to reference older versions of the database. Oracle 10g has taken this technology a step further making it simpler to use and much more flexible.

Note: Internally Oracle uses SCNs to track changes so any flashback operation that uses a timestamp must be translated into the nearest SCN which can result in a 3 second error.
  • Flashback Query 
  • Flashback Version Query 
  • Flashback Transaction Query 
  • Flashback Table 
  • Flashback Drop (Recycle Bin) 
  • Flashback Database 
  • Flashback Query Functions
Flashback Query
Flashback Query allows the contents of a table to be queried with reference to a specific point in time, using the AS OF clause. Essentially it is the same as the DBMS_FLASHBACK functionality or Oracle9i, but in a more convenient form. For example:

CREATE TABLE flashback_query_test (
id NUMBER(10)
);


SELECT current_scn, TO_CHAR(SYSTIMESTAMP, 'YYYY-MM-DD HH24:MI:SS') FROM v$database;

CURRENT_SCN TO_CHAR(SYSTIMESTAM
----------- -------------------
722452 2009-03-29 13:34:12

INSERT INTO flashback_query_test (id) VALUES (1);
COMMIT;
SELECT COUNT(*) FROM flashback_query_test;
COUNT(*)
----------
1

SELECT COUNT(*) FROM flashback_query_test AS OF TIMESTAMP TO_TIMESTAMP('2009-03-29 13:34:12', 'YYYY-MM-DD HH24:MI:SS');

COUNT(*)
----------
0

SELECT COUNT(*) FROM flashback_query_test AS OF SCN 722452;
COUNT(*)
----------

Flashback Version Query
Flashback version query allows the versions of a specific row to be tracked during a specified time period using the VERSIONS BETWEEN clause:
CREATE TABLE flashback_version_query_test (
id NUMBER(10),
description VARCHAR2(50)
);

INSERT INTO flashback_version_query_test (id, description) VALUES (1, 'ONE');
COMMIT;

SELECT current_scn, TO_CHAR(SYSTIMESTAMP, 'YYYY-MM-DD HH24:MI:SS') FROM v$database;
CURRENT_SCN TO_CHAR(SYSTIMESTAM
----------- -------------------
725202 2009-03-29 14:59:08

UPDATE flashback_version_query_test SET description = 'TWO' WHERE id = 1;
COMMIT;

UPDATE flashback_version_query_test SET description = 'THREE' WHERE id = 1;
COMMIT;

SELECT current_scn, TO_CHAR(SYSTIMESTAMP, 'YYYY-MM-DD HH24:MI:SS') FROM v$database;
CURRENT_SCN TO_CHAR(SYSTIMESTAM
----------- -------------------
725219 2009-03-29 14:59:36
COLUMN versions_startscn FORMAT 99999999999999999
COLUMN versions_starttime FORMAT A24
COLUMN versions_endscn FORMAT 99999999999999999
COLUMN versions_endtime FORMAT A24
COLUMN versions_xid FORMAT A16
COLUMN versions_operation FORMAT A1
COLUMN description FORMAT A11
SET LINESIZE 200

SELECT versions_startscn, versions_starttime,
versions_endscn, versions_endtime,
versions_xid, versions_operation,
description
FROM flashback_version_query_test
VERSIONS BETWEEN TIMESTAMP TO_TIMESTAMP('2009-03-29 14:59:08', 'YYYY-MM-DD HH24:MI:SS')
AND TO_TIMESTAMP('2009-03-29 14:59:36', 'YYYY-MM-DD HH24:MI:SS')
WHERE id = 1;

VERSIONS_STARTSCN VERSIONS_STARTTIME VERSIONS_ENDSCN VERSIONS_ENDTIME VERSIONS_XID V DESCRIPTION
------------------ ------------------------ ------------------ ------------------------ ---------------- 

725212 29-MAR-09 02.59.16 PM 02001C0043030000 U THREE
725209 29-MAR-09 02.59.16 PM 725212 29-MAR-04 02.59.16 PM 0600030021000000 U TWO
725209 29-MAR-09 02.59.16 PM ONE

SELECT versions_startscn, versions_starttime,
versions_endscn, versions_endtime,
versions_xid, versions_operation,
description
FROM flashback_version_query_test
VERSIONS BETWEEN SCN 725202 AND 725219
WHERE id = 1;

VERSIONS_STARTSCN VERSIONS_STARTTIME VERSIONS_ENDSCN VERSIONS_ENDTIME VERSIONS_XID V DESCRIPTION
----------------- ------------------------ ------------------ ------------------------ ----------------
725212 29-MAR-09 02.59.16 PM 02001C0043030000 U THREE
725209 29-MAR-09 02.59.16 PM 725212 29-MAR-04 02.59.16 PM 0600030021000000 U TWO
725209 29-MAR-09 02.59.16 PM ONE

The available pseudocolumn meanings are:
VERSIONS_STARTSCN or VERSIONS_STARTTIME - Starting SCN and TIMESTAMP when row took on this value. The value of NULL is returned if the row was created before the lower bound SCN ot TIMESTAMP.

VERSIONS_ENDSCN or VERSIONS_ENDTIME - Ending SCN and TIMESTAMP when row last contained this value. The value of NULL is returned if the value of the row is still current at the upper bound SCN ot TIMESTAMP.

VERSIONS_XID - ID of the transaction that created the row in it's current state.

VERSIONS_OPERATION - Operation performed by the transaction ((I)nsert, (U)pdate or (D)elete

Flashback Transaction Query
Flashback transaction query can be used to get extra information about the transactions listed by flashback version queries. The VERSIONS_XID column values from a flashback version query can be used to query the FLASHBACK_TRANSACTION_QUERY view like:

SELECT xid, operation, start_scn,commit_scn, logon_user, undo_sql
FROM flashback_transaction_query
WHERE xid = HEXTORAW('0600030021000000');
XID OPERATION START_SCN COMMIT_SCN
---------------- -------------------------------- ---------- ----------
LOGON_USER
------------------------------
UNDO_SQL
---------------------------------------------------------------------------------------------------
0600030021000000 UPDATE 725208 725209
SCOTT

update "SCOTT"."FLASHBACK_VERSION_QUERY_TEST" set "DESCRIPTION" = 'ONE' where ROWID = 'AAAMP9AAEAAAA
AYAAA';
0600030021000000 BEGIN 725208 725209
SCOTT
XID OPERATION START_SCN COMMIT_SCN
---------------- -------------------------------- ---------- ----------
LOGON_USER
------------------------------
UNDO_SQL
----------------------------------------------------------------------------------------------------
2 rows selected.

Flashback Table
The FLASHBACK TABLE command allows point in time recovery of individual tables subject to the following requirements:
You must have either the FLASHBACK ANY TABLE system privilege or have FLASHBACK object privilege on the table.

You must have SELECT, INSERT, DELETE, and ALTER privileges on the table.
There must be enough information in the undo tablespace to complete the operation.
Row movement must be enabled on the table (ALTER TABLE tablename ENABLE ROW MOVEMENT;).

The following example creates a table, inserts some data and flashbacks to a point prior to the data insertion. Finally it flashbacks to the time after the data insertion:
CREATE TABLE flashback_table_test (
id NUMBER(10)
);

ALTER TABLE flashback_table_test ENABLE ROW MOVEMENT;
SELECT current_scn FROM v$database;

CURRENT_SCN
-----------
715315

INSERT INTO flashback_table_test (id) VALUES (1);
COMMIT;

SELECT current_scn FROM v$database;
CURRENT_SCN
----------
715340

FLASHBACK TABLE flashback_table_test TO SCN 715315;
SELECT COUNT(*) FROM flashback_table_test;
COUNT(*)
----------
0

FLASHBACK TABLE flashback_table_test TO SCN 715340;
SELECT COUNT(*) FROM flashback_table_test;
COUNT(*)
----------
1

Flashback of tables can also be performed using timestamps:
FLASHBACK TABLE flashback_table_test TO TIMESTAMP TO_TIMESTAMP('2004-03-03 10:00:00', 'YYYY-MM-DD HH:MI:SS


Flashback Drop (Recycle Bin)
In Oracle 10g the default action of a DROP TABLE command is to move the table to the recycle bin (or rename it), rather than actually dropping it. The PURGE option can be used to permanently drop a table.

The recycle bin is a logical collection of previously dropped objects, with access tied to the DROP privilege. The contents of the recycle bin can be shown using the SHOW RECYCLEBIN command and purged using the PURGE TABLE command. As a result, a previously dropped table can be recovered from the recycle bin:

CREATE TABLE flashback_drop_test (
id NUMBER(10)
);

INSERT INTO flashback_drop_test (id) VALUES (1);
COMMIT;
DROP TABLE flashback_drop_test;
SHOW RECYCLEBIN

ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
FLASHBACK_DROP_T BIN$TstgCMiwQA66fl5FFDTBgA==$0 TABLE 2004-03-29:11:09:07 EST

FLASHBACK TABLE flashback_drop_test TO BEFORE DROP;
SELECT * FROM flashback_drop_test;
ID
----------
1
Tables in the recycle bin can be queried like any other table:

DROP TABLE flashback_drop_test;
SHOW RECYCLEBIN

ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
FLASHBACK_DROP_T BIN$TDGqmJZKR8u+Hrc6PGD8kw==$0 TABLE 2004-03-29:11:18:39  EST
SELECT * FROM "BIN$TDGqmJZKR8u+Hrc6PGD8kw==$0";
ID
----------
1

If an object is dropped and recreated multiple times all dropped versions will be kept in the recycle bin, subject to space. Where multiple versions are present it's best to reference the tables via the RECYCLEBIN_NAME. For any references to the ORIGINAL_NAME it is assumed the most recent object is drop version in the referenced question. During the flashback operation the table can be renamed like:
FLASHBACK TABLE flashback_drop_test TO BEFORE DROP RENAME TO flashback_drop_test_old;
Several purge options exist:

PURGE TABLE tablename; -- Specific table.
PURGE INDEX indexname; -- Specific index.
PURGE TABLESPACE ts_name; -- All tables in a specific tablespace.
PURGE TABLESPACE ts_name USER username; -- All tables in a specific tablespace for a specific user.
PURGE RECYCLEBIN; -- The current users entire recycle bin.
PURGE DBA_RECYCLEBIN; -- The whole recycle bin.

Several restrictions apply relating to the recycle bin:
Only available for non-system, locally managed tablespaces.
There is no fixed size for the recycle bin. The time an object remains in the recycle bin can vary.
The objects in the recycle bin are restricted to query operations only (no DDL or DML).
Flashback query operations must reference the recycle bin name.

Tables and all dependent objects are placed into, recovered and purged from the recycle bin at the same time.
Tables with Fine Grained Access policies aer not protected by the recycle bin.
Partitioned index-organized tables are not protected by the recycle bin.
The recycle bin does not preserve referential integrity.

Flashback DatabaseThe FLASHBACK DATABASE command is a fast alternative to performing an incomplete recovery. In order to flashback the database you must have SYSDBA privilege and the flash recovery area must have been prepared in advance.
If the database is in NOARCHIVELOG it must be switched to ARCHIVELOG mode
CONN sys/password AS SYSDBA

ALTER SYSTEM SET log_archive_dest_1='location=d:\oracle\oradata\DB10G\archive\' SCOPE=SPFILE;
ALTER SYSTEM SET log_archive_format='ARC%S_%R.%T' SCOPE=SPFILE;
ALTER SYSTEM SET log_archive_start=TRUE SCOPE=SPFILE;
SHUTDOWN IMMEDIATE
STARTUP MOUNT
ARCHIVE LOG START
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;

Flashback must be enabled before any flashback operations are performed:
CONN sys/password AS SYSDBA
SHUTDOWN IMMEDIATE
STARTUP MOUNT EXCLUSIVE
ALTER DATABASE FLASHBACK ON;
ALTER DATABASE OPEN;
With flashback enabled the database can be switched back to a previous point in time or SCN without the need for a manual incomplete recovery. In the following example a table is created, the database is then flashbacked to a time before the table was created:
-- Create a dummy table.
CONN scott/tiger
CREATE TABLE flashback_database_test (
id NUMBER(10)
);

-- Flashback 5 minutes.
CONN sys/password AS SYSDBA
SHUTDOWN IMMEDIATE
STARTUP MOUNT EXCLUSIVE
FLASHBACK DATABASE TO TIMESTAMP SYSDATE-(1/24/12);
ALTER DATABASE OPEN RESETLOGS;

-- Check that the table is gone.
CONN scott/tiger
DESC flashback_database_test

Some other variations of the flashback database command include:
FLASHBACK DATABASE TO TIMESTAMP my_date;
FLASHBACK DATABASE TO BEFORE TIMESTAMP my_date;
FLASHBACK DATABASE TO SCN my_scn;
FLASHBACK DATABASE TO BEFORE SCN my_scn;

The window of time that is available for flashback is determined by the DB_FLASHBACK_RETENTION_TARGET parameter. The maximum flashback can be determined by querying the V$FLASHBACK_DATABASE_LOG view. It is only possible to flashback to a point in time after flashback was enabled on the database and since the last RESETLOGS command.

Flashback Query Functions

The TIMESTAMP_TO_SCN and SCN_TO_TIMESTAMP functions have been added to SQL and PL/SQL to simplify flashback operations:

SELECT * FROM emp AS OF SCN TIMESTAMP_TO_SCN(SYSTIMESTAMP - 1/24);
SELECT * FROM emp AS OF TIMESTAMP SCN_TO_TIMESTAMP(993240);
DECLARE
l_scn NUMBER;
l_timestamp TIMESTAMP;
BEGIN
l_scn := TIMESTAMP_TO_SCN(SYSTIMESTAMP - 1/24);
l_timestamp := SCN_TO_TIMESTAMP(l_scn);
END;
/

Wednesday, March 9, 2011

Checking Growth of Oracle Database

Step : 1 Calculate total Size of tablespace
SELECT sum(bytes)/1024/1024 "TOTAL SIZE (MB)"
FROM dba_Data_files


Step : 2 Calculate Free Space in Tablespace
SELECT sum(bytes)/1024/1024 "FREE SPACE (MB)"
FROM dba_free_space


Step : 3 Calculate total size , free space and used space in tablespace

SELECT t2.total "TOTAL SIZE",
t1.free "FREE SPACE",
(t1.free/t2.total)*100 "FREE (%)" ,
(1-t1.free/t2.total)*100 "USED (%)"
FROM (SELECT sum(bytes)/1024/1024 free FROM dba_free_space) t1 ,
(SELECT sum(bytes)/1024/1024 total FROM dba_Data_files) t2


Step : 4 Create table which is store all free/use space related information of tablespace

CREATE TABLE db_growth
AS
SELECT *
FROM(
SELECT sysdate,
t2.total "TOTAL_SIZE",
t1.free "FREE_SPACE",
(t1.free/t2.total)*100 "FREE% "
FROM
(SELECT sum(bytes)/1024/1024 free
FROM dba_free_space) t1 ,
(SELECT sum(bytes)/1024/1024 total
FROM dba_Data_files) t2
)


Step : 5 Insert free space information in DB_GROWTH table (if you want to populate data Manually)

INSERT INTO db_growth
SELECT *
FROM (
SELECT sysdate,
t2.total "TOTAL_SIZE",
t1.free "FREE_SPACE",
(t1.free/t2.total)*100 "FREE%"
FROM
(SELECT sum(bytes)/1024/1024 free
FROM dba_free_space) t1 ,
(SELECT sum(bytes)/1024/1024 total
FROM dba_Data_files) t2
)


Step : 6 Create View on DB_GROWTH based table ( This Steps is Required if you want to populate data automatically)

CREATE VIEW v_db_growth
AS SELECT *
FROM
(
SELECT sysdate,
t2.total "TOTAL_SIZE",
t1.free "FREE_SPACE",
(t1.free/t2.total)*100 "FREE%"
FROM
(SELECT sum(bytes)/1024/1024 free
FROM dba_free_space) t1 ,
(SELECT sum(bytes)/1024/1024 total
FROM dba_Data_files) t2
)


Step : 7 Insert data into DB_GROWTH table from V_DD_GROWTH view

INSERT INTO db_growth select *
FROM v_db_growth


Step : 8 Check everything goes fine.

SELECT * FROM db_growth;

Check Result
Step : 9 Execute following SQL for more time stamp information

ALTER SESSION SET nls_date_format ='dd-mon-yyyy hh24:mi:ss' ;
Session altered.


Step : 10 Create a DBMS jobs which execute after 24 hours
DECLARE
jobno NUMBER;
BEGIN
DBMS_JOB.submit(
jobno, 'BEGIN INSERT INTO db_growth SELECT * FROM v_db_growth;COMMIT:END;', sysdate, 'SYSDATE+ 24', TRUE);
COMMIT;
END;


PL/SQL procedure successfully completed.

Step: 11 View your dbms jobs and it's other information
SELECT * FROM user_jobs;
TIPS: If you want to execute dbms jobs manually execute following command other wise jobs is executing automatically
EXEC DBMS_JOB.run(ENTER_JOB_NUMBER)
PL/SQL procedure successfully completed.
Step: 12 Finally all data populated in db_growth table
SELECT * FROM db_growth

How to Drop All Objects in a Schema in Oracle 10g

Normally, it is simplest to drop and add the user. This is the preferred method if you have system or sysdba access to the database.

If you don't have system level access, and want to scrub your schema, the following sql will produce a series of drop statments, which can then be executed.

select 'drop '||object_type||' '|| object_name|| DECODE(OBJECT_TYPE,'TABLE',' CASCADE CONSTRAINTS;',';')
from user_objects




Then, I normally purge the recycle bin to really clean things up. To be honest, I don't see a lot of use for oracle's recycle bin, and wish i could disable it... but anyway:

purge recyclebin;



This will produce a list of drop statements. Not all of them will execute - if you drop with cascade, dropping the PK_* indices will fail. But in the end, you will have a pretty clean schema. Confirm with:

select * from user_objects

Session Roles

Viewing Privilege and Role Information in Oracle 10g Database

DBA view describes all column object grants in the database. ALL view describes all column object grants for which the current user or PUBLIC is the object owner, grantor, or grantee. USER view describes column object grants for which the current user is the object owner, grantor, or grantee.

DBA_COL_PRIVS

ALL_COL_PRIVS

USER_COL_PRIVS

ALL view lists column object grants for which the current user is object owner or grantor. USER view describes column object grants for which the current user is the grantor.

ALL_COL_PRIVS_MADE

USER_COL_PRIVS_MADE

ALL view describes column object grants for which the current user or PUBLIC is the grantee. USER view describes column object grants for which the current user is the grantee.

ALL_COL_PRIVS_RECD

USER_COL_PRIVS_RECD

DBA view lists all grants on all objects in the database. ALL view lists the grants on objects where the user or PUBLIC is the grantee. USER view lists grants on all objects where the current user is the grantee.

DBA_TAB_PRIVS

ALL_TAB_PRIVS

USER_TAB_PRIVS

ALL view lists the all object grants made by the current user or made on the objects owned by the current user. USER view lists grants on all objects owned by the current user.

ALL_TAB_PRIVS_MADE

USER_TAB_PRIVS_MADE

ALL view lists object grants for which the user or PUBLIC is the grantee. USER view lists object grants for which the current user is the grantee.

ALL_TAB_PRIVS_RECD

USER_TAB_PRIVS_RECD

This view lists all roles that exist in the database.


DBA_ROLES

DBA view lists roles granted to users and roles. USER view lists roles granted to the current user.

DBA_ROLE_PRIVS

USER_ROLE_PRIVS

DBA view lists system privileges granted to users and roles. USER view lists system privileges granted to the current user.

DBA_SYS_PRIVS

USER_SYS_PRIVS

This view describes roles granted to other roles. Information is provided only about roles to which the user has access.

ROLE_ROLE_PRIVS

This view contains information about system privileges granted to roles.
Information is provided only about roles to which the user has access.

ROLE_SYS_PRIVS

This view contains information about object privileges granted to roles. Information is provided only about roles to which the user has access.


ROLE_TAB_PRIVS

This view lists the privileges that are currently enabled for the user.

SESSION_PRIVS

This view lists the roles that are currently enabled to the user.

Thursday, February 24, 2011

How to change the Redo Log File size in Oracle Database

We had 50 MB Redo Log Files, 1 Redo Thread, 2 Redo Log Groups and One member in each group.
We decided to increase the Redo Log size to 100MB.
The Redo Logs must be dropped and recreated for changing the redo log size. It can be done online without shutting down the database. However, you need to make sure that the Redo Group being dropped should be INACTIVE when you do this.
We have the following Log Groups and members:
SQL> select * from v$logfile;

 GROUP# STATUS  TYPE    MEMBER          IS_RECOVE
------ ------- -----      --------- ---------
 2   ONLINE   /app01/oratest/oradata/BOTI/BOTI/redo02.log NO
 1   ONLINE /app01/oratest/oradata/BOTI/BOTI/redo01.log NO
And the status of the Log Groups is:
SQL> select * from v$log;

 GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVE STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --------- --------------
 1     1   12   52428800   1   NO    CURRENT   1156736  27-JAN-11
 2     1   11   52428800   1   YES   ACTIVE    1156732  27-JAN-11
Here we see that the Group# 1 is being used Currently and the Group# 2 though not being used Currently, however is ACTIVE (means if the Database crashes now, you will need this Group for recovery.) We need to make this group Inactive before proceeding ahead:
For this, execute a checkpoint:
SQL> alter system checkpoint;

System altered.
Now again check the status of the Redo Groups:
SQL> select * from v$log;

 GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --------- --------
 1 1 12 52428800 1 NO CURRENT 1156736 27-JAN-11
 2 1 11 52428800 1 YES INACTIVE 1156732 27-JAN-11
The group 2 is now Inactive. Hence we can proceed with dropping this group:
SQL> alter database drop logfile group 2;
alter database drop logfile group 2
*
ERROR at line 1:
ORA-01567: dropping log 2 would leave less than 2 log files for instance BOTI (thread 1)
ORA-00312: online log 2 thread 1: '/app01/oratest/oradata/BOTI/BOTI/redo02.log'
What went wrong ???
It’s a basic requirement in Oracle Database that there should always be a minimum 2 Redo Log Groups available with the Database. Hence we can not drop any Redo Group if there are only 2 Groups.
To overcome this issue, we need to add one more Redo group to the database.
Execute the following step:
SQL> alter database add logfile group 3 '/app01/oratest/oradata/BOTI/BOTI/redo03.log' size 100M;

Database altered.
Now check the logfiles:
SQL> select * from v$logfile;

 GROUP# STATUS TYPE MEMBER IS_RECOVE
---------- --------------------- --------------------- -
 3 ONLINE /app01/oratest/oradata/BOTI/BOTI/redo03.log NO
 2 ONLINE /app01/oratest/oradata/BOTI/BOTI/redo02.log NO
 1 ONLINE /app01/oratest/oradata/BOTI/BOTI/redo01.log NO
… and the status of the Groups:
SQL> select * from v$log;

 GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVE STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --------- ---------
 1 1 12   52428800 1 NO CURRENT 1156736 27-JAN-11
 2 1 11 52428800 1 YES INACTIVE 1156732 27-JAN-11
 3 1 0 104857600 1 YES UNUSED 0
The status of the new Group is UNUSED because it has never been used.
Now, we have 3 Redo Groups in our database. We can now proceed with Dropping Redo Group# 2.
SQL> alter database drop logfile group 2;

Database altered.
Also, delete the file ‘/app01/oratest/oradata/BOTI/BOTI/redo02.log’ from File system also.
Now add the Redo Group 2 back to the database with changed Redo size:
SQL> alter database add logfile group 2 '/app01/oratest/oradata/BOTI/BOTI/redo02.log' size 100M;

Database altered.

SQL> select * from v$logfile;

 GROUP#       STATUS  TYPE   MEMBER  IS_RECOVE
---------- --------------------- --------------------- --------
 3 ONLINE /app01/oratest/oradata/BOTI/BOTI/redo03.log NO
 2 ONLINE /app01/oratest/oradata/BOTI/BOTI/redo02.log NO
 1 ONLINE /app01/oratest/oradata/BOTI/BOTI/redo01.log NO

SQL> select * from v$log;

 GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --------- --------------
 1 1 12 52428800 1 NO CURRENT 1156736 27-JAN-11
 2 1 0 104857600 1 YES UNUSED 0
 3 1 0 104857600 1 YES UNUSED 0
Now we have to drop the 1st Redo Log Group. Before that, we need to change the status of this group:
SQL> alter system switch logfile;

System altered.

SQL> select * from v$log;

 GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --------- ---- -----
 1 1 12 52428800 1 YES ACTIVE 1156736 27-JAN-11
 2 1 13 10485760 1 NO CURRENT 1157376 27-JAN-11
 3 1 0 104857600 1 YES UNUSED 0
Still the Grpoup is in Active status. Issue a checkpoint:
SQL> alter system checkpoint;

System altered.

SQL> select * from v$log;

 GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --------- -------
 1 1 12 52428800 1 YES INACTIVE 1156736 27-JAN-11
 2 1 13 104857600 1 NO CURRENT 1157376 27-JAN-11
 3 1 0 104857600 1 YES UNUSED 0
Now we can drop the Redo Group# 1.
SQL> alter database drop logfile group 1;

Database altered.

SQL> select * from v$log;

 GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --------- -----
 2 1 13 104857600 1 NO CURRENT 1157376 27-JAN-11
 3 1 0 104857600 1 YES UNUSED 0

SQL> select * from v$logfile;

 GROUP# STATUS TYPE MEMBEs IS_RECOVE
---------- --------------------- --------------------- 
3 ONLINE /app01/oratest/oradata/BOTI/BOTI/redo03.log NO 
2 ONLINE /app01/oratest/oradata/BOTI/BOTI/redo02.log NO
Delete the file ‘/app01/oratest/oradata/BOTI/BOTI/redo01.log’ from OS.
Now we need to add this group back to the database with 100MB Redo Log file:
SQL> alter database add logfile group 1 '/app01/oratest/oradata/BOTI/BOTI/redo01.log' size 100M;

Database altered.

SQL> select * from v$log;

 GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --------- ----------
 1   1   0   104857600   1    YES    UNUSED    0
 2   1   13  104857600   1     NO   CURRENT     1157376       27-JAN-11
 3   1   0   104857600   1    YES   UNUSED    0
Here we can see that all the Redo Groups are now showing 100MB size (column BYTES).
SQL> select * from v$logfile;

 GROUP# STATUS  TYPE   MEMBER    IS_RECOVE
---------- --------------------- -----------------
 3 ONLINE /app01/oratest/oradata/BOTI/BOTI/redo03.log NO
 2 ONLINE /app01/oratest/oradata/BOTI/BOTI/redo02.log NO
 1 ONLINE /app01/oratest/oradata/BOTI/BOTI/redo01.log NO
Though it’s suggested that you should keep 3 groups, if you want you can drop the Redo Group 3 which we added for this exercise.
SQL> alter database drop logfile group 3;

Database altered.

SQL> select * from v$logfile;

 GROUP# STATUS    TYPE                MEMBER                   IS_RECOVE
------- ------- -------------- ---------------------
 2 ONLINE  /app01/oratest/oradata/BOTI/BOTI/redo02.log      NO
 1 ONLINE  /app01/oratest/oradata/BOTI/BOTI/redo01.log      NO

SQL> select * from v$log;

 GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME
------ ---------- ---------- ---------- ---------- --------- ---------
 1      1       0          104857600     1 YES UNUSED 0
 2      1      13          104857600     1 NO CURRENT 1157376 27-JAN-11

SQL> alter system switch logfile;

System altered.

SQL> select * from v$log;

 GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARCHIVE STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --------- ---------- 
 1        1    14  104857600 1  NO   CURRENT   1157584       27-JAN-11
 2        1    13  104857600 1  YES  ACTIVE     1157376     27-JAN-11
Congratulations ! You have changed the Redo Log file size from 50M to 100M.

Thursday, January 20, 2011

Installing Oracle Enterprise Manager Grid Control 11g Release 1 (11.1.0.1.0) Linux x86





In this tutorial, you learn how to install Oracle Enterprise Manager Grid Control 11g Release 1 (11.1.0.1.0) Linux x86.

Time to Complete

Approximately 2.5 hours.

Overview

Earlier releases of Oracle Enterprise Manager Grid Control were installed in a single step using Oracle Universal Installer.   With the release of Oracle Enterprise Manager Grid Control 11g Release 1 (11.1.0.1.0) installing Oracle Enterprise Manager Grid Control is a three step process requiring the installation of Oracle WebLogic Server and Oracle Database prior to installing Grid Control. 

Scenario

In this tutorial, you install Oracle WebLogic Server 11g Release 1 (10.3.2) Linux x86, Oracle Database 11g Release 2 (11.2.0.1.0) Linux x86, and Oracle Enterprise Manager Grid Control 11g Release 1 (11.1.0.1.0) Linux x86.

Software Requirements

The following is a list of software requirements:
  • Download Oracle Enterprise Manager Grid Control 11g Release 1 (11.1.0.1.0) Linux x86 from OTN at this link
  • Download Oracle WebLogic Server 11g Release 1 (10.3.2) Linux x86 from OTN at this link
  • Oracle Database 11g Release 2 (11.2.0.1.0) Linux x86 from OTN at this link

Prerequisites

Before starting this tutorial, you should:
  • Have a server with 4G or more RAM
  • Complete a default install of Oracle Enterprise Linux 5.X (this example uses 5.4) with the oracle-validated RPM installed
  • Have 7G of free disk space for the installation software
  • Have 14G of free space for installing the software
Note: Screen captures for this tutorial were taken in Oracle Enterprise Linux 5.4 with a Gnome 2.16 Desktop.

Configuring the Operating System

Installing the oracle-validated RPM installs RPMs required for an Oracle installation as well as creates the operating system user oracle. The lesson uses operating system user oracle to install all the software.
Before installing the software the operating system must be configured. To configure the operating system perform the following steps as operating system user root.

Configuring the Operating System


1 . As root, in a terminal, perform these steps to configure the operating system in preparation for the software installations.

Operating system commands:

Screenshot for Step
 

Staging Software


2 . The installation software for this lesson is staged in directory /stage.
Screenshot for Step

Installation Information


3 . The software will be installed using the follow homes:
Database:/u01/app/oracle/database/11.2.0/dbhome_1
WebLogic: /u01/app/oracle/middleware
EMGC: /u01/app/oracle/gc_inst


  • Use your host name and domain name.
  • Any valid database SID can be used.
  • When passwords are required, choose a strong password. Do not use the passwords provided in the lesson.









































Installing Oracle WebLogic Server 11g Release 1 (10.3.2) Linux x86


4 . Connect as operating system user oracle in an X session.
5 . Execute the installer for Oracle WebLogic Server 11g Release 1 (10.3.2) Linux x86.
ls -al /stage/wls
cd /stage/wls
./wls1032_linux32.bin

Screenshot for Step
Screenshot for Step
6 . Click Next.
Screenshot for Step
7 . Set the value of Middleware Home Directory to:
/u01/app/oracle/middleware
Click Next.
Screenshot for Step
8 . Enter your e-mail address and My Oracle Support Password. Click Next.
If you choose to leave the fields blank, you will receive a pop up after clicking Next. Click Yes, to continue.
Screenshot for Step
9 . Click Next.
Screenshot for Step
10 . Click Next.
Screenshot for Step
11 . Click Next.
Screenshot for Step
12 . Wait for the installation to complete.
Screenshot for Step
13 . After the installation completes, uncheck Run Quickstart. Click Done.
Screenshot for Step

Installing Oracle Database 11g Release 2 (11.2.0.1.0) Linux x86


Installing Oracle Database 11g Release 2 (11.2.0.1.0) Linux x86


14 . Execute the installer for Oracle Database 11g Release 2 (11.2.0.1.0) Linux x86.
ls -al /stage/database
cd /stage/database
./runInstaller

Screenshot for Step
Screenshot for Step
15 . Enter your e-mail address and My Oracle Support Password. Click Next.
If you choose to leave the fields blank, you will receive a pop up after clicking Next. Click Yes, to continue.
Screenshot for Step
16 . Click Next.
Screenshot for Step
17 . Select Server Class. Click Next.
Screenshot for Step
18 . Click Next.
Screenshot for Step
19 . Select Typical. Click Next.
Screenshot for Step
20 . Enter these values, then click Next.
Oracle Base: /u01/app/oracle/database
Software location: /u01/app/oracle/database/11.2.0/dbhome_1
Storage Type: File System
Database file location: /u01/app/oracle/database/oradata
Database Edition: Enterprise Edition
OSDBA Group: dba
Global database name: emrep.example.com
Administrative password:
Pick a strong password. Use the domain of your network as the domain for the global database name.
Screenshot for Step
21 . Inventory Directory: /u01/app/oraInventory
oraInventory Group Name: oinstall
Click Next.
Screenshot for Step
22 . Although installing the oracle-validated RPM made several operating system configuration changes, a few more are required. Click Fix & Check Again.
Screenshot for Step
23 . Follow the on screen instructions to run the fixup script changing the needed operating system settings.
Screenshot for Step
24 . Open a terminal. Change to the operating system user root. Execute the script as instructed in the pop up window.
su - root
cd /tmp/CVU*
ls
./runfixup.sh

Screenshot for Step
25 . Click OK.
Screenshot for Step
26 . Click Finish.
Screenshot for Step
27 . Wait for the installation to complete.
Screenshot for Step
28 . Wait for the installation to complete.
Screenshot for Step
29 . Click OK.
Screenshot for Step
30 . Follow the instructions in the window.
Screenshot for Step
31 . Open a terminal. Change to operating system user root. Execute the two scripts.
su - root
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/database/11.2.0/dbhome_1/root.sh

Screenshot for Step
32 . Click Close.
Screenshot for Step

Removing Enterprise Manager Database Control

Creating a database using a Database Configuration Assistant template, as is done when choosing to create a database in the Oracle Universal Installer, creates a database containing an Enterprise Manger Database Control repository. The repository contains a subset of the Enterprise Manager Grid Control functionality. Before Enterprise Manager Grid Control can use the database, the Enterprise Manager Database Control repository must be dropped and the configuration files removed.
33 . Set the environment by souring oraenv located in /usr/local/bin. Execute the command to remove Enterprise Manager Database Control.
. oraenv
emrep
emca -deconfig dbcontrol db -repos drop -HOST host01.example.com -PORT 1521 -SID emrep -SYS_PWD oracle_4U -SYSMAN_PWD oracle_4U -DBSNMP_PWD oracle_4U
Y

Screenshot for Step

Configuring the Database for an Enterprise Manager Grid Control Installation

Enterprise Manager Grid Control database repository requirements exceed the default configuration from the Database Configuration Assistant template. Perform the following to meet the requirements.
34 . An Enterprise Manager Grid Control 11g Release 1 (11.1.0.1.0) database repository requires:
  • session_cached_cursors to be set to 200 or more
  • log_buffer set to 10485760 or more
  • processes set to 500 or more
  • undo tablespace size to be 200M or greater
The first three changes require the database to be bounced for the changes to take effect.
sqlplus /nolog
connect / as sysdba
alter system set session_cached_cursors=200 scope=spfile;
alter system set log_buffer=10485760 scope=spfile;
alter system set processes=500 scope=spfile;
alter database datafile '/u01/app/oracle/database/oradata/emrep/undotbs01.dbf' resize 250M;
shutdown immediate
startup
exit

Screenshot for Step

Installing Oracle Enterprise Manager Grid Control 11g Release 1 (11.1.0.1.0) Linux x86


35 . Execute the installer for Oracle Enterprise Manager Grid Control 11g Release 1 (11.1.0.1.0) Linux x86.
ls -al /stage/em
cd /stage/em
./runInstaller

Screenshot for Step
Screenshot for Step
36 . Enter your e-mail address and My Oracle Support Password. Click Next.
If you choose to leave the fields blank, you will receive a pop up after clicking Next. Click Yes, to continue.
Screenshot for Step
37 . Enter your My Oracle Support information and an install location or choose to Skip Software Updates. Click Next.
Screenshot for Step
38 . Click Next.
Screenshot for Step
39 . Click Next.
Screenshot for Step
40 . The installer will pick up the Middleware home and provide the install location for the OMS base on the Middleware home. Click Next.
Screenshot for Step
41 . Enter a password for the WebLogic user and Node Manager. Click Next.
Screenshot for Step
42 . Enter the database connection information used from the database installation lesson Click Next.
Database Host Name: host01.example.com
Port: 1521
Service/SID: emrep
SYS Password: oracle_4U
Screenshot for Step
43 . Enter a password for SYSMAN. Click Next.
Screenshot for Step
44 . Enter a password for the agent. Click Next.
Screenshot for Step
45 . Click Next.
Screenshot for Step
46 . Click Install.
Screenshot for Step
47 . Wait for the installation to complete.
Screenshot for Step
48 . Follow the instructions in the window.
Screenshot for Step
49 . Open a terminal. Change to operating system user root. Execute the script. Press the Enter key for each of the prompts.
su - root
/u01/app/oracle/middleware/oms11g/allroot.sh

Screenshot for Step
50 . Click OK.
Screenshot for Step
51 . Wait for the installation to complete.
Screenshot for Step
52 . Click Close.
Screenshot for Step

Accessing Oracle Enterprise Manager Grid Control with a Browser


Accessing Enterprise Manager for the first time requires accepting the security certificate from Enterprise Manager. Use URL: https://host01.example.com:7799/em
This example uses Firefox 3.6.
53 . Click Or you can add an exception... .
Screenshot for Step
54 . Click Add Exception... .
Screenshot for Step
55 . Click Get Certificate .
Screenshot for Step
56 . Click Confirm Security Exception .
Screenshot for Step
57 . Enter username sysman and the password you chose for sysman.
Screenshot for Step
58 . Click I Accept.
Screenshot for Step
59 . Installation complete.
Screenshot for Step

Summary

In this tutorial, you should have learned how to:
  • Configure Oracle Enterprise Linux 5 for an Enterprise Manager Grid Control installation.
  • Install Oracle WebLogic Server 11g Release 1 (10.3.2) Linux x86.
  • Install Oracle Database 11g Release 2 (11.2.0.1.0) Linux x86.
  • Configure Oracle Database 11g Release 2 (11.2.0.1.0) Linux x86 for an Enterprise Manager Grid Control installation.
  • Install Oracle Enterprise Manager Grid Control 11g Release 1 (11.1.0.1.0) Linux x86.
  • Access Oracle Enterprise Manager Grid Control 11g Release 1 (11.1.0.1.0) Linux x86 from a browse