Tabs

Friday, January 9, 2015

Drop database in 11gR2 with RAC

I am planning to remove my cluster database which is running on 11gR2

Stop the entire cluster environment  
Murali[KMM]>srvctl stop database -d KMM_a

Start only one instance to edit the cluster_database parameter to FALSE

Murali[KMM]>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Feb 10 16:03:03 2012

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

Connected to an idle instance.

SQL> startup mount
ORACLE instance started.

Total System Global Area 2.6924E+10 bytes
Fixed Size                  2241104 bytes
Variable Size            1.3086E+10 bytes
Database Buffers         1.3824E+10 bytes
Redo Buffers               11227136 bytes
Database mounted.


SQL> alter system set cluster_database=FALSE scope=spfile sid='*';

System altered.


SQL> shutdown abort;
ORACLE instance shut down.

Now starting only one instance after editing below parameter CLUSTER_DATABASE parameters to FALSE

SQL> startup mount exclusive restrict
ORACLE instance started.

Total System Global Area 2.6924E+10 bytes
Fixed Size                  2241104 bytes
Variable Size            1.3086E+10 bytes
Database Buffers         1.3824E+10 bytes
Redo Buffers               11227136 bytes
Database mounted.

Make sure whether you have started in the restricted mode

SQL>  select logins,parallel from v$instance;

LOGINS     PAR
---------- ---
RESTRICTED NO

When you issue this command, this will drop the database including datafiles, control files, redo log files & archive log files

SQL> drop database;

Database dropped.

To drop the database including the backup, we can go for the below option
RMAN> DROP DATABASE INCLUDING BACKUPS NOPROMPT;

Murali[KMM]>srvctl  remove database -d dbname

Thursday, January 8, 2015

Restore Controlfile using RMAN


Backup.Bat: -

SET ORACLE_HOME=D:\app\CYBADMIN\product\11.2.0\dbhome_1

SET ORACLE_SID=ORCL

RMAN TARGET SYS/ CMDFILE D:\app\Backup\BACKUP.RCV LOG D:\app\Backup\BACKUP.LOG



Backup.RCV: -

Run {

Allocate channel t1 type disk;

Allocate channel t2 type disk;

Allocate channel t3 type disk;

Allocate channel t4 type disk;

Backup AS COMPRESSED BACKUPSET database format 'D:\app\Backup\Backup\bk_%s_%p_%t'

                        Plus archivelog format 'D:\app\Backup\Backup\al_%s_%p_%t';

Sql "alter database backup controlfile to ''D:\app\Backup\Backup\control.ctl'' REUSE";

Sql "alter database backup controlfile to trace as ''D:\app\Backup\Backup\control.txt'' REUSE";

}



D:\app\Backup>backup.bat

D:\app\Backup>SET ORACLE_HOME=D:\app\CYBADMIN\product\11.2.0\dbhome_1

D:\app\Backup>SET ORACLE_SID=ORCL

D:\app\Backup>RMAN TARGET SYS/ CMDFILE D:\app\Backup\BACKUP.RCV LOG D:\app\Backup\BACKUP.LOG

RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11>

D:\app\Backup>rman target sys/

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jan 8 14:19:53 2015

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

target database Password:

connected to target database: ORCL (DBID=1380168819)

RMAN> shutdown immediate

using target database control file instead of recovery catalog

database closed

database dismounted

Oracle instance shut down

RMAN> exit

Recovery Manager complete.


D:\app\Backup>rman target SYS/

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jan 8 14:20:56 2015

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

target database Password:

connected to target database (not started)



RMAN> startup nomount;

Oracle instance started

Total System Global Area    1603411968 bytes

Fixed Size                     2176168 bytes

Variable Size               1073744728 bytes

Database Buffers             520093696 bytes

Redo Buffers                   7397376 bytes

RMAN> run

{

Allocate channel c1 device type disk;

Restore controlfile from 'D:\app\Backup\Backup\control.ctl';

}

using target database control file instead of recovery catalog

allocated channel: c1

