Friday, February 21, 2014

How to configure Oracle 11g OEM dbconsole manually

How to configure Oracle 11g OEM dbconsole manually

In most of the time DBAs used to go for manual configuration of the database after the database creation. Suppose your database is cloned from other database where you have grid already installed and configured. After the cloning, in the target database the same set of configuration will not work. You have to reconfigure the same. 

For that you have to drop the existing configuration first. If it is a new database you can directly configure the grid using emca.
Step 1. Drop the existing configuration if it is having sysman user already present.
Connect to sqlplus with sys as sysdba and check SYSMAN is exist or not
SQL> Select username from dba_users where username='SYSMAN';

USERNAME
------------------------------
SYSMAN
      
Command to drop the existing configuration
$ emca -deconfig dbcontrol db -repos drop

STARTED EMCA at Jun 23, 2011 5:27:34 AM
EM Configuration Assistant, Version 11.1.0.7.0 Production
Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Enter the following information:
Database SID: prod9
Listener port number: 1522
Password for SYS user:
Password for SYSMAN user:
Password for SYSMAN user:
Do you wish to continue? [yes(Y)/no(N)]: Y
Jun 23, 2011 5:27:47 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /data/oracle/cfgtoollogs/emca/prod9/emca_2011_06_23_05_27_34.log.
Jun 23, 2011 5:27:49 AM oracle.sysman.emcp.EMDBPreConfig performDeconfiguration
WARNING: EM is not configured for this database. No EM-specific actions can be performed.
Jun 23, 2011 5:27:50 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Dropping the EM repository (this may take a while) ...
Jun 23, 2011 5:37:25 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully dropped
Enterprise Manager configuration completed successfully
FINISHED EMCA at Jun 23, 2011 5:37:26 AM

Step 2. Create the OEM GRID repository
$ emca -repos create

STARTED EMCA at Jun 23, 2011 6:41:59 AM
EM Configuration Assistant, Version 11.1.0.7.0 Production
Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Enter the following information:
Database SID: prod9
Listener port number: 1522
Password for SYS user:
Password for SYSMAN user:
Do you wish to continue? [yes(Y)/no(N)]: Y
Jun 23, 2011 6:42:17 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /data/oracle/cfgtoollogs/emca/prod9/emca_2011_06_23_06_41_59.log.
Jun 23, 2011 6:42:18 AM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...
Jun 23, 2011 7:16:31 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully created
Enterprise Manager configuration completed successfully
FINISHED EMCA at Jun 23, 2011 7:16:31 AM

Step 4. Confitgure EM Grid control
$ emca -config dbcontrol db

STARTED EMCA at Jun 23, 2011 8:58:47 PM
EM Configuration Assistant, Version 11.1.0.7.0 Production
Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Enter the following information:
Database SID: prod9
Database Control is already configured for the database prod9
You have chosen to configure Database Control for managing the database prod9
This will remove the existing configuration and the default settings and perform a fresh configuration
Do you wish to continue? [yes(Y)/no(N)]: Y
Listener port number: 1522
Password for SYS user:
Password for DBSNMP user:
Password for SYSMAN user:
Password for SYSMAN user: Email address for notifications (optional):
Outgoing Mail (SMTP) server for notifications (optional):
-----------------------------------------------------------------

You have specified the following settings

Database ORACLE_HOME ................ /data/oracle/product/11.1.0

Local hostname ................ localhost
Listener port number ................ 1522
Database SID ................ prod9
Email address for notifications ...............
Outgoing Mail (SMTP) server for notifications ...............

-----------------------------------------------------------------
Do you wish to continue? [yes(Y)/no(N)]: y
Jun 23, 2011 8:59:36 PM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /data/oracle/cfgtoollogs/emca/prod9/emca_2011_06_23_20_58_47.log.
Jun 23, 2011 8:59:41 PM oracle.sysman.emcp.util.DBControlUtil stopOMS
INFO: Stopping Database Control (this may take a while) ...
Jun 23, 2011 8:59:49 PM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository
INFO: Uploading configuration data to EM repository (this may take a while) ...
Jun 23, 2011 9:09:13 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Uploaded configuration data successfully
Jun 23, 2011 9:09:36 PM oracle.sysman.emcp.util.DBControlUtil configureSoftwareLib
INFO: Software library configured successfully.
Jun 23, 2011 9:09:36 PM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary
INFO: Deploying Provisioning archives ...
Jun 23, 2011 9:10:15 PM oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary
INFO: Provisioning archives deployed successfully.
Jun 23, 2011 9:10:16 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Securing Database Control (this may take a while) ...
Jun 23, 2011 9:11:01 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Database Control secured successfully.
Jun 23, 2011 9:11:01 PM oracle.sysman.emcp.util.DBControlUtil startOMS
INFO: Starting Database Control (this may take a while) ...
Jun 23, 2011 9:13:04 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: Database Control started successfully
Jun 23, 2011 9:13:04 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: >>>>>>>>>>> The Database Control URL is https://localhost:1158/em <<<<<<<
Jun 23, 2011 9:13:20 PM oracle.sysman.emcp.EMDBPostConfig invoke
WARNING:
************************  WARNING  ************************

