Sunday, 15 October 2023

Oracle GoldenGate HUB Configuration

Oracle GoldenGate HUB Configuration

In this post, we will provide the steps to set up an Oracle GoldenGate hub for Uni-Directional Replication.

In our environment, we have an Oracle Database 21c multi-tenant (container CDB) as both the source and target databases on seperated servers. We also have a GoldenGate hub server with the latest Oracle client installed on it. For this configuration, we will be using "pdb1" on both the source and target databases, and a demo schema named "TEST."

Information:

  • Source:
    • Hostname: dbsource
    • IP: 192.168.220.09
    • DB: pdb1
    • Schema: Test
    • Oracle: Oracle Database 21c
  • GoldenGate HUB:
    • Hostname: goldengate-server
    • IP: 192.168.220.10
    • DB: proddb
    • Oracle: Oracle Client 21c
  • Target:
    • Hostname: dbtarget
    • IP: 192.168.220.11
    • DB: pdb1
    • Schema: Test
    • Oracle: Oracle Database 21c

Steps:

  1. Edit .bash profile for client installation.

  2. Download and install Oracle GoldenGate 21c.

  3. Download and install Oracle Client 21c.

  4. Configure tnsnames.ora file with entries for source and target DBs.

  5. Configure GoldenGate settings and configuration.

Download the latest version of Oracle GoldenGate and Oracle Client software.

Verify Certification: Certification Link


Create a gg_home directory at /u01/app/oracle/product/21.0.0/


Unzip the zip file and install GoldenGate at gg Home:

Install Oracle Golden Gate 21c at gg_home directory

/u01/app/oracle/product/21.0.0/gg_home


Client Installation:

Install Oracle Client 21c or a later version at the client home directory

/u01/app/oracle/product/21.0.0/client_1/


Update the .bash profile with Oracle settings:

####################################################
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=goldengate-server; export ORACLE_HOSTNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/21.0.0/client_1; export ORACLE_HOME
TNS_ADMIN=$ORACLE_BASE/product/21.0.0/client_1/network/admin; export TNS_ADMIN
OGGHOME=/u01/app/oracle/product/21.0.0/gg_home; export OGGHOME
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib: export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
    

Make specific changes in both databases while in mount mode:

SQL> alter system set recyclebin=off scope=spfile;
SQL> alter database add supplemental log data;
SQL> alter database archivelog;
SQL> ALTER DATABASE FORCE LOGGING;
SQL> alter system set ENABLE_GOLDENGATE_REPLICATION=true;

SQL> alter database open;
    

Create tablespaces and user script for container databases:

We need to create the required tablespaces and admin user on source and target in CDB as well as in all PDBs.

In CDB:
SQL> create tablespace ggtbs datafile '/u01/app/oracle/oradata/CDB1/ggtbs01.dbf' size 1G autoextend on;
SQL> create temporary tablespace ggtemp tempfile '/u01/app/oracle/oradata/CDB1/ggtemp01.dbf' size 1G autoextend on;

In PDBs:
SQL> alter session set container=pdb1;
SQL> create tablespace ggtbs datafile '/u01/app/oracle/oradata/CDB1/pdb1/ggtbs01.dbf' size 1G autoextend on;
SQL> create temporary tablespace ggtemp tempfile '/u01/app/oracle/oradata/CDB1/pdb1/ggtemp01.dbf' size 1G autoextend on;

SQL> alter session set container=pdb2;
SQL> create tablespace ggtbs datafile '/u01/app/oracle/oradata/CDB1/pdb2/ggtbs01.dbf' size 1G autoextend on;
SQL> create temporary tablespace ggtemp tempfile '/u01/app/oracle/oradata/CDB1/pdb2/ggtemp01.dbf' size 1G autoextend on;

Create a Globale User:
SQL> CREATE USER c##ggadmin IDENTIFIED BY ggadmin container=all  default tablespace ggtbs temporary tablespace ggtemp;

Grant privileges:
SQL> GRANT CONNECT, RESOURCE, DBA TO c##ggadmin container=all;
SQL> ALTER USER c##ggadmin QUOTA unlimited ON ggtbs;
SQL> exec dbms_goldengate_auth.grant_admin_privilege('c##ggadmin',container=>'all');
SQL> ALTER USER c##ggadmin SET CONTAINER_DATA=all CONTAINER=current;
    

Create subdirectories golden gate server:

mkdir /u01/app/oracle/product/21.0.0/gg_home/dirdat/tr
(we will using this directory for trail files)

cd $GGHome
[oracle@goldengate-server gg_home]$ ./ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 21.3.0.0.0 OGGCORE_21.3.0.0.0_PLATFORMS_210728.1047_FBO
Oracle Linux 7, x64, 64bit (optimized), Oracle Database 21c and lower supported versions on Jul 29 2021 03:59:23
Operating system character set identified as UTF-8.

Copyright (C) 1995, 2021, Oracle and/or its affiliates. All rights reserved.

GGSCI (goldengate-server) 1> create subdirs

Creating subdirectories under current directory ./gg_home

Parameter files                ./gg_home/dirprm: already exists
Report files                   ./gg_home/dirrpt: created
Checkpoint files               ./gg_home/dirchk: created
Process status files           ./gg_home/dirpcs: created
SQL script files               ./gg_home/dirsql: created
Database definitions files     ./gg_home/dirdef: created
Extract data files             ./gg_home/dirdat: created
Temporary files                ./gg_home/dirtmp: created
Stdout files                   ./gg_home/dirout: created
    

Run scripts for creating necessary objects for supporting DDL replication on both servers:

@marker_setup.sql
@ddl_setup.sql
@role_setup.sql
@ddl_enable.sql
    

Add GoldenGate User to CredentialStore:

We need to add login information in GoldenGate creating a credentialstore and aliases source and target databases:
(Note: Check the tns file at the bottom for database connections).

./ggsci GGSCI (goldengate-server) 2> add credentialstore Credential store created. GGSCI (goldengate-server) 3> alter credentialstore add user c##ggadmin@ggtarget alias ggtarget Password: Credential store altered. GGSCI (goldengate-server) 4> alter credentialstore add user c##ggadmin@ggsource alias ggsource Password: Credential store altered. GGSCI (goldengate-server) 5> info credentialstore Reading from credential store: Default domain: OracleGoldenGate Alias: ggtarget Userid: c##ggadmin@ggtarget Alias: ggsource Userid: c##ggadmin@ggsource

Configure the manager and start the service:

GGSCI (goldengate-server) 55> Edit params mgr
port 7809

GGSCI (goldengate-server) 55> start mgr

GGSCI (goldengate-server) 55> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING

    

Configure the extract process and start it:

GGSCI (goldengate-server) 1> dblogin useridalias ggsource

GGSCI (goldengate-server) 1> edit params ext1
extract ext1
exttrail /u01/app/oracle/product/21.0.0/gg_home/dirdat/tr
discardfile /u01/app/oracle/product/21.0.0/gg_home/dirrpt/discard01.dsc, append megabytes 50
logallsupcols
DDL include mapped
useridalias ggsource
table test.*;