channel c1: SID=134 device type=DISK

Starting restore at 08-JAN-15

channel c1: copied control file copy

output file name=D:\APP\CYBADMIN\ORADATA\ORCL\CONTROL01.CTL

output file name=D:\APP\CYBADMIN\FLASH_RECOVERY_AREA\ORCL\CONTROL02.CTL

Finished restore at 08-JAN-15

released channel: c1

RMAN> alter database mount;

database mounted



RMAN> run {

recover database;

alter database open resetlogs;

}

Starting recover at 08-JAN-15

Starting implicit crosscheck backup at 08-JAN-15

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=134 device type=DISK

Crosschecked 6 objects

Finished implicit crosscheck backup at 08-JAN-15

Starting implicit crosscheck copy at 08-JAN-15

using channel ORA_DISK_1

Crosschecked 10 objects

Finished implicit crosscheck copy at 08-JAN-15

searching for all files in the recovery area

cataloging files...

no files cataloged

using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 3 is already on disk as file D:\APP\CYBADMIN\ORADATA\ORCL\REDO03.LOG

archived log file name=D:\APP\CYBADMIN\ORADATA\ORCL\REDO03.LOG thread=1 sequence=3

media recovery complete, elapsed time: 00:00:01

Finished recover at 08-JAN-15

database opened

RMAN>

Tuesday, January 6, 2015

Oracle database upgrade 11.2.0.3 to 12.1.0

Upgrade Path for Oracle Database to Oracle 12c Release 1 (12.1)

Minimum version of the database that can be directly upgraded to Oracle 12c Release 1 (12.1)
Source DatabaseTarget Database
10.2.0.5 12.1.x
11.1.0.7 12.1.x
11.2.0.2 or higher 12.1.x
The following database versions will require an indirect upgrade path:
Source Database

Intermediate Upgrade Path for Target Database

Target Database
11.2.0.1 ----> 11.2.0.2 or higher ----> 12.1.x
11.1.0.6 ----> 11.1.0.7 or 11.2.0.2 or higher ----> 12.1.x
10.2.0.4 (or earlier) ---->  10.2.0.5 or later direct upgrade version ----> 12.1.x
10.1.0.5 (or earlier) ----> 10.2.0.5 or later direct upgrade version ----> 12.1.x
9.2.0.8 (or earlier) ---->   9.2.0.8 --> 11.2.0.2 or higher ----> 12.1.x
 For example:
  •  If you are upgrading from 11.2.0.1 or 11.1.0.6, then you must first upgrade to Oracle Database 11g Release 2 (11.2.0.2).
  •  If you are upgrading from 10.2.0.2, 10.2.0.3, 10.2.0.4, or 10.1.0.5, then you must first upgrade to 10.2.0.5 or later.
  •  For release 9.2.0.8, you must first upgrade to an intermediate Oracle Database release, as follows: 9.2.0.8 -> 11.2.0.2 or 11.2.0.3 -> 12.1
Note:
To locate the patch-id of a patch-set refer to:
Note 438049.1 : How To Find RDBMS patchsets on My Oracle Support
Note 753736.1 : Quick Reference to Patchset Patch Numbers


Upgrading Oracle Database 11.2.0.3 to 12.1.0 steps

 

There are different ways of upgrading to the latest release of Oracle database and Oracle provides multiple methods to upgrade. Few are listed below:
  • Database Upgrade Assistant (DBUA)
  • Manual Upgrade
  • Transportable Tablespaces
  • Datapump export/import
  • Oracle Streams
  • Oracle GoldenGate
I chose DBUA to upgrade my test database as it was the simplest and quickest of all. Below are the database environment details prior to upgrade:

 

 Server details below

OS : OEL 5.4 (64 bit)
Database : 11.2.0.3 (64 bit)

Note:- Before starting the up-gradation process, take the complete backup of database.

1)Take cold backup of 11.2.0.3 database
[oracle@Murali ~]$ cd $ORACLE_BASE
[oracle@Murali oracle]$ ls
admin cfgtoollogs checkpoints diag fast_recovery_area oradata product
[oracle@Murali oracle]$ cd oradata/