Management Repository has been placed in secure mode wherein Enterprise Manager data will be encrypte                                                    ile: /data/oracle/product/11.1.0/localhost_prod9/sysman/config/emkey.ora.   Pleas                                                         d data will become unusable if this file is lost.
***********************************************************
Enterprise Manager configuration completed successfully
FINISHED EMCA at Jun 23, 2011 9:13:20 PM

Step 5. Verify the configuration by typing the address (https://localhost:1158/em) in the explorer.

How to check the status of EM Grid control
To check the status of grid control you have issue emctl status dbcontrol
$ emctl status dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.1.0.7.0
Copyright (c) 1996, 2008 Oracle Corporation.  All rights reserved.
https://localhost:1158/em/console/aboutApplication
Oracle Enterprise Manager 11g is running.
------------------------------------------------------------------
Logs are generated in directory /data/oracle/product/11.1.0/localhost_prod9/sysman/log

How to start the EM Grid control
$ emctl start dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.1.0.7.0
Copyright (c) 1996, 2008 Oracle Corporation.  All rights reserved.
https://localhost:1158/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control ................ started.
------------------------------------------------------------------
Logs are generated in directory /data/oracle/product/11.1.0/localhost_prod9/sysman/log

How to stop the EM Grid Control?

$ emctl stop dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.1.0.7.0
Copyright (c) 1996, 2008 Oracle Corporation.  All rights reserved.
https://localhost:1158/em/console/aboutApplication
Stopping Oracle Enterprise Manager 11g Database Control ...
 ...  Stopped.

A new method for a database rename instance

A new method for a database rename instance

For Oracle9i and beyond, Oracle author Dr. Tim Hall has this procedure to rename an Oracle database using the new dbnewid (also called nid, for new ID) utility:
  • STEP 1: Backup the database.
     
  • STEP 2: Mount the database after a clean shutdown:
    SHUTDOWN IMMEDIATE
    STARTUP MOUNT
  • STEP 3: Invoke the DBNEWID utility (nid) specifying the new DBNAME from the command line using a user with SYSDBA privilege:
    nid TARGET=sys/password@TSH1 DBNAME=TSH2
    Assuming the validation is successful the utility prompts for confirmation before performing the actions. Typical output may look something like:
    C:\oracle\920\bin>nid TARGET=sys/password@TSH1 DBNAME=TSH2
    DBNEWID: Release 9.2.0.3.0 - Production
    Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.
    
    Connected to database TSH1 (DBID=1024166118)
    
    Control Files in database:
        C:\ORACLE\ORADATA\TSH1\CONTROL01.CTL
        C:\ORACLE\ORADATA\TSH1\CONTROL02.CTL
        C:\ORACLE\ORADATA\TSH1\CONTROL03.CTL
    
    Change database ID and database name TSH1 to TSH2? (Y/[N]) => Y
    
    Proceeding with operation
    Changing database ID from 1024166118 to 1317278975
    Changing database name from TSH1 to TSH2
        Control File C:\ORACLE\ORADATA\TSH1\CONTROL01.CTL - modified
        Control File C:\ORACLE\ORADATA\TSH1\CONTROL02.CTL - modified
        Control File C:\ORACLE\ORADATA\TSH1\CONTROL03.CTL - modified
        Datafile C:\ORACLE\ORADATA\TSH1\SYSTEM01.DBF - dbid changed, wrote new name
        Datafile C:\ORACLE\ORADATA\TSH1\UNDOTBS01.DBF - dbid changed, wrote new name
        Datafile C:\ORACLE\ORADATA\TSH1\CWMLITE01.DBF - dbid changed, wrote new name
        Control File C:\ORACLE\ORADATA\TSH1\CONTROL01.CTL - dbid changed, wrote new name
        Control File C:\ORACLE\ORADATA\TSH1\CONTROL02.CTL - dbid changed, wrote new name
        Control File C:\ORACLE\ORADATA\TSH1\CONTROL03.CTL - dbid changed, wrote new name
    
    Database name changed to TSH2.
    Modify parameter file and generate a new password file before restarting.
    Database ID for database TSH2 changed to 1317278975.
    All previous backups and archived redo logs for this database are unusable.
    Shut down database and open with RESETLOGS option.
    Succesfully changed database name and ID.
    DBNEWID - Completed succesfully.
  • STEP 4: Shutdown the database:
    SHUTDOWN IMMEDIATE
  • STEP 5: Modify the DB_NAME parameter in the initialization parameter file. The startup will result in an error but proceed anyway.
    STARTUP MOUNT
    ALTER SYSTEM SET DB_NAME=TSH2 SCOPE=SPFILE;
    SHUTDOWN IMMEDIATE
  • STEP 6: Create a new password file:
    orapwd file=c:\oracle\920\database\pwdTSH2.ora password=password entries=10
  • STEP 7: Rename the SPFILE to match the new DBNAME.
     
  • STEP 8: If you are using Windows you must recreate the service so the correct name and parameter file are used:
    oradim -delete -sid TSH1
    oradim -new -sid TSH2 -intpwd password -startmode a -pfile c:\oracle\920\database\spfileTSH2.ora
    If you are using UNIX/Linux simply reset the ORACLE_SID environment variable:
    ORACLE_SID=TSH2; export ORACLE_SID
  • STEP 9: Alter the listener.ora and tnsnames.ora setting to match the new database name and restart the listener:
    lsnrctl reload
  • STEP 10: Open the database with RESETLOGS:
    STARTUP MOUNT
    ALTER DATABASE OPEN RESETLOGS;
  • STEP 11: Backup the database.

Thursday, February 20, 2014

Renaming a Linux Host running Oracle 11gR2

Renaming a Linux Host running Oracle 11gR2
In this blog post, we are going to rename the Linux host name of an existing Oracle 11gR2 system. We can also use this technique to change the IP address of our host.
Host renames are a useful technique in virtualized environments, where vCenter may be used to clone entire hosts including the Oracle databases installed on them. This technique will also work with physical hosts should you wish to simply rename an existing Oracle host.
In 2009, Martin Nash who writes the ORAganism blog demonstrated the host rename process using Oracle 11.2.0.1. This post is heavily based on his work, but updated for Oracle 11.2.0.3. In this example I am using RedHat 6.0 but the process should be exactly the same for CentOS 6.x and OEL Linux.
Martin’s original work can be found here: ORAganism: Oracle Restart – Changing Hostname
Whereas this demonstration is not completely automated, it might form the basis of a fully scripted database deployment model for non-production use.
Time Required: 45 minutes

Part I – Deconfigure OEM/DBC.

Time Required: 5 mins.
Before renaming a host, it is important to shut down and remove the Oracle Enterprise Manager DB Console if it has been installed.
The emca tool allows the DBA to configure and de-configure the OEM/DBC repository. In this example we use the silent option. The command is as follows:
emca -deconfig dbcontrol db -repos drop -silent \
 -SID gctdev \
 -PORT 1521 \
 -LISTENER_OH /u01/app/11.2.0/grid \
 -SYS_PWD mypassword \
 -DBSNMP_PWD dbsnmp \
 -SYSMAN_PWD mypassword \
 -ASM_OH /u01/app/11.2.0/grid \
 -ASM_SID +ASM \
 -ASM_PORT 1521 \
 -ASM_USER_NAME asmsnmp \
 -ASM_USER_PWD mypassword

Most of these directives should be self explanatory. Note that directives here are case sensitive and must be upper-case.
DirectiveMeaning
SIDDatabase SID to be deconfigured
PORTListener port number used by database instance
LISTENER_OHThe Oracle Home path where the listener is running
SYS_PWDThe SYS user password
DBSNMP_PWDThe DBSNMP user password
SYSMAN_PWDThe SYSMAN user password
ASM_OHThe Oracle Home path where the ASM instance is running
ASM_SIDThe ASM instance SID name
ASM_PORTListener port number used by ASM instance
ASM_USER_NAMEThe ASM user name to connect to the ASM instance
ASM_USER_PWDThe password of the ASM user used to connect to the ASM instance
These directives may optionally be placed into a response file rather than added on the command line. If a response file is used they will be presented as follows:
SID=gctdev
PORT=1521
LISTENER_OH=/u01/app/11.2.0/grid

The emca tool can then be invoked with the -respFile=[filename] directive to include the response file.
We can now launch emca to deconfigure OEM/DBC:
STARTED EMCA at Jan 11, 2013 12:50:13 PM
EM Configuration Assistant, Version 11.2.0.3.0 Production
Copyright (c) 2003, 2011, Oracle.  All rights reserved.


----------------------------------------------------------------------
WARNING : While repository is dropped the database will be put in quiesce mode.
----------------------------------------------------------------------
Jan 11, 2013 12:50:14 PM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /u01/app/oracle/cfgtoollogs/emca/gctdev/emca_2013_01_11_12_50_13.log.
Jan 11, 2013 12:50:14 PM oracle.sysman.emcp.util.DBControlUtil stopOMS
INFO: Stopping Database Control (this may take a while) ...
Jan 11, 2013 12:50:35 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Dropping the EM repository (this may take a while) ...
Jan 11, 2013 12:51:52 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully dropped
Enterprise Manager configuration completed successfully
FINISHED EMCA at Jan 11, 2013 12:51:59 PM

In some cases the deconfig script will not complete cleanly. It is good practice to check the database to ensure that both the SYSMAN and MGMT_VIEW users as well as the MGMT_USER role have been dropped.

Part II – Shutdown Oracle Databases and Grid Infrastructure.

Time Required: 5 mins.
With OEM/DBC deconfigured, we can shut down the Oracle software on the server. In this example I am using crs_stop to do the shutdown:
[oracle@attila ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.DATA.dg    ora....up.type ONLINE    ONLINE    attila      
ora....ER.lsnr ora....er.type ONLINE    ONLINE    attila      
ora.asm        ora.asm.type   ONLINE    ONLINE    attila      
ora.cssd       ora.cssd.type  ONLINE    ONLINE    attila      
ora.diskmon    ora....on.type OFFLINE   OFFLINE               
ora.evmd       ora.evm.type   ONLINE    ONLINE    attila      
ora.gctdev.db  ora....se.type ONLINE    ONLINE    attila      
ora.ons        ora.ons.type   OFFLINE   OFFLINE

[oracle@attila ~]$ crs_stop -all
CRS-2500: Cannot stop resource 'ora.diskmon' as it is not running
CRS-2500: Cannot stop resource 'ora.ons' as it is not running
Attempting to stop `ora.evmd` on member `attila`
Attempting to stop `ora.DATA.dg` on member `attila`
Attempting to stop `ora.gctdev.db` on member `attila`
Attempting to stop `ora.LISTENER.lsnr` on member `attila`
Stop of `ora.LISTENER.lsnr` on member `attila` succeeded.
Stop of `ora.evmd` on member `attila` succeeded.
Stop of `ora.gctdev.db` on member `attila` succeeded.
Stop of `ora.DATA.dg` on member `attila` succeeded.
Attempting to stop `ora.asm` on member `attila`
Stop of `ora.asm` on member `attila` succeeded.
Attempting to stop `ora.cssd` on member `attila`
Stop of `ora.cssd` on member `attila` succeeded.
CRS-0216: Could not stop resource 'ora.diskmon'.

CRS-0216: Could not stop resource 'ora.ons'.
We can now check to see that everything is down:
[oracle@attila ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.DATA.dg    ora....up.type OFFLINE   OFFLINE               
ora....ER.lsnr ora....er.type OFFLINE   OFFLINE               
ora.asm        ora.asm.type   OFFLINE   OFFLINE               
ora.cssd       ora.cssd.type  OFFLINE   OFFLINE               
ora.diskmon    ora....on.type OFFLINE   OFFLINE               
ora.evmd       ora.evm.type   OFFLINE   OFFLINE               
ora.gctdev.db  ora....se.type OFFLINE   OFFLINE               
ora.ons        ora.ons.type   OFFLINE   OFFLINE 

Part III – Deconfigure Oracle Restart.

Time Required: 5 mins.
Next we are going to log in as root and deconfigure the Oracle Restart components. The command to do this has changed slightly since earlier releases. For 11.2.0.3 the command is as follows:
$ORACLE_HOME/perl/bin/perl -I \
  $ORACLE_HOME/perl/lib -I $ORACLE_HOME/crs/install \
  $ORACLE_HOME/crs/install/roothas.pl -deconfig -force
Log in as root and source the Oracle ASM environment so that we are pointed at the Grid home, and then execute the command:
[root@attila ~]# . oraenv
ORACLE_SID = [root] ? +ASM
The Oracle base has been set to /u01/app/oracle

[root@attila ~]# $ORACLE_HOME/perl/bin/perl -I \
  $ORACLE_HOME/perl/lib -I $ORACLE_HOME/crs/install \
  $ORACLE_HOME/crs/install/roothas.pl -deconfig -force
Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params
CRS resources for listeners are still configured
PRKO-2573 : ONS daemon is already stopped.
CRS-2500: Cannot stop resource 'ora.cssd' as it is not running
CRS-4000: Command Stop failed, or completed with errors.
CRS-4133: Oracle High Availability Services has been stopped.
Successfully deconfigured Oracle Restart stack

Part IV – Rename the Host.

Time Required: 5 mins.
While logged in as root, we can rename our Linux host and update the IP address. The files we typically edit for this are as follows:
  • /etc/sysconfig/network
  • /etc/hosts
  • /etc/sysconfig/network-scripts/ifcfg-eth0
In my case I am going to rename my host Attila to another character from the same opera; Odabella. Below is my revised /etc/sysconfig/network file:
[root@attila ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=odabella.operanet

Once this is done, reboot the Linux machine so that the new settings take effect. Don’t worry about the database trying to start, we disabled Oracle Restart so it will stay down.

Part V – Configure Oracle Restart.

Time Required: 5 mins.
Once the server comes back up, check that the new hostname and network addresses are working as expected, before trying to reconfigure Oracle.
Once we are satisfied our Linux machine has the correct new identity, we can use the following command to re-configure Oracle Restart:
$ORACLE_HOME/perl/bin/perl -I \
  $ORACLE_HOME/perl/lib -I \
  $ORACLE_HOME/crs/install $ORACLE_HOME/crs/install/roothas.pl
Log in as root and source the Oracle ASM environment so that we are pointed at the Grid home, and then execute the command:
[root@odabella ~]# . oraenv
ORACLE_SID = [root] ? +ASM
The Oracle base has been set to /u01/app/oracle

[root@odabella ~]# $ORACLE_HOME/perl/bin/perl -I \
>   $ORACLE_HOME/perl/lib -I \
>   $ORACLE_HOME/crs/install $ORACLE_HOME/crs/install/roothas.pl
Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params
LOCAL ADD MODE 
Creating OCR keys for user 'oracle', privgrp 'oinstall'..
Operation successful.
LOCAL ONLY MODE 
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
CRS-4664: Node odabella successfully pinned.
Adding Clusterware entries to upstart

odabella     2013/01/10 22:29:25     /u01/app/11.2.0/grid/cdata/odabella/backup_20130110_222925.olr
Successfully configured Oracle Grid Infrastructure for a Standalone Server 

Part VI – Reconfigure Oracle Listener, ASM and DB.

Time Required: 10 mins.
Log into the server as the Oracle user and source the Oracle ASM environment so that we are pointed at the Grid home. We can now update the listener files and add the listener, the ASM instance and the databases back into our configuration:
First, edit the listener.ora file and update the host name:
[oracle@odabella ~]$ cat $ORACLE_HOME/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/11.2.0/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = odabella.operanet)(PORT = 1521))
    )
  )