GGSCI (goldengate-server as c##ggadmin@cdb1) 7> register extract ext1 database

GGSCI (goldengate-server as c##ggadmin@cdb1) 8> add extract ext1, integrated tranlog, begin now
Integrated Extract added.

GGSCI (goldengate-server as c##ggadmin@cdb1) 9>  Add EXTTRAIL /u01/app/oracle/product/21.0.0/gg_home/dirdat/tr, extract ext1
EXTTRAIL added.

-- to view 
ggsci> view params ext1
    

Configure the Replicat process:

login to target db
GGSCI (goldengate-server) 1> dblogin useridalias ggtarget
Successfully logged into database.

-- Parameter file for Replicat:
GGSCI (goldengate-server as c##ggadmin@cdb1) 3> edit params rep1

REPLICAT rep1
ASSUMETARGETDEFS
HANDLECOLLISIONS
DISCARDFILE ./dircrd/rep_discard.txt, append, megabytes  10
DDL include ALL
USERIDALLIAS ggtarget
MAP test.*, TARGET test.*;

-- Create checkpoint Table
GGSCI (goldengate-server as c##ggadmin@cdb1) 8> add checkpointtable c##ggadmin.checkpoint
Successfully created checkpoint table c##ggadmin.checkpoint.

-- Add Replicats:
GGSCI (goldengate-server as c##ggadmin@cdb1) 9> ADD REPLICAT rep1 integrated exttrail 
/u01/app/oracle/product/21.0.0/gg_home/dirdat/tr CHECKPOINTTABLE c##ggadmin.checkpoint

Integrated Replicat added.

-- Register Replicats to database:
GGSCI (goldengate-server as c##ggadmin@cdb1) 10> register replicat REP1 database
2023-10-13 17:21:06  INFO    OGG-02528  Replicat group REP1 successfully registered with database as inbound server OGG$REP1.
    

Table creation for demo:

CREATE TABLE Test.t1(
    id NUMBER GENERATED BY DEFAULT AS IDENTITY,
    dt VARCHAR2(50) NOT NULL,
    PRIMARY KEY(id)
);
    

Add supplemental logging for a table or all schemas:

GGSCI (goldengate-server) 1> add SCHEMATRANDATA test
    

Start the Extract and Replicat process:

GGSCI (goldengate-server) 6> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING
EXTRACT     STOPPED     EXT1        00:14:23      00:00:14
REPLICAT    STOPPED     REP1        00:00:00      00:00:06

GGSCI (goldengate-server) 7> start ext1

Sending START request to Manager ...
Extract group EXT1 starting.

GGSCI (goldengate-server) 10> start rep1

Sending START request to Manager ...
Replicat group REP1 starting.


GGSCI (goldengate-server) 11> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING
EXTRACT     RUNNING     EXT1        00:14:23      00:01:24
REPLICAT    RUNNING     REP1        00:00:00      00:01:15
    

Insert some data on source and check the replication:

SQL> insert into t1 values(1,sysdate);
SQL> commit;
SQL> select * from t1;
        ID DT
---------- ---------------------------
         1 13-OCT-23

Check on Target DB:
$  sqlplus test/test@ggtarget

SQL*Plus: Release 21.0.0.0.0 - Production on Sat Oct 14 02:23:02 2023
Version 21.3.0.0.0

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

Last Successful login time: Fri Oct 13 2023 23:48:18 -04:00

Connected to:
Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0

SQL> select * from t1;

        ID DT
---------- ---------------------------
         1 13-OCT-23
         
         

Replicatoin is successfull. You can test it for all DML and DDL operation...


TNS file use in this demo:

[oracle@goldengate-server gg_home]$ cat /u01/app/oracle/product/21.0.0/client_1/network/admin/tnsnames.ora
GGSOURCE=
   (DESCRIPTION=
        (ENABLE=BROKEN)
        (ADDRESS_LIST=
            (ADDRESS=(PROTOCOL=TCP)(HOST=dbsource)(PORT=1522)))
        (CONNECT_DATA=(SERVICE_NAME=pdb1))
    )

GGTARGET =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dbtarget)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdb1)
    )
  )
    


Saturday, 23 September 2023

Configure Oracle 11g Enterprise Manager database console manually

Follow the following steps. 
 
1. Drop dbcontrol configuration 
2. Create the OEM repository 
3. Configure EM db control 

Step 1. Drop the existing configuration. 
 [oracle@dbserver bin]$ emca -deconfig dbcontrol db -repos drop
 

Step 2. Create the OEM repository. 
[oracle@dbserver bin]$ emca -repos create





















Step 3. Configure db control. 
[oracle@dbserver ~]$ emca -config dbcontrol db

























On any web browser try the em URL to verify the configuration.

To check the status of EM.
[oracle@dbserver ~]$ emctl status dbconsole



 



Start EM.
[oracle@dbserver ~]$ emctl start dbconsole

Stop EM.
[oracle@dbserver ~]$ emctl stop dbconsole


Monday, 1 May 2023

Oracle Database 19c Data Guard Setup Using the Data Guard Broker

=========================================================================

Setup for following demonstraton:

Primary:

--Host Name: Linux1

--DB Name: orcl

--Db_Unique_Name: orcl

--Service Name: ORCL

------------------------------------------------------------------------------------------------------------------------

==Standby:

--Host Name: Linux2

--DB Name: orcl

--Db_Unique_Name: orcldr

--Service Name: ORCL_STBY 

=========================================================================

------------------------------------------------------------------------------------------------------------------------
Primary Server Setup

Logging:

Switch archivelog mode:

select log_mode from v$database;

alter database archivelog;


Enable force logging:

alter database force logging;


Set FRA for recovery and flashback

SQL> alter system set db_recovery_file_dest_size=10G scope=both sid='*';

SQL> alter system set db_recovery_file_dest='+DATA' scope=both sid='*';

System altered.


Enable Flashback on:

alter database flashback on;

------------------------------------------------------------------------------------------------------------------------

Create Standby redo logs:

SQL> alter database add standby logfile thread 1 group 10 ('/u01/app/oracle/oradata/ORCL/standby_redo01.log') size 50m;

SQL> alter database add standby logfile thread 1 group 11 ('/u01/app/oracle/oradata/ORCL/standby_redo02.log') size 50m;

SQL> alter database add standby logfile thread 1 group 12 ('/u01/app/oracle/oradata/ORCL/standby_redo03.log') size 50m;

SQL> alter database add standby logfile thread 1 group 13 ('/u01/app/oracle/oradata/ORCL/standby_redo04.log') size 50m;

------------------------------------------------------------------------------------------------------------------------

Initialization Parameters

Check the setting for the DB_NAME and DB_UNIQUE_NAME parameters. 

In this case they are both set to "orcl" on the primary database.


Make sure the STANDBY_FILE_MANAGEMENT parameter is set.

alter system set standby_file_management=auto;

------------------------------------------------------------------------------------------------------------------------

Service Setup

Following entries for the primary and standby databases are needed in the tnsnames.ora files on all servers.


ORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = linux1)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SID = orcl)

    )

  )


ORCL_STBY =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = linux2)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SID = orcl)

    )

  )

------------------------------------------------------------------------------------------------------------------------

The "$ORACLE_HOME/network/admin/listener.ora" file on the primary server contains the following configuration.  

    

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = orcl)

      (ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1)

      (SID_NAME = orcl)

    )

        (SID_DESC =

      (GLOBAL_DBNAME = orcl_DGMGRL)

      (ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1)

      (SID_NAME = orcl)

    )

  )



Add Following to Standby Listerer.ora: 


SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = orcldr)

      (ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1)

      (SID_NAME = orcl)

    )

        (SID_DESC =

      (GLOBAL_DBNAME = orcldr_DGMGRL)

      (ORACLE_HOME = /u01/app/oracle/product/19.0.0/dbhome_1)

      (SID_NAME = orcl)

    )

  )

------------------------------------------------------------------------------------------------------------------------

Standby Server Setup

Create a parameter file for the standby database called "/u01/mypfile.ora" with the following contents.


*.db_name='cdb1'


Create a password file, with the SYS password matching that of the primary database.

$ orapwd file=/u01/app/oracle/product/19.0.0/db_1/dbs/orapwcdb1 password=Password1 entries=10

Or

copy from primary using scp

------------------------------------------------------------------------------------------------------------------------

Start the auxiliary instance on the standby server by starting it using the above created pfile "mypfile.ora"

$ export ORACLE_SID=orcl

$ sqlplus / as sysdba

SQL> STARTUP NOMOUNT PFILE='/u01/mypfile.ora';

------------------------------------------------------------------------------------------------------------------------

Connect to RMAN, specifying a full connect string for both the TARGET and AUXILIARY instances.

[oracle@linux1 admin]$ rman target sys/oracle@orcl auxiliary sys/oracle@orcl_stby


Use following rman commands to strat duplication of database from live primary database.

RMAN> duplicate target database

for standby from active database

dorecover

spfile

set db_unique_name='orcl_stby' comment 'Is Standby'

nofilenamecheck;

------------------------------------------------------------------------------------------------------------------------

Enable broker on primary and standby database:

alter system set dg_broker_start=true;

------------------------------------------------------------------------------------------------------------------------

Broker configuration:

[oracle@linux1 admin]$ dgmgrl sys/oracle@orcl


DGMGRL> create configuration dg_config as primary database is orcl connect identifier is orcl;

Configuration "dg_config" created with primary database "orcl"


DGMGRL> add database orcl_stby as connect identifier is orcl_stby maintained as physical;

Database "orcl_stby" added


add database orcl_stby2 as connect identifier is orcl_stby2 maintained as physical;


DGMGRL> enable configuration;


DGMGRL> show configuration;

------------------------------------------------------------------------------------------------------------------------

Stop/Start Managed Recovery

-- Stop managed recovery.

alter database recover managed standby database cancel;


-- Start managed recovery.

alter database recover managed standby database disconnect;

or

alter database recover managed standby database disconnect nodelay;

------------------------------------------------------------------------------------------------------------------------

Database Switchover

Before process switchover or failover, always validate that everything is okay with my DataGuard environment.


DGMGRL> validate database orcl_stby


DGMGRL> switchover to orcl_stby;


$ dgmgrl sys/Password1@cdb1_stby