[oracle@Murali oradata]$ ls
PROD
[oracle@Murali oradata]$ cd PROD/

[oracle@Murali PROD]$ ls
control01.ctl redo01.log redo03.log system01.dbf undotbs01.dbf
example01.dbf redo02.log sysaux01.dbf temp01.dbf users01.dbf

[oracle@Murali PROD]$ cd ..
[oracle@Murali oradata]$ ls
PROD
[oracle@Murali oradata]$ cp -R PROD/ PROD_backup

2) Stop the Listener
[oracle@Murali admin]$ lsnrctl stop PROD
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 04-DEC-2014 11:32:26 Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=Murali.oracle.com)(PORT=1521)))

The command completed successfully

3) Create directory structure for 12c ORACLE_HOME
[oracle@Murali product]$ mkdir -p /u01/app/oracle/product/12.1.0

4) export ORACLE_HOME to 12c
[oracle@Murali 12.1.0]$ export ORACLE_HOME=/u01/app/oracle/product/12.1.0

5) Copy ( winscp or scp ) 12c software to /home/oracle
6) Launch Oracle 12c runinstaller
[oracle@Murali database]$ pwd
/home/oracle/database

Note: open new terminal & run xhost + command as a root user before running ./runInstaller 

[oracle@Murali database]$ ./runInstaller


Un-check “I Wish to receive security updates via My oracle support” and click Next



Click Yes
Select “Skip Software Updates” and click Next.


select “Upgrade an existing database” and click Next


select “Upgrade an existing database” and click Next


Select your language and click Next


Select “Enterprise Edition” and click Next


Fill the details for ORACLE_BASE and software location and click Next


Select the OSOPER grouop (Optional) and click Next


If you satisfy with the summary click Next


 Now Oracle Database 12c installation starts



 
Run the scripts as root user
[root@Murali ~]# /u01/app/oracle/product/12.1.0/root.sh
Performing root user operation for Oracle 12c
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/12.1.0
Enter the full pathname of the local bin directory: [/usr/local/bin]:
The file “dbhome” already exists in /usr/local/bin. Overwrite it? (y/n)
[n]:
The file “oraenv” already exists in /usr/local/bin. Overwrite it? (y/n)
[n]:
The file “coraenv” already exists in /usr/local/bin. Overwrite it? (y/n)
[n]:
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.

Now product-specific root actions will be performed.

Click OK after completion of running that script.

 [root@Murali ~]# netca


 Click next
Fill the Listener Name and click Next



 Click Next


Select the port number and click Next




Select No and click Next







 click next


 Click Finish



Now start DBUA (Database Upgrade Assistant)
Select “Upgrade Oracle Database” and click Next




Click Next



 click on that “Pre Upgrade Utility Checks” – severiy



You might see this error, safely ignore this error because this is a test machine.







 Choose Ignore from Action menu and click Next



 Check the file locations and click Next




Select “Configure Enterprise Manager (EM) Database Express and click Next

 

 Click Next


Select listener and click Next



Choose ” I have my own backup and restore strategy” and click Next






Click Finish




Oracle Database upgrade in progress,
Pre-Upgrade steps will complete in seconds but Database Upgrades Steps takes at-least 90 min of time based on your machine performance and post upgrade steps will take just 5 mins.




After finishing all up-gradation steps click on “Upgrade Results”




click “close”

 

After successfully completion of upgradation click “close”



 Oracle Database upgradation from 11g to 12c completed successfully.

Check it out the version of the upgraded database
[oracle@Murali database]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jul 4 21:07:50 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 – 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> select banner from v$version;
BANNER
——————————————————————————–
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 – 64bit Production
PL/SQL Release 12.1.0.1.0 – Production
CORE 12.1.0.1.0 Production
TNS for Linux: Version 12.1.0.1.0 – Production
NLSRTL Version 12.1.0.1.0 – Production