Sunday, December 2, 2012

droping a standalone database using RMAN


[oracle@subhen-db01 dbs]$ echo $ORACLE_SID
RENAMEDB
[oracle@subhen-db01 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Mon Dec 3 14:41:07 2012

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 2355015680 bytes
Fixed Size                  2230592 bytes
Variable Size             536872640 bytes
Database Buffers         1795162112 bytes
Redo Buffers               20750336 bytes
Database mounted.
Database opened.
SQL> show parameter pfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATA01/renamedb/spfilerenamed
                                                 b.ora
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
***********************************************
Connect to RMAN to the intended database to be dropped
************************************************
[oracle@subhen-db01 dbs]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Mon Dec 3 14:41:47 2012

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: RENAMEDB (DBID=257482690)

RMAN> report schema
2> ;

using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name RENAMEDB

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    710      SYSTEM               ***     +DATA01/testdb/datafile/system.278.800725811
2    520      SYSAUX               ***     +DATA01/testdb/datafile/sysaux.394.800725811
3    75       UNDOTBS1             ***     +DATA01/testdb/datafile/undotbs1.838.800725811
4    5        USERS                ***     +DATA01/testdb/datafile/users.463.800725811

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    29       TEMP                 32767       +DATA01/testdb/tempfile/temp.555.800725895

RMAN> STARTUP FORCE MOUNT

Oracle instance started
database mounted

Total System Global Area    2355015680 bytes

Fixed Size                     2230592 bytes
Variable Size                536872640 bytes
Database Buffers            1795162112 bytes
Redo Buffers                  20750336 bytes

RMAN> SQL 'ALTER SYSTEM ENABLE RESTRICTED SESSION';

sql statement: ALTER SYSTEM ENABLE RESTRICTED SESSION

RMAN> DROP DATABASE INCLUDING BACKUPS NOPROMPT;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of drop db & bck command at 02/06/2013 12:31:16
ORA-01507: database not mounted

RMAN> SQL 'alter database mount'
2> ;

sql statement: alter database mount


RMAN> DROP DATABASE INCLUDING BACKUPS NOPROMPT;

database name is "RENAMEDB" and DBID is 257482690

allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=387 device type=DISK
specification does not match any backup in the repository

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=387 device type=DISK
specification does not match any datafile copy in the repository
specification does not match any control file copy in the repository
specification does not match any control file copy in the repository
specification does not match any archived log in the repository

database name is "RENAMEDB" and DBID is 257482690
database dropped

RMAN> exit


Recovery Manager complete.

Thursday, November 29, 2012

Renaming the DB name(Standalone)


====================================================================
In this post i would be changing the DB name of a single instance DB from TESTDB to RENAMEDB
====================================================================

-- check TESTDB is primary role and read write mode

[oracle@subhen-db01 ~]$ . oraenv
ORACLE_SID = [oracle] ? TESTDB
The Oracle base has been set to /oracle/app
[oracle@subhen-db01 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Nov 30 15:57:45 2012

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


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

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
TESTDB    READ WRITE           PRIMARY

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

-- stop the database and start it in mount mode

[oracle@subhen-db01 ~]$ srvctl stop database -d TESTDB -o immediate
[oracle@subhen-db01 ~]$ srvctl start database -d TESTDB -o MOUNT
[oracle@subhen-db01 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Nov 30 16:02:32 2012

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


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

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
TESTDB    MOUNTED              PRIMARY

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

-- starting with NID utility

[oracle@subhen-db01 ~]$ nid -help

DBNEWID: Release 11.2.0.3.0 - Production on Fri Nov 30 16:05:51 2012

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Keyword     Description                    (Default)
----------------------------------------------------
TARGET      Username/Password              (NONE)
DBNAME      New database name              (NONE)
LOGFILE     Output Log                     (NONE)
REVERT      Revert failed change           NO
SETNAME     Set a new database name only   NO
APPEND      Append to output log           NO
HELP        Displays these messages        NO

[oracle@subhen-db01 ~]$ nid TARGET=sys@TESTDB DBNAME=RENAMEDB

DBNEWID: Release 11.2.0.3.0 - Production on Fri Nov 30 16:07:24 2012

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Password:
Connected to database TESTDB (DBID=2584054004)

Connected to server version 11.2.0

Control Files in database:
    +DATA01/testdb/controlfile/current.827.800725877

Change database ID and database name TESTDB to RENAMEDB? (Y/[N]) => y

Proceeding with operation
Changing database ID from 2584054004 to 257482690
Changing database name from TESTDB to RENAMEDB
    Control File +DATA01/testdb/controlfile/current.827.800725877 - modified
    Datafile +DATA01/testdb/datafile/system.278.80072581 - dbid changed, wrote new name
    Datafile +DATA01/testdb/datafile/sysaux.394.80072581 - dbid changed, wrote new name
    Datafile +DATA01/testdb/datafile/undotbs1.838.80072581 - dbid changed, wrote new name
    Datafile +DATA01/testdb/datafile/users.463.80072581 - dbid changed, wrote new name
    Datafile +DATA01/testdb/tempfile/temp.555.80072589 - dbid changed, wrote new name
    Control File +DATA01/testdb/controlfile/current.827.800725877 - dbid changed, wrote new name
    Instance shut down

Database name changed to RENAMEDB.
Modify parameter file and generate a new password file before restarting.
Database ID for database RENAMEDB changed to 257482690.
All previous backups and archived redo logs for this database are unusable.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.

-- starting with the new database RENAMEDB and change the parameter file to include the DBname as RENAMEDB

[oracle@subhen-db01 ~]$ export ORACLE_SID=RENAMEDB
[oracle@subhen-db01 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Nov 30 16:08:53 2012

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

Connected to an idle instance.

SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/oracle/app/database/11.2.0.3/dbhome_1/dbs/initRENAMEDB.ora'
SQL> exit

-- here i will create a pfile from the spfile of TESTDB(earlier database)
Disconnected
[oracle@subhen-db01 ~]$ ps -fe|grep pmon
oracle    5258   911  0 16:09 pts/2    00:00:00 grep pmon

oracle   19437     1  0 Jul24 ?        00:00:03 asm_pmon_+ASM

[oracle@subhen-db01 ~]$ . oraenv
ORACLE_SID = [RENAMEDB] ? +ASM
The Oracle base remains unchanged with value /oracle/app
[oracle@subhen-db01 ~]$ asmcmd
ASMCMD> ls
DATA01/
ASMCMD> cd *
ASMCMD> ls
ASM/
BLAINT1/
BLAINT2/
BLAOID1/
BLAOID2/
TESTDB/
ASMCMD> cd TESTDB/
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
spfileTESTDB.ora
ASMCMD> pwd
+DATA01/TESTDB
ASMCMD> exit

[oracle@subhen-db01 ~]$ export ORACLE_SID=RENAMEDB
[oracle@subhen-db01 ~]$ export ORACLE_HOME=/oracle/app/database/11.2.0.3/dbhome_1
[oracle@subhen-db01 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Nov 30 16:11:00 2012

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

Connected to an idle instance.

SQL> create pfile='/tmp/initRENAME.ora' from spfile='+DATA01/TESTDB/spfileTESTDB.ora';

File created.

SQL> exit
Disconnected
-- modify the parameters like db_name='RENAMEDB' and start the database

[oracle@subhen-db01 ~]$ vi /tmp/initRENAME.ora
[oracle@subhen-db01 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Nov 30 16:14:44 2012

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

Connected to an idle instance.

SQL> startup nomount pfile='/tmp/initRENAME.ora'
ORACLE instance started.

Total System Global Area 2355015680 bytes
Fixed Size                  2230592 bytes
Variable Size             536872640 bytes
Database Buffers         1795162112 bytes
Redo Buffers               20750336 bytes
SQL> alter database mount;

Database altered.

SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> alter database open resetlogs;

Database altered.

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
RENAMEDB  READ WRITE           PRIMARY

note: control file and other locations still refer to the old locations

Wednesday, November 28, 2012

ODI_REPO(componentID - ODI) RCU schema creation using 11.1.1.15.0


[oracle@subhen-db09 ~]$ /oracle/source/OFM11gR1/ofm_rcu_linux_11.1.1.5.0/rcuHome/bin/rcu -silent -createRepository -databaseType ORACLE  -connectString  subhen-dbscan.espdev.aurdev.national.com.au:1621:ORCL -dbUser sys -dbRole sysdba -schemaPrefix CIS -component ODI -f < /home/oracle/password_ODI.txt

Processing command line ....
Repository Creation Utility - Checking Prerequisites
Checking Global Prerequisites







Repository Creation Utility - Checking Prerequisites
Checking Component Prerequisites
Repository Creation Utility - Creating Tablespaces
Validating and Creating Tablespaces
Repository Creation Utility - Create
Repository Create in progress.
Percent Complete: 0
Percent Complete: 0
Percent Complete: 10
Percent Complete: 10
Percent Complete: 10
Percent Complete: 50
Percent Complete: 100
Repository Creation Utility: Create - Completion Summary
Database details:
Host Name                       : subhen-dbscan.espdev.aurdev.national.com.au
Port                            : 1621
Service Name                    : ORCL
Connected As                    : sys
Prefix for (prefixable) Schema Owners : CIS
RCU Logfile                     : /oracle/app/logdir.2012-11-29_11-00/rcu.log
Component schemas created:
Component                       Status  Logfile
Master and Work Repository              Success /oracle/app/logdir.2012-11-29_11-00/odi.log

Repository Creation Utility - Create : Operation Completed
[oracle@subhen-db09 ~]$ sleep 2d

[oracle@subhen-db09 ~]$ cat /home/oracle/password_ODI.txt
<sys DB password >
Cis321
001
Cis321
D
001
WORKREP
Cis321
[oracle@subhen-db09 ~]$ sleep 2d

Tuesday, November 27, 2012

Dataguard Broker troubleshoot:Error: ORA-16664: unable to receive the result from a database

I had recently created a 2node RAC standby database from a 2 node RAC primary database .Also configured for dataguard broker , but while checking the status of the configuration through "show configuration" it was showing the errors like 

*********************************
Error stack from primary database
*********************************
[oracle@subhen-db07 ~]$ . oraenv
ORACLE_SID = [ORCL1] ? ORCL1
The Oracle base for ORACLE_HOME=/oracle/app/database/11.2.0.3/dbhome_1 is /oracle/app
[oracle@subhen-db07 ~]$ dgmgrl
DGMGRL for Linux: Version 11.2.0.3.0 - 64bit Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys@ORCL
Password:
Connected.
DGMGRL> show configuration

Configuration - ORCLdg

  Protection Mode: MaxAvailability
  Databases:
    ORCL  - Primary database
    ORCLB - Physical standby database
      Error: ORA-16664: unable to receive the result from a database

Fast-Start Failover: DISABLED

Configuration Status:
ERROR

DGMGRL> exit

****************************
Error stack from standby database
****************************
[oracle@standby-db07 ~]$ . oraenv
ORACLE_SID = [oracle] ? ORCLB1
The Oracle base has been set to /oracle/app
[oracle@standby-db07 ~]$ dgmgrl
DGMGRL for Linux: Version 11.2.0.3.0 - 64bit Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys@ORCLB
Password:
Connected.
DGMGRL> show configuration

Configuration - ORCLdg

  Protection Mode: MaxAvailability
  Databases:
    ORCL  - Primary database
    ORCLB - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
ORA-01017: invalid username/password; logon denied
ORA-16625: cannot reach database "ORCL"
DGM-17017: unable to determine configuration status

****************************
Solution for the above errors
*************************
Copy the password file from one of the primary instance hosts to other standby sites( note: don't create password files at standby host using ORAPW utility)
*****************************************************
After copying the password file from primary over to standby host
***************************************************
[oracle@subhen-db07 ~]$ dgmgrl
DGMGRL for Linux: Version 11.2.0.3.0 - 64bit Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys@ORCL
Password:
Connected.
DGMGRL> show configuration

Configuration - orcldg

  Protection Mode: MaxAvailability
  Databases:
    ORCL  - Primary database
    ORCLB - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS


Friday, November 23, 2012

GOLDEN GATE configuration from schema to schema replication within the same database


Here i am going to show how to replicate schema1 to schema2 using ORACLE goldengate only DML replication.(in the same database)

Prerequisites: Oracle Goledengate software is assumed to be installed
               Manager process started(if not check the bottom of post how to start manager process)
               TNS entries are there for ASM and database (if not check the bottom of post)
               supplemental logging is enabled at database level(if not check the bottom of post)
source schema: SCHEMA1
destination schema: SCHEMA2
HOST NAME:subhendb01
DATABASE NAME:ORCL

-- create golden_data tablespace
create tablespace ggate_data datafile size 100m autoextend on;
-- create golden gate user i.e. ggate_schema1
create user ggate_schema1 identified by <pwd>
temporary tablespace TEMP
default tablespace ggate_data
quota unlimited on ggate_data;

grant CREATE SESSION to ggate_schema1;
grant ALTER SESSION to ggate_schema1;
grant RESOURCE to ggate_schema1;
grant SELECT ANY DICTIONARY to ggate_schema1;
grant EXECUTE on DBMS_FLASHBACK to ggate_schema1;


--Encrypt passwords for GGate user and ASM user for extract parameter file

--Create encrypted password for user ggate_schema1

GGSCI (subhendb01.***.***.****.***) 39> encrypt password <pwd>
No key specified, using default key...

Encrypted password:  AACAAAAAAAAAAAJABDJBJFYAFAVBTEYGXFLIVHDDGANENIWA
--- Use it for the USERID line in the parameter file

Create encrypted password for ASM user

GGSCI (subhendb01.***.***.****.***) 15> encrypt password <pwd>

No key specified, using default key...

Encrypted password:  AACAAAAAAAAAAAJAIEJANCHETDCCSJLCUCUEPFYGGJBFJGIH

--- Use it for the TRANLOGOPTIONS ASMUSER line in the parameter file


--Configure 'continuous' EXTRACT group

[oracle@subhendb01 11.1_11g]$ . oraenv
ORACLE_SID = [oracle] ? ORCL_1
The Oracle base for ORACLE_HOME=/oracle/app/database/11.2.0.3/dbhome_1 is /oracle/app
[oracle@subhendb01 11.1_11g]$ ./ggsci

Oracle GoldenGate Command Interpreter for Oracle
Version 11.1.1.0.0 Build 078
Linux, x64, 64bit (optimized), Oracle 11 on Jul 28 2010 13:13:42

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



GGSCI (subhendb01.***.***.****.***) 1>ADD EXTRACT EXT_schema1, TRANLOG, THREADS 3, BEGIN NOW

GGSCI (subhendb01.***.***.****.***) 2>ADD EXTTRAIL ./dirdat/ep, EXTRACT EXT_schema1

GGSCI (subhendb01.***.***.****.***) 3> edit params EXT_SCHEMA1

...............
EXTRACT EXT_schema1
SETENV (ORACLE_HOME = "/oracle/app/database/11.2.0.3/dbhome_1")
SETENV (ORACLE_SID = "ORCL_1")
USERID ggate_schema1, PASSWORD AACAAAAAAAAAAAJABDJBJFYAFAVBTEYGXFLIVHDDGANENIWA, &
ENCRYPTKEY DEFAULT
TRANLOGOPTIONS ASMUSER sys@+ASM, ASMPASSWORD AACAAAAAAAAAAAHAWAEJQDPACDHGNHSE, &
ENCRYPTKEY DEFAULT
TRANLOGOPTIONS PURGEORPHANEDTRANSACTIONS
DISCARDFILE ./discard/ext_schema1_discard.dsc, append, megabytes 10
GETUPDATEBEFORES
NOCOMPRESSDELETES
RMTHOST subhendb01, mgrport 7840
rmttrail ./dirdat/ep
table NWHADS_schema1.*;


--For replication schema NWHADS_schema2
--Create GGATE_DATA tablespace and  ggate_rep_schema2 user, if not exists

create user ggate_rep_schema2 identified by <pwd>
temporary tablespace TEMP
default tablespace ggate_data
quota unlimited on ggate_data;

grant CREATE SESSION to ggate_rep_schema2;
grant ALTER SESSION to ggate_rep_schema2;
grant RESOURCE to ggate_rep_schema2;
grant SELECT ANY DICTIONARY to ggate_rep_schema2;
grant EXECUTE on DBMS_FLASHBACK to ggate_rep_schema2;


--Create a checkpoint table, if not already exists

-- Create global parameter file with the table name

GGSCI (subhendb01.***.***.****.***) 3> edit params ./GLOBALS
……
CHECKPOINTTABLE ggate_schema1.cp_table
CHECKPOINTTABLE ggate_rep_schema2.cp_table
…..

GGSCI (subhendb01.***.***.****.***) 4>DBLOGIN USERID ggate_schema1, PASSWORD <pwd>
GGSCI (subhendb01.***.***.****.***) 4>ADD CHECKPOINTTABLE ggate_schema1.cp_table

… Successfully created checkpoint table ggate_schema1.cp_table.

GGSCI (subhendb01.***.***.****.***) 4>DBLOGIN USERID ggate_rep_schema2, PASSWORD <pwd>
GGSCI (subhendb01.***.***.****.***) 4>ADD CHECKPOINTTABLE ggate_rep_schema2.cp_table


… Successfully created checkpoint table ggate_rep_schema2.cp_table.


--Create the replicated schema tablespace and owner

grant CREATE SESSION to NWHADS_schema2;
grant DEBUG CONNECT SESSION to NWHADS_schema2;
grant CREATE TABLE to NWHADS_schema2;
grant CREATE VIEW to NWHADS_schema2;
grant CREATE SYNONYM to NWHADS_schema2;
grant CREATE SEQUENCE to NWHADS_schema2;
grant CREATE TRIGGER to NWHADS_schema2;
grant CREATE TYPE to NWHADS_schema2;
grant CREATE PROCEDURE to NWHADS_schema2;
grant CREATE LIBRARY to NWHADS_schema2;
grant CREATE DATABASE LINK to NWHADS_schema2;



--Configure 'continuous' REPLICAT group

--GGSCI (subhendb01.***.***.****.***) 1> ADD REPLICAT REP_schema2, EXTTRAIL ./dirdat/ep, BEGIN NOW
edit params REP_schema2
……………………………………
REPLICAT REP_schema2
SETENV (ORACLE_HOME = "/oracle/app/database/11.2.0.3/dbhome_1")
SETENV (ORACLE_SID = "ORCL_1")
USERID ggate_rep_schema2, PASSWORD AACAAAAAAAAAAAJABDJBJFYAFAVBTEYGXFLIVHDDGANENIWA, &
ENCRYPTKEY DEFAULT
ASSUMETARGETDEFS
EXTTRAIL ./dirdat/ep
DBOPTIONS  DEFERREFCONST
INSERTALLRECORDS
GETUPDATEBEFORES
REPERROR (DEFAULT, ABEND)
DDLERROR DEFAULT IGNORE
discardfile ./discard/rep_schema1_discard.dsc, append, megabytes 10
map NWHADS_schema1.*, target NWHADS_schema2.*;
………………………


GGSCI (subhendb01.***.***.****.***) 4> info all

Program     Status      Group       Lag           Time Since Chkpt

MANAGER     RUNNING
EXTRACT     RUNNING     EXT_SCHEMA1    00:00:00      00:00:03
REPLICAT    RUNNING     REP_SCHEMA2    00:00:00      00:00:08


=========================
start of manager process
==========================

--  Check ports are free, e.g.:

netstat -a|grep " 78[4-7][0-9] "

./ggsci

EDIT PARAMS MGR    

PORT 7840
DYNAMICPORTLIST 7841-7870
AUTOSTART EXTRACT *
AUTOSTART REPLICAT *
AUTORESTART EXTRACT *
AUTORESTART REPLICAT *
PURGEOLDEXTRACTS ./DIRDAT/*, USECHECKPOINTS, MINKEEPDAYS 5

--save and exit

-- Test MGR restart

 START MGR
 STOP MGR
 START MGR
……………………………………
Manager started.

==================================
Configuration of tnsnames.ora file
==================================

The ASM service entry must be present in tnsnames.ora in the DB Oracle home:
………………………………………
+ASM =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = subhendb01v.***.***.****.***)(PORT = 1621))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = +ASM)
    )
  ) ………………………………………
Verify TNS connectivity

sqlplus sys/<pwd>@+ASM as sysdba

The source database service entry must be present in tnsnames.ora in the DB Oracle home:
………………………………………
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = subhendbscan.***.***.****.***)(PORT = 1621))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORCL)
    )
  ) ………………………………………….

Verify TNS connectivity

sqlplus sys/<pwd>@ORCL as sysdba

=============================================
ENABLE SUPPLEMENTAL LOGGING AT DATABASE LEVEL
=============================================


As sys or system : enable minimal supplemental logging at the database level. This is
required to process updates to primary keys and chained rows.

--- Check status

SQL> SELECT SUPPLEMENTAL_LOG_DATA_MIN FROM GV$DATABASE;

SUPPLEME
--------
NO
NO
NO

SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

Database altered.

--- To start the supplemental logging, switch the log files on all instances

SQL> alter system archive log current;

System altered.

--- Verify

SQL> SELECT SUPPLEMENTAL_LOG_DATA_MIN FROM GV$DATABASE;

SUPPLEME
--------
YES
YES
YES


Tuesday, November 6, 2012

Recreating the failed diskgroup with the same name



*************************
Not able to drop diskgroup
**************************

[oracle@subdb01 ~]$ asmcmd umount FRA
ORA-15032: not all alterations performed
ORA-15001: diskgroup "FRA" does not exist or is not mounted (DBD ERROR: OCIStmtExecute)
[oracle@subdb01 ~]$ asmcmd dropdg -f -r FRA
ORA-15039: diskgroup not dropped
ORA-15063: ASM discovered an insufficient number of disks for diskgroup "FRA" (DBD ERROR: OCIStmtExecute)

****************************
ERROR description
**************************

Our disk headers were overwritten by mistake so it was complaining about duplicate paths

SQL> CREATE DISKGROUP FRA EXTERNAL REDUNDANCY DISK '/dev/oracleasm/disks/DISK01' ,
'/dev/oracleasm/disks/DISK02' , '/dev/oracleasm/disks/DISK03'
NOTE: Assigning number (5,0) to disk (/dev/oracleasm/disks/DISK01)
NOTE: Assigning number (5,1) to disk (/dev/oracleasm/disks/DISK02)
NOTE: Assigning number (5,2) to disk (/dev/oracleasm/disks/DISK03)
WARNING: detected duplicate paths to the same disk:
'/dev/oracleasm/disks/DISK06' and
'/dev/oracleasm/disks/DISK02'
More trace information dumped to '/oracle/app/diag/asm/+asm/+ASM1/trace/+ASM1_ora_8000.trc'
WARNING: detected duplicate paths to the same disk:
'/dev/oracleasm/disks/DISK09' and
'/dev/oracleasm/disks/DISK05'
More trace information dumped to '/oracle/app/diag/asm/+asm/+ASM1/trace/+ASM1_ora_8000.trc'
WARNING: detected duplicate paths to the same disk:
'/dev/oracleasm/disks/DISK07' and
'/dev/oracleasm/disks/DISK03'
More trace information dumped to '/oracle/app/diag/asm/+asm/+ASM1/trace/+ASM1_ora_8000.trc'
WARNING: detected duplicate paths to the same disk:
'/dev/oracleasm/disks/DISK08' and
'/dev/oracleasm/disks/DISK04'
More trace information dumped to '/oracle/app/diag/asm/+asm/+ASM1/trace/+ASM1_ora_8000.trc'
NOTE: erasing header on grp 5 disk FRA_0000
Thu Oct 25 21:51:04 2012
GMON dismounting group 5 at 422 for pid 51, osid 8000
NOTE: Disk in mode 0x8 marked for de-assignment
NOTE: Disk in mode 0x8 marked for de-assignment
NOTE: Disk in mode 0x8 marked for de-assignment
ERROR: diskgroup FRA was not created
ORA-15018: diskgroup cannot be created
ORA-15020: discovered duplicate ASM disk "FRA_0005"
ERROR: CREATE DISKGROUP FRA EXTERNAL REDUNDANCY DISK '/dev/oracleasm/disks/DISK01' ,
'/dev/oracleasm/disks/DISK02' , '/dev/oracleasm/disks/DISK03'

*************************************
Creating disk group with force option
*************************************
So as above disk 2,3,4,5 was showing overwritten with duplicate information

so to relebel them in ASMLIB please follow the below steps


Action Plan
---------------------
1. Relable the affected devices using the following command.

# /etc/init.d/oracleasm force-renamedisk /dev/oracleasm/disks/DISK02 DISK02
# /etc/init.d/oracleasm force-renamedisk /dev/oracleasm/disks/DISK03 DISK03
# /etc/init.d/oracleasm force-renamedisk /dev/oracleasm/disks/DISK04 DISK04
# /etc/init.d/oracleasm force-renamedisk /dev/oracleasm/disks/DISK05 DISK05

2. And run scandisks command from all nodes.


# /etc/init.d/oracleasm scandisks

3. Create DUMMY diskgroup with all 9 devices belonged to FRA diskgroup in the following way.

SQL> CREATE DISKGROUP DUMMY EXTERNAL REDUNDANCY DISK
'/dev/oracleasm/disks/DISK01' ,
'/dev/oracleasm/disks/DISK02' force,
'/dev/oracleasm/disks/DISK03' force,
'/dev/oracleasm/disks/DISK04' force,
'/dev/oracleasm/disks/DISK05' force,
'/dev/oracleasm/disks/DISK06' force,
'/dev/oracleasm/disks/DISK07' force,
'/dev/oracleasm/disks/DISK08' force,
'/dev/oracleasm/disks/DISK09' force;

4. Once DUMMY diskgroup can be created properly, drop it.
SQL> drop diskgroup DUMMY including contents;

5. And then recreate FRA with the following command.
SQL> CREATE DISKGROUP FRA EXTERNAL REDUNDANCY DISK
'/dev/oracleasm/disks/DISK01' ,
'/dev/oracleasm/disks/DISK02' ,
'/dev/oracleasm/disks/DISK03' ,
'/dev/oracleasm/disks/DISK04' ,
'/dev/oracleasm/disks/DISK05' ,
'/dev/oracleasm/disks/DISK06' ,
'/dev/oracleasm/disks/DISK07' ,
'/dev/oracleasm/disks/DISK08' ,
'/dev/oracleasm/disks/DISK09' ;

Creating a spfile from memory and starting the DB with the new spfile



Currently we had a situation where the database was showing started with spfile but the spfile physically was not there present at ASM location

i.e. show parameter pfile --- shows DB started with spfile but the same ASM file doesn't exist at its location.


SQL> show parameter pfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATA/devnwwfw/spfiledevnwwfw.ora                                        



Current configuration of database

[oracle@subdb02 ~]$ srvctl config database -d DEVNWWFW
Database unique name: DEVNWWFW
Database name: DEVNWWFW
Oracle home: /oracle/app/database/11.2.0.3/dbhome_1
Oracle user: oracle
Spfile: +DATA/DEVNWWFW/spfileDEVNWWFW.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: KXD2BUPOOL
Database instances:
Disk Groups: DATA,FRA
Mount point paths:
Services:
Type: RAC

Database is policy managed

No SPFILE found

ASMCMD> cd +DATA/DEVNWWFW
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
TEMPFILE/
ASMCMD> pwd
+DATA/DEVNWWFW
ASMCMD> exit



This was a part of 4 node cluster and when one node crashed and it denied to come up then this issue was noticed

Solution:

Step1(create a pfile from memory):

From a different node(instance) which is up please create a pfile;


SQL> create pfile='/tmp/DEVNWWFW.ora' from spfile='+DATA/devnwwfw/spfiledevnwwfw.ora';
create pfile='/tmp/DEVNWWFW.ora' from spfile='+DATA/devnwwfw/spfiledevnwwfw.ora'
*
ERROR at line 1:
ORA-01565: error in identifying file '+DATA/devnwwfw/spfiledevnwwfw.ora'
ORA-17503: ksfdopn:2 Failed to open file +DATA/devnwwfw/spfiledevnwwfw.ora
ORA-15173: entry 'spfiledevnwwfw.ora' does not exist in directory 'devnwwfw'


SQL> create pfile='/tmp/DEVNWWFW.ora' from memory;

File created.

Step 2(create a new spfile with different name):

Create a new spfile with different name as it is not allowing us to create with same one as per the error above


[oracle@subdb02 ~]$ echo $ORACLE_SID
DEVNWWFW_2
[oracle@subdb02 ~]$ srvctl stop database -d DEVNWWFW -o immediate
[oracle@subdb02 ~]$ echo $ORACLE_SID
DEVNWWFW_2
[oracle@subdb02 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Oct 31 18:12:03 2012

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

Connected to an idle instance.

SQL> create spfile='+DATA/devnwwfw/spfiledevnwwfw1.ora' from pfile='/tmp/DEVNWWFW_new.ora';

File created.



Step3( using srvctl modify the database to start with new spfile):


[oracle@subdb02 ~]$ srvctl modify database -d DEVNWWFW -p +DATA/devnwwfw/spfiledevnwwfw1.ora
[oracle@subdb02 ~]$  srvctl config database -d DEVNWWFW
Database unique name: DEVNWWFW
Database name: DEVNWWFW
Oracle home: /oracle/app/database/11.2.0.3/dbhome_1
Oracle user: oracle
Spfile: +DATA/devnwwfw/spfiledevnwwfw1.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: KXD2BUPOOL
Database instances:
Disk Groups: DATA,FRA
Mount point paths:
Services:
Type: RAC
Database is policy managed

Step4(start the database with new spfile):


[oracle@subdb02 ~]$ srvctl start database -d DEVNWWFW
[oracle@subdb02 ~]$  srvctl status database -d DEVNWWFW
Instance DEVNWWFW_1 is running on node subdb01
Instance DEVNWWFW_2 is running on node subdb02
Instance DEVNWWFW_3 is running on node subdb03

step5(check if it started with new spfile and the ASM location also):


SQL> show parameter pfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATA/devnwwfw/spfiledevnwwfw1.ora                                          


ASMCMD> cd +DATA/devnwwfw/
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
TEMPFILE/
spfiledevnwwfw1.ora