------------------------------------------------------------------------------------------------------------------------

Database Failover

DGMGRL> failover to orcl_stby;

------------------------------------------------------------------------------------------------------------------------

After using above failover, since the standby database is now the primary database it should be backed up immediately.


The original primary database can now be configured as a standby. If flashback database was enabled on the primary database, then this can be done relatively easily with the following command.


DGMGRL> reinstate database orcl;

------------------------------------------------------------------------------------------------------------------------

Read-Only Standby and Active Data Guard:

Once a standby database is configured, it can be opened in read-only mode to allow query access.


shutdown immediate;

startup mount;

alter database open read only;

alter database recover managed standby database disconnect from session;

------------------------------------------------------------------------------------------------------------------------

Verify Sync:


SELECT ARCH.THREAD# "Thread", ARCH.SEQUENCE# "Last Sequence Received", APPL.SEQUENCE# "Last Sequence Applied", (ARCH.SEQUENCE# - APPL.SEQUENCE#) "Difference" FROM (SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)) ARCH,(SELECT THREAD# ,SEQUENCE# FROM V$LOG_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL WHERE ARCH.THREAD# = APPL.THREAD# ORDER BY 1;

------------------------------------------------------------------------------------------------------------------------

Check all the above changed parameters:


set linesize 500 pages 0

col value for a90

col name for a50

 

select name, value

from v$parameter

where name in ('db_name','db_unique_name','log_archive_config', 'log_archive_dest_1','log_archive_dest_2',

   'log_archive_dest_3', 'log_archive_dest_4',

               'log_archive_dest_state_1','log_archive_dest_state_2', 'remote_login_passwordfile',

               'log_archive_format','log_archive_max_processes','fal_server','db_file_name_convert',

                     'log_file_name_convert', 'standby_file_management');

------------------------------------------------------------------------------------------------------------------------

=========================================================================



Saturday, 17 January 2015

Recover a Database when all Control Files and all Redo Log Files are Lost and Database is in no archive log mode and there is no backup

Here we have to create a scenario where we lost all control files and redo log files and there is no backup. We only have data files and initialization file. The database is in no archive log mode.
The steps followed to recover the database: 

Step 1. Login to database and shutdown it.