Next we add the listener back into the Oracle Restart configuration: (SID=+ASM)
[oracle@odabella ~]$ srvctl add listener

Next we add the ASM instance back in, setting the ASM disk discovery string as we do.(SID=+ASM)
[oracle@odabella ~]$ srvctl add asm -d '/dev/oracleasm/*'

Next we start the listener and the ASM instance:(SID=+ASM)
[oracle@odabella ~]$ srvctl start listener
[oracle@odabella ~]$ srvctl start asm

We now need to mount any disk groups that we use in ASM. In this example I have only the DATA diskgroup:(+ASM)
[oracle@odabella ~]$ asmcmd mount DATA
Now we can add the diskgroup under Oracle Restart control:(SID=+ASM)
[oracle@odabella ~]$ srvctl status diskgroup -g DATA
Finally we can add our databases back into the configuration. The command to do this is as follows:(+ASM)
srvctl add database -d gctdev \
 -o /u01/app/oracle/product/11.2.0/dbhome_1 \
 -n gctdev \
 -p +DATA/gctdev/spfilegctdev.ora \
 -a DATA
The arguments here are as follows:
ArgumentMeaning
dDatabase Name
oOracle Home of the database
nInstance Name
pParameter file location
aASM Diskgroups to mount
Note: Be careful to specify the Oracle Home of the database here and not the ASM home. I find it best to fully specify the path and not rely on environment variables.
We can verify our database configuration as follows:(SID=+ASM)
[oracle@odabella ~]$ srvctl config database -d gctdev
Database unique name: gctdev
Database name: gctdev
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +DATA/gctdev/spfilegctdev.ora
Domain: 
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Database instance: gctdev
Disk Groups: DATA
Services:
If the configuration looks good, we should be able to start the database with the following command:(SID=+ASM)
[oracle@odabella ~]$ srvctl start database -d gctdev
If everything worked, you should be able to check the status with the crs_stat command:
[oracle@odabella ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.DATA.dg    ora....up.type ONLINE    ONLINE    attila      
ora....ER.lsnr ora....er.type ONLINE    ONLINE    attila      
ora.asm        ora.asm.type   ONLINE    ONLINE    attila      
ora.cssd       ora.cssd.type  ONLINE    ONLINE    attila      
ora.diskmon    ora....on.type OFFLINE   OFFLINE               
ora.evmd       ora.evm.type   ONLINE    ONLINE    attila      
ora.gctdev.db  ora....se.type ONLINE    ONLINE    attila      
ora.ons        ora.ons.type   OFFLINE   OFFLINE
Check you can connect to the database from a different machine to ensure all components are working normally.

Part VII – Configure OEM/DBC (Optional).

Time Required: 10 mins.
If you need the OEM Database Control functionality on your renamed Linux host, then you will need to recreate the OEM repository. Again we can use the emca to do this silently.
The command to use is as follows:
emca -config dbcontrol db -repos create -silent \
 -SID gctdev \
 -PORT 1521 \
 -LISTENER_OH /u01/app/11.2.0/grid \
 -SYS_PWD mypassword \
 -DBSNMP_PWD dbsnmp \
 -SYSMAN_PWD mypassword \
 -ASM_OH /u01/app/11.2.0/grid \
 -ASM_SID +ASM \
 -ASM_PORT 1521 \
 -ASM_USER_NAME asmsnmp \
 -ASM_USER_PWD mypassword
You need to set the Oracle environment variables for the Oracle Home where the target database resides, if you are still pointing at the Grid home the command will fail.
The command can take some time to run, so be patient:
[oracle@odabella Desktop]$ . oraenv
ORACLE_SID = [+ASM] ? gctdev
The Oracle base remains unchanged with value /u01/app/oracle

[oracle@odabella ~]$ emca -config dbcontrol db -repos create -silent  -SID gctdev  -PORT 1521  -LISTENER_OH /u01/app/11.2.0/grid  -SYS_PWD mypassword  -DBSNMP_PWD dbsnmp  -SYSMAN_PWD mypassword  -ASM_OH /u01/app/11.2.0/grid  -ASM_SID +ASM  -ASM_PORT 1521  -ASM_USER_NAME asmsnmp  -ASM_USER_PWD mypassword

STARTED EMCA at Jan 11, 2013 12:40:51 PM
EM Configuration Assistant, Version 11.2.0.3.0 Production
Copyright (c) 2003, 2011, Oracle.  All rights reserved.

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

You have specified the following settings

Database ORACLE_HOME ................ /u01/app/oracle/product/11.2.0/dbhome_1

Local hostname ................ odabella.operanet
Listener ORACLE_HOME ................ /u01/app/11.2.0/grid
Listener port number ................ 1521
Database SID ................ gctdev
Email address for notifications ............... null
Outgoing Mail (SMTP) server for notifications ............... null
ASM ORACLE_HOME ................ /u01/app/11.2.0/grid
ASM SID ................ +ASM
ASM port ................ 1521
ASM user role ................ SYSDBA
ASM username ................ asmsnmp

-----------------------------------------------------------------
Jan 11, 2013 12:40:52 PM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /u01/app/oracle/cfgtoollogs/emca/gctdev/emca_2013_01_11_12_40_50.log.
Jan 11, 2013 12:40:53 PM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...
Jan 11, 2013 12:44:30 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully created
Jan 11, 2013 12:44:33 PM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository
INFO: Uploading configuration data to EM repository (this may take a while) ...
Jan 11, 2013 12:45:18 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Uploaded configuration data successfully
Jan 11, 2013 12:45:20 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Securing Database Control (this may take a while) ...
Jan 11, 2013 12:46:14 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Database Control secured successfully.
Jan 11, 2013 12:46:14 PM oracle.sysman.emcp.util.DBControlUtil startOMS
INFO: Starting Database Control (this may take a while) ...
Jan 11, 2013 12:46:47 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: Database Control started successfully
Jan 11, 2013 12:46:47 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: >>>>>>>>>>> The Database Control URL is https://odabella.operanet:1158/em <<<<<<<<<<<
Jan 11, 2013 12:46:50 PM oracle.sysman.emcp.EMDBPostConfig invoke
WARNING: 
************************  WARNING  ************************

Management Repository has been placed in secure mode wherein Enterprise Manager data will be encrypted.  The encryption key has been placed in the file: /u01/app/oracle/product/11.2.0/dbhome_1/odabella.operanet_gctdev/sysman/config/emkey.ora. Ensure this file is backed up as the encrypted data will become unusable if this file is lost. 

***********************************************************
Enterprise Manager configuration completed successfully
FINISHED EMCA at Jan 11, 2013 12:46:50 PM

Dataguard Switchover and failover steps:

Dataguard Switchover and failover steps:

A switchover allows the primary database to switch roles with its standby database. There is no data loss during a switchover. You can switch back to the original Primary database later by performing another switchover.

In case of primary database failure, you will need to perform failover to transition the standby database to the primary role. After a failover, the original primary database can no longer participate in the Data Guard configuration. So if the original Primary database is still accessible, you should always consider a switchover first.

This document only talks about switchover involving physical standby database. In this example, the original primary data is called PRIM and the original standby database is called STAN.

I. Before Switchover:

1. Verify the primary database instance is open.

SQL> Select Database_role from v$Database;
It will return “PRIMARY”,

2. Verify the standby database instance is mounted.

SQL> Select Database_role from v$Database;
It will return “PHYSICAL STANDBY”,

3. Verify there are no active users connected to the databases.

4. Make sure the last redo data transmitted from the Primary database was applied on the standby database. Issue the following commands on Primary database and Standby database to find out:

SQL>select sequence#, applied from v$archvied_log;

Perform SWITCH LOGFILE if necessary.

In order to apply redo data to the standby database as soon as it is received, use Real-time apply.

II. Quick Switchover Steps

1. Initiate the switchover on the primary database PRIM:
SQL>connect /@PRIM as sysdba
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;

2. After step 1 finishes, Switch the original physical standby db STAN to primary role;
Open another prompt and connect to SQLPLUS:
SQL>connect /@STAN as sysdba
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

3. Immediately after issuing command in step 2, shut down and restart the former primary instancePRIM:
SQL>SHUTDOWN IMMEDIATE;
SQL>STARTUP MOUNT;

4. After step 3 completes, you can open the new Primary database STAN:
SQL>ALTER DATABASE OPEN;

STAN is now transitioned to the primary database role.Now your PHYSICAL STANDBY Database has become PRIMARY. To verify this change, again query the Database_role column of V$DATABASE. Now it will return “PRIMARY”.
SQL> Select Database_role from v$Database;

5. On the new primary database STAN, perform a SWITCH LOGFILE to start sending redo data to the standby database PRIM.
SQL>ALTER SYSTEM SWITCH LOGFILE;



FAILOVER

1. Initiate the failover on the standby database STAN:
SQL>connect /@STAN as sysdba
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

2. Immediately after issuing command in step 2, shut down and restart the standby instance STAN:
SQL>SHUTDOWN IMMEDIATE;
SQL>STARTUP;

STAN is now transitioned to the primary database role.Now your PHYSICAL STANDBY Database has become PRIMARY. To verify this change, again query the Database_role column of V$DATABASE. Now it will return “PRIMARY”.
SQL> Select Database_role from v$Database;

  How to Change Instance Type & Security Group of EC2 in AWS By David Taylor Updated April 29, 2023 EC2 stands for Elastic Compute Cloud...