[oracle@linux1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 17 03:15:59 2015

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

Step 2. Let have delete all redolog files and control files at OS level.

[oracle@linux1 db1]$ ll
total 2076740
-rw-r-----  1 oracle oinstall  10076160 Jan 17 03:16 control01.ctl
-rw-r-----. 1 oracle oinstall 362422272 Jan 17 03:16 example01.dbf
-rw-r-----  1 oracle oinstall  52429312 Jan 17 03:16 redo01.log
-rw-r-----  1 oracle oinstall  52429312 Jan 17 03:04 redo02.log
-rw-r-----  1 oracle oinstall  52429312 Jan 17 03:04 redo03.log
-rw-r-----. 1 oracle oinstall  52436992 Jan 17 03:16 srcdata01.dbf
-rw-r-----. 1 oracle oinstall 587210752 Jan 17 03:16 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 807411712 Jan 17 03:16 system01.dbf
-rw-r-----. 1 oracle oinstall  20979712 Jan 17 02:41 temp01.dbf
-rw-r-----. 1 oracle oinstall  52436992 Jan 17 03:16 trgdata01.dbf
-rw-r-----. 1 oracle oinstall  68165632 Jan 17 03:16 undotbs01.dbf
-rw-r-----. 1 oracle oinstall   9183232 Jan 17 03:16 users01.dbf
[oracle@linux1 db1]$ rm redo0*
[oracle@linux1 db1]$ ll
total 1923128
-rw-r-----  1 oracle oinstall  10076160 Jan 17 03:16 control01.ctl
-rw-r-----. 1 oracle oinstall 362422272 Jan 17 03:16 example01.dbf
-rw-r-----. 1 oracle oinstall  52436992 Jan 17 03:16 srcdata01.dbf
-rw-r-----. 1 oracle oinstall 587210752 Jan 17 03:16 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 807411712 Jan 17 03:16 system01.dbf
-rw-r-----. 1 oracle oinstall  20979712 Jan 17 02:41 temp01.dbf
-rw-r-----. 1 oracle oinstall  52436992 Jan 17 03:16 trgdata01.dbf
-rw-r-----. 1 oracle oinstall  68165632 Jan 17 03:16 undotbs01.dbf
-rw-r-----. 1 oracle oinstall   9183232 Jan 17 03:16 users01.dbf
[oracle@linux1 db1]$ pwd
/u01/app/oracle/oradata/db1
[oracle@linux1 db1]$ rm control01.ctl
[oracle@linux1 db1]$ ll
total 1913288
-rw-r-----. 1 oracle oinstall 362422272 Jan 17 03:16 example01.dbf
-rw-r-----. 1 oracle oinstall  52436992 Jan 17 03:16 srcdata01.dbf
-rw-r-----. 1 oracle oinstall 587210752 Jan 17 03:16 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 807411712 Jan 17 03:16 system01.dbf
-rw-r-----. 1 oracle oinstall  20979712 Jan 17 02:41 temp01.dbf
-rw-r-----. 1 oracle oinstall  52436992 Jan 17 03:16 trgdata01.dbf
-rw-r-----. 1 oracle oinstall  68165632 Jan 17 03:16 undotbs01.dbf
-rw-r-----. 1 oracle oinstall   9183232 Jan 17 03:16 users01.dbf

[oracle@linux1 db1]$

[oracle@linux1 db1]$ cd ../..
[oracle@linux1 oracle]$ cd fast_recovery_area/db1/
[oracle@linux1 db1]$ ll
total 19360
-rw-r----- 1 oracle oinstall  9748480 Jan 17 02:41 __control02.ctl
-rw-r----- 1 oracle oinstall 10076160 Jan 17 03:16 control02.ctl
[oracle@linux1 db1]$ rm control02.ctl
[oracle@linux1 db1]$ ll
total 9520
-rw-r----- 1 oracle oinstall 9748480 Jan 17 02:41 __control02.ctl
[oracle@linux1 db1]$ rm __control02.ctl
[oracle@linux1 db1]$ ll
total 0
[oracle@linux1 db1]$

Step 3. Now login again and and startup database.

[oracle@linux1 db1]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 17 03:23:49 2015

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  413372416 bytes
Fixed Size                  2253784 bytes
Variable Size             314575912 bytes
Database Buffers           88080384 bytes
Redo Buffers                8462336 bytes
ORA-00205: error in identifying control file, check alert log for more info


SQL>

Step 4. Alert log giving following error that control files missing.

ALTER DATABASE   MOUNT
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/fast_recovery_area/db1/control02.ctl'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/oradata/db1/control01.ctl'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-205 signalled during: ALTER DATABASE   MOUNT...

Step 5. Now again shutdown the database and startup the database in nomount mode.

SQL> shut immediate;
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.

Total System Global Area  413372416 bytes
Fixed Size                  2253784 bytes
Variable Size             314575912 bytes
Database Buffers           88080384 bytes
Redo Buffers                8462336 bytes
SQL>

Step 6. Run following command to create control file.

SQL> CREATE CONTROLFILE REUSE DATABASE "DB1" RESETLOGS NOARCHIVELOG
  2      MAXLOGFILES 16
  3      MAXLOGMEMBERS 3
    MAXDATAFILES 100
  4      MAXINSTANCES 8
  5      MAXLOGHISTORY 292
  6  LOGFILE
  7    GROUP 1 '/u01/app/oracle/oradata/db1/redo01.log'  SIZE 50M,
  8    GROUP 2 '/u01/app/oracle/oradata/db1/redo02.log'  SIZE 50M,  ,
  9    GROUP 3 '/u01/app/oracle/oradata/db1/redo03.log'  SIZE 50M,
 10  DATAFILE
 11   12    '/u01/app/oracle/oradata/db1/example01.dbf',
 13    '/u01/app/oracle/oradata/db1/srcdata01.dbf',
 14    '/u01/app/oracle/oradata/db1/sysaux01.dbf',
 15    '/u01/app/oracle/oradata/db1/system01.dbf',
 16    --'/u01/app/oracle/oradata/db1/temp01.dbf',
 17    '/u01/app/oracle/oradata/db1/trgdata01.dbf',
 18    '/u01/app/oracle/oradata/db1/undotbs01.dbf',
 19    '/u01/app/oracle/oradata/db1/users01.dbf'
 20  CHARACTER SET WE8MSWIN1252;

Control file created.

SQL>
SQL> alter database open resetlogs;

Database altered.

SQL>

You can see that all control files and redo log files has been created.

/u01/app/oracle/fast_recovery_area/db1
[oracle@linux1 db1]$ ll
total 9840
-rw-r----- 1 oracle oinstall 10076160 Jan 17 03:35 control02.ctl
[oracle@linux1 db1]$

[oracle@linux1 db1]$ cd ../..
[oracle@linux1 oracle]$ cd oradata/db1/
[oracle@linux1 db1]$ ll
total 2076740
-rw-r-----  1 oracle oinstall  10076160 Jan 17 03:36 control01.ctl
-rw-r-----. 1 oracle oinstall 362422272 Jan 17 03:34 example01.dbf
-rw-r-----  1 oracle oinstall  52429312 Jan 17 03:36 redo01.log
-rw-r-----  1 oracle oinstall  52429312 Jan 17 03:34 redo02.log
-rw-r-----  1 oracle oinstall  52429312 Jan 17 03:34 redo03.log
-rw-r-----. 1 oracle oinstall  52436992 Jan 17 03:34 srcdata01.dbf
-rw-r-----. 1 oracle oinstall 587210752 Jan 17 03:34 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 807411712 Jan 17 03:34 system01.dbf
-rw-r-----. 1 oracle oinstall  20979712 Jan 17 02:41 temp01.dbf
-rw-r-----. 1 oracle oinstall  52436992 Jan 17 03:34 trgdata01.dbf
-rw-r-----. 1 oracle oinstall  68165632 Jan 17 03:34 undotbs01.dbf
-rw-r-----. 1 oracle oinstall   9183232 Jan 17 03:34 users01.dbf
[oracle@linux1 db1]$

The database opened successfully. The only point to consider is that of the data loss the data in the redo log files,






Thursday, 15 January 2015

Dataguard Configuration from RAC to RAC database

Primary Site:
Physical IPs: 192.168.1.1 , 192.168.1.2
VIPs:            192.168.1.3 , 192.168.1.4
DB_Unique_Name: racdb

Standby Site:
Physical IPs: 192.168.2.1 , 192.168.2.2
VIPs:            192.168.2.3 , 192.168.2.4
DB_Unique_Name: racdr

##########################################
Steps on Production/Primary Server

1- Modify or add dataguard related init Parameters on production:

alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(racdb,racdr)' scope=both sid='*';
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=racdb' scope=both sid='*';

alter system set LOG_ARCHIVE_DEST_2='SERVICE=racdr LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=racdr' scope=both sid='*';


alter system set log_archive_format='%t_%s_%r.arc' scope=spfile sid='*';
alter system set log_archive_max_processes=8 scope=both sid='*';
alter system set fal_server=racdr scope=both sid='*';   ----FAL server (typically this is the database running in the primary role).
alter system set FAL_Client='racdb' scope=both sid='*';
alter system set standby_file_management=AUTO scope=both sid='*';
alter system set db_file_name_convert='+DATA/racdb/','+DATA/racdr/' scope=spfile sid='*';
alter system set log_file_name_convert='+DATA/racdb/','+DATA/racdr/' scope=spfile sid='*';


2- Enable Archivelog Mode:

srvctl stop database -d racdb
startup mount                      ----(only one instance)
alter database archivelog;
alter database force logging;
alter database open;
srvctl start database -d racdb  ----This will start the remaining Instances on the cluster.


3- Tns Entries on all servers (copy these entires on both nodes of standby server),
Note that add new entries with VIP instead of scan name:

racdb =
  (DESCRIPTION=(FAILOVER=ON)(LOAD_BALANCE=ON)
    (ADDRESS= (PROTOCOL=TCP)(HOST=192.168.1.3)(PORT=1521))
    (ADDRESS= (PROTOCOL=TCP)(HOST=192.168.1.4)(PORT=1521))
    (CONNECT_DATA= (SERVER = DEDICATED)(FAILOVER_MODE=(TYPE=select)(METHOD=basic))
      (SERVICE_NAME=racdb)))


racdr =
  (DESCRIPTION=(FAILOVER=ON)(LOAD_BALANCE=ON)
    (ADDRESS= (PROTOCOL=TCP)(HOST=192.168.2.3)(PORT=1521))
    (ADDRESS= (PROTOCOL=TCP)(HOST=192.168.2.4)(PORT=1521))
    (CONNECT_DATA= (SERVER = DEDICATED)(FAILOVER_MODE=(TYPE=select)(METHOD=basic))
      (SERVICE_NAME=racdr)))


4- Create the Standby Redo Logs (SRLs) on Primary and Standby:
alter system set standby_file_management=manual scope=both sid='*';

alter database add standby logfile thread 1 group 1 '+DATA/racdb/onlinelog/standbyredo1.log' size 52M;
alter database add standby logfile thread 2 group 1 '+DATA/racdb/onlinelog/standbyredo2.log' size 52M;
alter database add standby logfile thread 1 group 2 '+DATA/racdb/onlinelog/standbyredo3.log' size 52M;
alter database add standby logfile thread 2 group 2 '+DATA/racdb/onlinelog/standbyredo4.log' size 52M;
alter database add standby logfile thread 1 group 3 '+DATA/racdb/onlinelog/standbyredo5.log' size 52M;
alter database add standby logfile thread 2 group 3 '+DATA/racdb/onlinelog/standbyredo6.log' size 52M;

alter system set standby_file_management=auto scope=both sid='*';

5- Copy password file to standby nodes.
scp $ORACLE_HOME/dbs/orapwracdb1 oracle@192.168.2.1:/u01/app/oracle/product/11.2.0/dbhome_1/dbs

scp $ORACLE_HOME/dbs/orapwracdb1 oracle@192.168.2.2:/u01/app/oracle/product/11.2.0/dbhome_1/dbs

created password file on production and copied and renamed it with standby database name(orapwracdr1) on both nodes. we do not need to create password file in the standby server.

6- Backup Primary DB:
rman target /
sql "alter system switch logfile";
BACKUP AS COMPRESSED BACKUPSET DATABASE format '/u01/app/oracle/backup/rman_%n_%T_%s_%p.bk' tag 'FORSTANDBY';
BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/u01/app/oracle/backup/ForStandbyCTRL.bck';

7- Compressed the backup folder:
tar -zcvf backup.tar.gz /u01/app/oracle/backup

8- Copy Compressed backup directory to Standby:
scp -r backup.tar.gz oracle@192.168.2.1:/u01/app/oracle/

Steps on Standby Server

9- Modify/add follwoing parameters on Standby site:
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(racdb,racdr)' scope=both sid='*';
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=racdb' scope=both sid='*';

alter system set LOG_ARCHIVE_DEST_2='SERVICE=racdr LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=racdr' scope=both sid='*';


alter system set log_archive_format='%t_%s_%r.arc' scope=spfile sid='*';
alter system set log_archive_max_processes=8 scope=both sid='*';
alter system set fal_server=racdb scope=both sid='*';
alter system set FAL_Client='racdr' scope=both sid='*';
alter system set standby_file_management=AUTO scope=both sid='*';
alter system set db_file_name_convert='+DATA/racdb/','+DATA/racdr/' scope=spfile sid='*';
alter system set log_file_name_convert='+DATA/racdb/','+DATA/racdr/' scope=spfile sid='*';

9- Un-compressed the backup folder:
tar -zxvf backup.tar.gz -C /u01/app/oracle/

10- Start Standby in no mount mode:
srvctl stop database -d racdr
startup nomount   -----one instance

11- Connect to rman on standby server and restore the backup:
rman target /

11.1- Restore controlfile and mount the database:
restore standby controlfile from '/u01/app/oracle/backup/ForStandbyCTRL.bck';
sql 'alter database mount standby database';

11.2- Now restore the database backup:
run {
ALLOCATE CHANNEL c1 DEVICE TYPE DISK ;
restore database;
switch datafile all ;
}


12-  Open the database in read only mode:
alter database open read only;

13-  Start active recovery on standby database:
recover managed standby database cancel;   ---if media recovery already running
recover managed standby database disconnect using current logfile;

14- Check dataguard status
select status, error from v$archive_dest where dest_id=2;
select name,open_mode,db_unique_name,database_role,protection_mode from v$database;

15- On the primary server, check the latest archived redo log and force a log switch:
ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';
SELECT sequence#, first_time, next_time FROM v$archived_log ORDER BY sequence#;
ALTER SYSTEM SWITCH LOGFILE;

16- Check the new archived redo log has arrived at the standby server and been applied:
ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';
SELECT sequence#, first_time, next_time, applied FROM v$archived_log ORDER BY sequence#;
SELECT sequence#, to_char(first_time,'dd-mon-yy hh:mi:ss am'), next_time, applied FROM v$archived_log ORDER BY sequence#;


Wednesday, 14 January 2015

Restore RMAN Backup on other Machine having Different Physical Structure/database migration


Restore RMAN Backup on other Machine having Different Physical Structure:
following documentation is a step by step guide and can be used for to restore rman backup on other machine with different directories structure or database migration from one server to other or database version migration from 64/32 bit to 32/64 bit.

Source machine:
OS: Windows Server 2012
Database: Oracle 11.2.0.2.0

Target machine:
OS: Windows Server 2012
Database: Oracle 11.2.0.2.0
-------------------------------------------------------------------------------
Steps:

1.1- Create Required Directories:
Create required directories on target machine.

1.2- Copy Pfile from source:
create pfile='d"\pfile.ora' from spfile;

1.3- Copy this pfile to target and start database in nomount state from this pfile:
startup nomount pfile='d'\pfile.ora';

1.4- Set DBID:
set dbid=1275888

1.5- Restore control File:
restore controlfile from 'D:\test\control_ORCL_2m9KC0e_92';

1.6- Mount Database:
alter database mount;

1.7- Generating the SET NEWNAME command:
Generating the SET NEWNAME command for each tempfile in the database using below script:
select 'set newname for datafile '||file_id||' to '''||'+DATA'||''';' from dba_data_files;

1.8- RMAN Block to rename Datafiles and restore database:
RUN
{
SET NEWNAME FOR DATAFILE 1 TO 'D:\app\Administrator\oradata\ORCL\SYSTEM01.DBF';
SET NEWNAME FOR DATAFILE 2 TO 'D:\app\Administrator\oradata\ORCL\SYSAUX01.DBF';
SET NEWNAME FOR DATAFILE 3 TO 'D:\app\Administrator\oradata\ORCL\UNDOTBS01.DBF';
SET NEWNAME FOR DATAFILE 4 TO 'D:\app\Administrator\oradata\ORCL\USERS01.DBF';
SET NEWNAME FOR DATAFILE 5 TO 'D:\app\Administrator\oradata\ORCL\EXAMPLE01.DBF';
SET NEWNAME FOR DATAFILE 6 TO 'D:\app\Administrator\oradata\ORCL\APP_USER1.DBF';
SET NEWNAME FOR DATAFILE 7 TO 'D:\app\Administrator\oradata\ORCL\APP_USER2.DBF';
SET NEWNAME FOR DATAFILE 8 TO 'D:\app\Administrator\oradata\ORCL\APP_USERS_INDEXES.DBF';
SQL "ALTER DATABASE RENAME FILE ''S:\app\Administrator\oradata\ORCL\redo01.log''
      TO ''D:\app\Administrator\oradata\ORCL\redo01.log'' ";
SQL "ALTER DATABASE RENAME FILE ''S:\app\Administrator\oradata\ORCL\redo02.log''
      TO ''D:\app\Administrator\oradata\ORCL\redo02.log'' ";
SQL "ALTER DATABASE RENAME FILE ''S:\app\Administrator\oradata\ORCL\redo03.log''
      TO ''D:\app\Administrator\oradata\ORCL\redo03.log'' ";
  # Do a SET UNTIL to prevent recovery of the online logs
  #set until time "to_date('2011-13-04:11:40:00', 'yyyy-dd-mm:hh24:mi:ss')";
  # restore the database and switch the datafile names
  RESTORE DATABASE;
  SWITCH DATAFILE ALL;
  # recover the database
  RECOVER DATABASE;
}


----------------------------------Output of RMAN command-------------------

RMAN-00571: ========================================
RMAN-00569: ==== ERROR MESSAGE STACK FOLLOWS =====
RMAN-00571: ========================================
RMAN-03002: failure of recover command at 01/25/2004 15:59:41
RMAN-06054: media recovery requesting unknown log: thread 1 scn 140830

-------------------------------------------------------------------------------
1.9- Resolving of this issue:

First shutdown the database.
shu immediate;
startup database;
then open database with resetlogs
alter database open resetlogs;

Your database successfully migrated from one machine to other with different directories structure.
-------------------------------------------------------------------------------
Convert DB from 64Bit to 32Bit or vice versa
If you want to migrate from a 64/32 bit machine to 32/64 bit then follow all above steps and also use following extra steps
-------------------------------------------------------------------------------
 2.1- Resoloving virsion problem:
SHUTDOWN IMMEDIATE;

2.2- Startup database with upgrade option
startup upgrade;

2.3- Now run do following steps

1) startup upgrade;
2) @?/rdbms/admin/utlirp.sql
3) shutdown immediate;
4) startup;
5) drop user QCSITEADMIN_DB0 cascade;
6) shutdown immediate;
7) startup upgrade;
8) @?/rdbms/admin/utlirp.sql
9) shutdown immediate;
10) startup;

 Now database successfully migrated between different version.



Convert and Migrate Single Instance to RAC

For getting detail documentation and step by step guide please go to following links.

http://allthingsoracle.com/convert-single-instance-to-rac-part-1-duplicate-db-using-rman/

http://allthingsoracle.com/convert-single-instance-to-rac-part-2-manually-convert-to-rac/

Friday, 20 December 2013

Script to Disable All Constraint of a User (Scott)

begin
for i in (select constraint_name, table_name from user_constraints) LOOP
execute immediate 'alter table '||i.table_name||' ENABLE constraint '||i.constraint_name||'';
end loop;
end;
/



begin
  for cur in (select owner, constraint_name , table_name
    from all_constraints
     where owner = 'SCOTT' ) loop
     execute immediate 'ALTER TABLE '||cur.owner||'.'||cur.table_name||' MODIFY CONSTRAINT "'||
cur.constraint_name||'" ENABLE NOVALIDATE ';
  end loop;
end;



begin
  for cur in (select fk.owner, fk.constraint_name , fk.table_name
    from all_constraints fk, all_constraints pk
     where fk.CONSTRAINT_TYPE = 'R' and
           pk.owner = 'SCOTT' and
           fk.r_owner = pk.owner and
           fk.R_CONSTRAINT_NAME = pk.CONSTRAINT_NAME )
           loop
    execute immediate 'ALTER TABLE "'||cur.owner||'"."'||cur.table_name||'" MODIFY CONSTRAINT "'||
cur.constraint_name||'" ENABLE NOVALIDATE';
  end loop;
end;

Tuesday, 25 June 2013

Steps to Restore RMAN Backup on other Machine having Different Physical Structure

------------------------------------------------------------------------------------------------------
Steps to Restore RMAN Backup on other Machine having Different Physical Structure
------------------------------------------------------------------------------------------------------
------------------------Create Required Directories---------------------------------------------------
---------------------------Copy Pfile from source----------------------------------------------------

create pfile='d"\pfile.ora' from spfile;

Copy this pfile to target and start Database in nomount state from this pfile.

startup nomount pfile='d'\pfile.ora';
------------------------------------------------------------------------------------------------------
-------------------------------------Set DBID---------------------------------------------------------

 set dbid=1275888
------------------------------------------------------------------------------------------------------
------------------------------Restore control File----------------------------------------------------

restore controlfile from 'D:\test\control_ORCL_2m9KC0e_92';

------------------------------------------------------------------------------------------------------
------------------------------Mount Database----------------------------------------------------------

alter database mount;

------------------------------------------------------------------------------------------------------
----------------RMAN Block to rename Datafiles and restore database-----------------------------------
RUN
{
SET NEWNAME FOR DATAFILE 1 TO 'D:\app\Administrator\oradata\ORCL\SYSTEM01.DBF';
SET NEWNAME FOR DATAFILE 2 TO 'D:\app\Administrator\oradata\ORCL\SYSAUX01.DBF';
SET NEWNAME FOR DATAFILE 3 TO 'D:\app\Administrator\oradata\ORCL\UNDOTBS01.DBF';
SET NEWNAME FOR DATAFILE 4 TO 'D:\app\Administrator\oradata\ORCL\USERS01.DBF';
SET NEWNAME FOR DATAFILE 5 TO 'D:\app\Administrator\oradata\ORCL\EXAMPLE01.DBF';
SET NEWNAME FOR DATAFILE 6 TO 'D:\app\Administrator\oradata\ORCL\EPARS_MSG_COMM_FBR.DBF';
SET NEWNAME FOR DATAFILE 7 TO 'D:\app\Administrator\oradata\ORCL\EPARS_TCH_APP_FBR.DBF';
SET NEWNAME FOR DATAFILE 8 TO 'D:\app\Administrator\oradata\ORCL\EPARS_INDEXES.DBF';
SQL "ALTER DATABASE RENAME FILE ''S:\app\Administrator\oradata\ORCL\redo01.log''
      TO ''D:\app\Administrator\oradata\ORCL\redo01.log'' ";
  SQL "ALTER DATABASE RENAME FILE ''S:\app\Administrator\oradata\ORCL\redo02.log''
      TO ''D:\app\Administrator\oradata\ORCL\redo02.log'' ";
SQL "ALTER DATABASE RENAME FILE ''S:\app\Administrator\oradata\ORCL\redo03.log''
      TO ''D:\app\Administrator\oradata\ORCL\redo03.log'' ";
  # Do a SET UNTIL to prevent recovery of the online logs
  #set until time "to_date('2011-13-04:11:40:00', 'yyyy-dd-mm:hh24:mi:ss')";
  # restore the database and switch the datafile names
  RESTORE DATABASE;
  SWITCH DATAFILE ALL;
  # recover the database
  RECOVER DATABASE;
}
------------------------------------------------------------------------------------------------------
----------------------------------Output of RMAN command---------------------------------------------

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/25/2004 15:59:41
RMAN-06054: media recovery requesting unknown log: thread 1 scn 140830

------------------------------------------------------------------------------------------------------
------------------------------Resolving of this issue-------------------------------------------------

First down the DB.
startup database
then open database with resetlogs
------------------------------------------------------------------------------------------------------
----------------------------------Down the Database---------------------------------------------------

shutdown immediate;
-------------------------------------------------------------------------------------------------------
---------------------------------Startup database------------------------------------------------------

startup;
-------------------------------------------------------------------------------------------------------
-----------------------------------Open database with resetlogs----------------------------------------

alter database open resetlogs;
--------------------------------------------------------------------------------------------------------
------------------------------------Resoloving virsion problem------------------------------------------

If you convert DB from 64Bit to 32Bit then use following steps

--------------------------------------------------------------------------------------------------------

SHUTDOWN IMMEDIATE;

--------------------------------------------------------------------------------------------------------
--------------------------------------Startup database with upgrade option------------------------------

startup upgrade;

--------------------------------------------------------------------------------------------------------
-----------------------------------------Now run do following steps-------------------------------------

1) startup upgrade;
2) @?/rdbms/admin/utlirp.sql
3) shutdown immediate;
4) startup;
5) drop user QCSITEADMIN_DB0 cascade;
6) shutdown immediate;
7) startup upgrade;
8) @?/rdbms/admin/utlirp.sql
9) shutdown immediate;
10) startup;
---------------------------------------------------------------------------------------------------------
----------------------------------------------END--------------------------------------------------------



Sunday, 26 May 2013

Oracle 11gR2 Grid Infrastructure implementation for Real Application Cluster (RAC)

Requirements:
OS:RedHat Enterprise Linux 5 on all machines participating in the setup.
DB: Oracle 11g R2
To be consistent with the rest of the article, the following information should be set during the installation:

RAC1:
 Hostname: trnbank4
IP Address eth0: 10.40.0.147 (public address)
IP Address eth1: 172.16.100.147(private address)
RAC2:
Hostname: trnbank5
IP Address eth0: 10.40.0.148 (public address)
IP Address eth1: 172.16.100.148 (private address)

Media Required:
·         Oracle 11gR2 Grid Infrastructure need for Cluster Installation.
·         Oracle 11gR2 media is required for Oracle Database Installation.
·         Oracle ASM RPM required for ASM configuration.

SAN Storage:
We use 100GB Share Storage on rac1 and rac2 machines.
·         2 Partition of 20 GB for Data Disk group.
·         2 Partition of 20 GB for FRA Disk group.
·         3 Partition of 2.5 GB for VOTING Disk group.

SCAN Configration:
The Single Client Access Name (SCAN) should really be defined in the DNS or GNS and round-robin between one of 3 addresses, which are on the same subnet as the public and virtual IPs. In this article I've defined it as a single IP address in the "/etc/hosts" file, which is wrong and will cause the cluster verification to fail, but it allows me to complete the install without the presence of a DNS.

Note:
1. Swap Space should be 2 time of RAM size.
2. There should be two ethernet cards (eth0 for Public and eth1 for Private interconnectivity).
3. On Root shoud be at least of 30Gb free Space.
4. Three Voting Disks with minimum of 2Gb space and Voting Disk Group with normal redundancy.
5. Public and virtual IP addresses must be on the same subnet.
Public and Private IP subnet should be different.

Oracle Installation Prerequisites

Note: In the entire text in this document, “All nodes” means all two machines as described in the setup above. “All RAC nodes” are (obviously) only RAC nodes, (obviously) excluding the storage machine.

Step: RPM Installation

Once the basic installation is complete, install the following packages whilst logged in as the root user. This includes the 64-bit and 32-bit versions of some packages.

yum install binutils-2.17.50.0.6 compat-libstdc++-33-3.2.3 compat-libstdc++-33-3.2.3   elfutils-libelf-0.125  elfutils-libelf-devel-0.125  elfutils-libelf-devel static-0.125 gcc-4.1.2 gcc-c++-4.1.2 glibc-2.5-24 glibc-2.5-24   glibc-common-2.5 glibc-devel-2.5 glibc-devel-2.5   glibc-headers-2.5 ksh-20060214 libaio-0.3.106 libaio-0.3.106   libaio-devel-0.3.106 libaio-devel-0.3.106   libgcc-4.1.2 libgcc-4.1.2libstdc++-4.1.2 libstdc++-4.1.2   libstdc++-devel 4.1.2 make-3.81 pdksh-5.2.14 sysstat-7.0.2 unixODBC-2.2.11 unixODBC-2.2.11   unixODBC-devel-2.2.11  unixODBC-devel-2.2.11


Configure Name Resolution

DNS is configured to resolve the following. However, local /etc/hosts is also configured, in case DNS becomes un-available for whatever reasons.


All nodes:
If you are not using DNS, the "/etc/hosts" file must contain the following information.

~]# vi /etc/hosts

127.0.0.1       localhost.localdomainlocalhost

# Public Network - (eth0)
10.40.0.147    trnbank4           trnbank4
10.40.0.148    trnbank5           trnbank5

# Private Interconnect - (eth1)
172.16.100.147    trnbank4-priv      trnbank4-priv
172.16.100.148    trnbank5-priv      trnbank5-priv

# Public Virtual IP (VIP) addresses - (eth0:1)
10.40.0.149    trnbank4-vip       trnbank4-vip
10.40.0.150    trnbank5-vip       trnbank5-vip

# SCAN
10.40.0.155   rac-scan    rac-scan

Set Resource Limits for Oracle Sofware Installation Users

Step:
Add or amend the following lines to the "/etc/sysctl.conf" file
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_default=262144
net.core.wmem_max=1048586

Run the following command to change the current kernel parameters.
/sbin/sysctl -p

Add the following lines to the "/etc/security/limits.conf" file.
oracle               soft    nproc   2047
oracle               hard    nproc   16384
oracle               soft    nofile  1024
oracle               hard    nofile  65536
Add the following lines to the "/etc/pam.d/login" file, if it does not already exist.
session    required     pam_limits.so
Disable secure linux by editing the "/etc/selinux/config" file, making sure the SELINUX flag is set as follows.
SELINUX=disabled

Alternatively, this alteration can be done using the GUI tool (System > Administration > Security Level and Firewall). Click on the SELinux tab and disable the feature.

Configure Cluster Time Synchronization Service - (CTSS)

Either configure NTP, or make sure it is not configured so the Oracle Cluster Time Synchronization Service (ctssd) can synchronize the times of the RAC nodes. In this case we will deconfigure NTP.
# servicentpd stop
Shutting down ntpd:                                        [  OK  ]
# chkconfigntpd off
# mv /etc/ntp.conf /etc/ntp.conf.org
# rm /var/run/ntpd.pid

Start the Name Service Cache Daemon (nscd).
chkconfig --level 35 nscd on
servicenscd start

Create Groups and User for Grid Infrastructure

Create the new groups and users.
groupadd -g 1000 oinstall
groupadd -g 1200 dba
groupadd -g 1400 asmadmin
groupadd -g 1600 asmdba
useradd -u 1100 -g oinstall -G dba,asmadmin,asmdba oracle
passwd oracle

Create Required Directories

On both RAC1 and RAC2 create the directories in which the Oracle software will be installed.
mkdir -p /u01/app/11.2.0/grid
mkdir -p /u01/app/oracle/product/11.2.0/db_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01

Create Login Profile for oracle User Account

Login as the oracle user and add the following lines at the end of the .bash_profile file for rac1.

#####################################################
#Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=trnbank4; export ORACLE_HOSTNAME
ORACLE_UNQNAME=racdb; export ORACLE_UNQNAME
GRID_HOME=/u01/app/11.2.0/grid; export GRID_HOME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=racdb1; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
PATH=$GRID_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
#####################################################

Login as the oracle user and add the following lines at the end of the .bash_profile file for rac2.

#####################################################
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=trnbank5; export ORACLE_HOSTNAME
ORACLE_UNQNAME=racdb; export ORACLE_UNQNAME
GRID_HOME=/u01/app/11.2.0/grid; export GRID_HOME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=racdb2; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
PATH=$GRID_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
#####################################################

Create Partitions on SAN Storage

Used the Linux fdisk command to create the logical partitions:
[root@trnbank4 ~]# fdisk –l
 
Now create logical partition on un-partitioned SAN disks.
 
[root@11gR2Base ~]# fdisk /dev/sdb
[root@11gR2Base ~]# partprobe
[root@trnbank4 ~]# fdisk –l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        5221    41833260   8e  Linux LVM

Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2610    20964793+  83  Linux

And create the remaining logical partitions like this.

Install and Configure ASMLib

[root@trnbank4 Oracleasm_Lib-RHEL5-64]# pwd
/backup/Oracleasm_Lib-RHEL5-64
[root@trnbank4 Oracleasm_Lib-RHEL5-64]# ls
oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm
oracleasm-2.6.18-194.el5debug-2.0.5-1.el5.x86_64.rpm
oracleasm-2.6.18-194.el5-debuginfo-2.0.5-1.el5.x86_64.rpm
oracleasm-2.6.18-194.el5xen-2.0.5-1.el5.x86_64.rpm
oracleasmlib-2.0.4-1.el5.x86_64.rpm
oracleasm-support-2.1.4-1.el5.x86_64.rpm

[root@trnbank4 Oracleasm_Lib-RHEL5-64]# rpm -Uvhoracleasm*
[root@trnbank4 ~]#rpm -qa | greporacleasm
[root@trnbank4 ~]#/etc/init.d/oracleasm configure -i
Configuring the Oracle ASM library driver.
 
This will configure the on-boot properties of the Oracle ASM library
driver.  The following questions will determine whether the driver is
loaded on boot and what permissions it will have.  The current values
will be shown in brackets ('[]').  Hitting <ENTER> without typing an
answer will keep that current value.  Ctrl-C will abort.
 
Default user to own the driver interface []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration:           [  OK  ]
Loading module "oracleasm":                                [  OK  ]
Mounting ASMlib driver filesystem:                         [  OK  ]
Scanning system for ASM disks:                             [  OK  ]
 
[root@11gR2Base ~]# /etc/init.d/oracleasm status
Checking if ASM is loaded:                                 [  OK  ]
Checking if /dev/oracleasm is mounted:                     [  OK  ]

Create ASM Disks for Oracle

[root@trnbank4 ~]# fdisk –l

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        5221    41833260   8e  Linux LVM
 
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2610    20964793+  83  Linux
 
Disk /dev/sdc: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        2610    20964793+  83  Linux
 
Disk /dev/sdd: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1        2610    20964793+  83  Linux
 
Disk /dev/sde: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1        2610    20964793+  83  Linux
 
Disk /dev/sdf: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1               1         317     2546271   83  Linux
/dev/sdf2             318         634     2546302+  83  Linux
 
Disk /dev/sdg: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1               1         317     2546271   83  Linux
/dev/sdg2             318         634     2546302+  83  Linux
 
[root@trnbank4 ~]#/etc/init.d/oracleasmcreatedisk DATA01 /dev/sdb1
[root@trnbank4 ~]#/etc/init.d/oracleasmcreatedisk DATA02 /dev/sdc1
[root@trnbank4 ~]#/etc/init.d/oracleasmcreatediskFRA01/dev/sdd1
[root@trnbank4 ~]#/etc/init.d/oracleasmcreatediskFRA02/dev/sde1
[root@trnbank4 ~]#/etc/init.d/oracleasmcreatediskVOT01/dev/sdf1
[root@trnbank4 ~]#/etc/init.d/oracleasmcreatediskVOT02/dev/sdg1
[root@trnbank4 ~]# /etc/init.d/oracleasmcreatedisk VOT01 /dev/sdf1
[root@trnbank4 ~]# /etc/init.d/oracleasmcreatedisk VOT02 /dev/sdf2
[root@trnbank4 ~]# /etc/init.d/oracleasmcreatedisk VOT03 /dev/sdg1
[root@trnbank4 ~]# /etc/init.d/oracleasmcreatedisk VOT04 /dev/sdg2
[root@trnbank4 ~]#/etc/init.d/oracleasmlistdisks
DATA01
DATA02
FRA01
FRA02
VOT01
VOT02
VOT03
VOT04

Also check on node 2
[root@trnbank5 ~]#/etc/init.d/oracleasmlistdisks
DATA01
DATA02
FRA01
FRA02
VOT01
VOT02
VOT03
VOT04

Install the cvuqdisk Package for Linux

Install the operating system package cvuqdisk to both Oracle RAC nodes. Without cvuqdisk, Cluster Verification Utility cannot discover shared disks, and you will receive the error message "Package cvuqdisk not installed" when the Cluster Verification Utility is run (either manually or at the end of the Oracle grid infrastructure installation). Use the cvuqdisk RPM for your hardware architecture (for example, x86_64 or i386).
The cvuqdisk RPM can be found on the Oracle grid infrastructure installation media in the rpm directory.
 
# Install the following package from the Oracle grid media.
[oracle@trnbank4 rpm]$ pwd
/u01/media/Oracle-DataGrid-11gR2/rpm
[oracle@trnbank4 rpm]$ ls
cvuqdisk-1.0.7-1.rpm
[oracle@trnbank4 rpm]$ rpm -Uvhcvuqdisk*


Shut down un-necessary services on all nodes: (Some of the below)

chkconfig --level 35 sendmail off
chkconfig --level 35 pcmcia off
chkconfig --level 35 cups off
chkconfig --level 35 hpoj off
chkconfig --level 35 iptables off
chkconfig --level 35 exim off
chkconfig --level 35 postfix off
chkconfig --level 35 FreeWnn off
chkconfig --level 35 httpd off
chkconfig --level 35 rhnsd off
chkconfig --level 35 smartd off
chkconfig --level 35 canna off
chkconfig --level 35 iiim off

Configuring Passwordless SSH on Cluster Nodes

To configure passwordless SSH, complete the following on both Oracle RAC nodes.
[root@trnbank4 ~]#su – oracle
[root@trnbank5 ~]#su – oracle
[oracle@trnbank4 ~]#mkdir ~/.ssh
[oracle@trnbank5 ~]#mkdir ~/.ssh
[oracle@trnbank4 ~]#chmod 700 ~/.ssh
[oracle@trnbank4 ~]#chmod 700 ~/.ssh
[oracle@trnbank4 ~]#/usr/bin/ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_dsa): [Enter]
Enter passphrase (empty for no passphrase): [Enter]
Enter same passphrase again: [Enter]
Your identification has been saved in /home/oracle/.ssh/id_dsa.
Your public key has been saved in /home/oracle/.ssh/id_dsa.pub.
The key fingerprint is:
57:21:d7:d5:54:29:4c:12:40:23:36:e9:6e:2f:e6:40 oracle@trnbank4
[oracle@trnbank5 ~]#/usr/bin/ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_dsa): [Enter]
Enter passphrase (empty for no passphrase): [Enter]
Enter same passphrase again: [Enter]
Your identification has been saved in /home/oracle/.ssh/id_dsa.
Your public key has been saved in /home/oracle/.ssh/id_dsa.pub.
The key fingerprint is:
58:25:d7:d5:54:29:4c:12:40:23:36:e9:6e:2f:e6:90 oracle@trnbank5
[oracle@trnbank4 ~]#touch ~/.ssh/authorized_keys
[oracle@trnbank5 ~]#touch ~/.ssh/authorized_keys
[oracle@trnbank4 ~]#ls -l ~/.ssh
[oracle@trnbank4 ~]#ls -l ~/.ssh
[oracle@trnbank4 ~]#ssh trnbank4 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[oracle@trnbank4 ~]#ssh trnbank5 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[oracle@trnbank4 ~]#ls -l ~/.ssh
[oracle@trnbank4 ~]#scp ~/.ssh/authorized_keys trnbank5:.ssh/authorized_keys
[oracle@trnbank4 ~]#chmod 600 ~/.ssh/authorized_keys
[oracle@trnbank5 ~]#chmod 600 ~/.ssh/authorized_keys
If SSH is configured correctly, you will be able to use the ssh and scp commands without being prompted for a password or pass phrase from the terminal session:
[oracle@trnbank4 ~]#ssh trnbank4 "date;hostname"
[oracle@trnbank4 ~]#ssh trnbank5 "date;hostname"
[oracle@trnbank5 ~]#ssh trnbank4 "date;hostname"
[oracle@trnbank5 ~]#ssh trnbank5 "date;hostname"

Verify Oracle Clusterware Requirements with CVU- (optional)

[oracle@trnbank4 ~]#cd /u01/media/Oracle-DataGrid-11gR2/
[oracle@trnbank4 ~]#./runcluvfy.sh stage -pre crsinst -fixup -n trnbank4,trnbank5 -verbose

Install Oracle Grid Infrastructure for a Cluster

[oracle@trnbank4 ~]$ cd /u01/media/Oracle-DataGrid-11gR2/
[oracle@trnbank4 Oracle-DataGrid-11gR2]$ ls
[oracle@trnbank4 Oracle-DataGrid-11gR2]$ ./runInstaller





Click on Add to add second cluster Node.


Configure the SSH Connectivity if not configured and also Test it.












Post-installation Tasks for Oracle Grid Infrastructure for a Cluster

Run Scripts on both nodes as root user.
[oracle@trnbank4 ~]$ /u01/app/oraInventory/orainstRoot.sh
[oracle@trnbank5 ~]$ /u01/app/oraInventory/orainstRoot.sh
[oracle@trnbank4 ~]# /u01/app/11.2.0/grid/root.sh
 
[oracle@trnbank5 ~]# /u01/app/11.2.0/grid/root.sh

 
After successful root scrip execution Click on Ok.

Verify Oracle Clusterware Installation

Check CRS Status

[oracle@trnbank4 ~]$ crsctl check crs
CRS-4638: Oracle High Availability Services is online
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online

Check Clusterware Resources

[oracle@trnbank4 ~]$ crs_stat -t –v

Check Cluster Nodes

[oracle@trnbank4 ~]$ olsnodes -n
trnbank4        1
trnbank5        2

Check Oracle TNS Listener Process on Both Nodes

[oracle@trnbank4 ~]$ ps -ef | greplsnr | grep -v 'grep' | grep -v 'ocfs' | awk '{print $9}'
LISTENER
LISTENER_SCAN1

Confirming Oracle ASM Function for Oracle Clusterware Files

[oracle@trnbank4 ~]$ srvctl status asm -a
ASM is running on trnbank4,trnbank5
ASM is enabled.
[oracle@trnbank5 ~]$ srvctl status asm -a
ASM is running on trnbank4,trnbank5
ASM is enabled.

Check Oracle Cluster Registry (OCR)

[oracle@trnbank4 ~]$ ocrcheck
[oracle@trnbank5 ~]$ ocrcheck

Check Voting Disk

[oracle@trnbank4 ~]$ crsctl query cssvotedisk
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   0cb7d89cecd74fa5bf68fc4b24745e3e (ORCL:VOT01) [VOTING]
Located 1 voting disk(s).
[oracle@trnbank5 ~]$ crsctl query cssvotedisk
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   0cb7d89cecd74fa5bf68fc4b24745e3e (ORCL:VOT01) [VOTING]
Located 1 voting disk(s).

Check SCAN Resolution

[oracle@trnbank4 ~]$dig rac-scan
[oracle@trnbank5 ~]$dig rac-scan

Create ASM Disk Groups for Data and Fast Recovery Area

Create two additional DATA and FRA ASM disk groups as the oracle user:
[oracle@trnbank4 ~]$ asmca









Now Install Oracle 11gR2 Software only:

[oracle@trnbank4 ~]$ cd /u01/media/Oracle-Database-11gR2_Linux-64/
[oracle@trnbank4 Oracle-Database-11gR2_Linux-64]$ ls
doc  install  response  rpm  runInstallersshsetup  stage  welcome.html
[oracle@trnbank4 Oracle-Database-11gR2_Linux-64]$ ./runInstaller







Execute root.sh script on both nodes as root user.
[root@trnbank4 ~]# /u01/app/oracle/product/11.2.0/db_1/root.sh
[root@trnbank5 ~]# /u01/app/oracle/product/11.2.0/db_1/root.sh
Finish, Installation will completes.

Create the Oracle Cluster Database

[oracle@trnbank4 ~]$dbca&














When the DBCA has completed, you will have a fully functional Oracle RAC 11g release 2 cluster running!

Verify Oracle Grid Infrastructure and Database Configuration

[oracle@trnbank4 ~]$ crsctl check cluster
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online

All Oracle Instances - (Database Status)

[oracle@trnbank4 ~]$ srvctl status database -d racdb
Instance racdb1 is running on node trnbank4
Instance racdb2 is running on node trnbank5

Single Oracle Instance - (Status of Specific Instance)

[oracle@trnbank4 ~]$ srvctl status instance -d racdb -i racdb1
Instance racdb1 is running on node trnbank4
[oracle@trnbank5 ~]$ srvctl status instance -d racdb -i racdb2
Instance racdb2 is running on node trnbank5

Node Applications - (Status)

[oracle@trnbank4 ~]$ srvctl status nodeapps

List all Configured Databases

[oracle@trnbank4 ~]$ srvctlconfig database
racdb

ASM - (Status)

[oracle@trnbank4 ~]$ srvctl status asm
ASM is running on trnbank4,trnbank5

TNS listener - (Status)

[oracle@trnbank4 ~]$ srvctl status listener
Listener LISTENER is enabled
Listener LISTENER is running on node(s): trnbank4,trnbank5

SCAN - (Status)

[oracle@trnbank4 ~]$ srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node trnbank4

VIP - (Status of Specific Node)

[oracle@trnbank4 ~]$ srvctl status vip -n trnbank4
VIP trnbank4-vip is enabled
VIP trnbank4-vip is running on node: trnbank4

All running instances in the cluster - (SQL)

SQL> SELECT
inst_id
  , instance_numberinst_no
  , instance_nameinst_name
  , parallel
  , status
  , database_statusdb_status
  , active_state state
  , host_name host
FROM gv$instance
ORDER BY inst_id; 

INST_ID INST_NO  INST_NAME  PAR  STATUS   DB_STATUS   STATE    HOST
---------- ---------- ---------------- --- ------------ ----------------- 
1       1        racdb1    YES  OPEN  ACTIVE  NORMAL    trnbank4
2     2       racdb2   YES  OPEN      ACTIVE     NORMAL    trnbank5

ASM Disk Volumes - (SQL)

SQL> SELECT path
FROM   v$asm_disk; 

PATH
-----------------------------------------------------------------------------
ORCL:DATA01
ORCL:DATA02
ORCL:FRA01
ORCL:FRA02
ORCL:VOT01

Starting / Stopping the Cluster

Stopping the Oracle Clusterware Stack on the Local Server
[root@trnbank4 ~]#  /u01/app/11.2.0/grid/bin/crsctl stop cluster
[root@trnbank4 ~]# /u01/app/11.2.0/grid/bin/crsctl stop cluster –all

Starting the Oracle Clusterware Stack on the Local Server

Use the "crsctl start cluster" command on racnode1 to start the Oracle Clusterware stack:
[root@trnbank4 ~]# /u01/app/11.2.0/grid/bin/crsctl start cluster
[root@trnbank4 ~]# /u01/app/11.2.0/grid/bin/crsctl start cluster -all
You can also start the Oracle Clusterware stack on one or more named servers in the cluster by listing the servers separated by a space:
[root@trnbank4 ~]# /u01/app/11.2.0/grid/bin/crsctl start cluster -n trnbank4 trnbank5

Instance Start and Stop

[oracle@trnbank4 ~]# srvctl start instance -d racdb -i racdb1
[oracle@trnbank5 ~]# srvctl start instance -d racdb -i racdb2
[oracle@trnbank4 ~]# srvctl stop instance -d racdb -i racdb1
[oracle@trnbank5 ~]# srvctl stop instance -d racdb -i racdb2

Start/Stop All Instances with SRVCTL

Finally, you can start/stop all instances and associated services using the following:
[root@trnbank4 ~]# srvctl stop database -d racdb
[root@trnbank4 ~]# srvctl start database -d racdb

Tns Configuration for TAF
RACDB =
  (DESCRIPTION =
   (ENABLE=BROKEN)
   (FAILOVER=ON)
   (LOAD_BALANCE=ON)
   (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST=rac-scan)(PORT=1521)))
     (CONNECT_DATA =
      (SERVICE_NAME=racdb)
      (FAILOVER_MODE=(TYPE=SELECT)(METHOD=BASIC)(RETRIES=250)(DELAY=5)
)
    )
  )

-----------------------------------------------------------------End--------------------------------------------------------------------