Friday, August 14, 2015

Moving non-RAC Database and ASM Between Servers

There are many strategies to moving a database from one server to another. Backup/duplication, exports base solutions are most common. This post list steps for moving a non-RAC database and ASM (standlone) by way of attaching the underlying storage to the new server. The steps here has been tested using Amazon EC2/ESB combination and using Oracle VirtualBox. As stated in title the current setup includes a standalone non-RAC database using ASM.
1. To able to use ASM in the new sever, install grid infrastructure with software only option. This allow installation of GI without having to create ASM disk groups.

2. When prompted run the root scripts.
# /opt/app/oracle/product/11.2.0/grid_1/root.sh
Performing root user operation for Oracle 11g

The following environment variables are set as:
    ORACLE_OWNER= grid
    ORACLE_HOME=  /opt/app/oracle/product/11.2.0/grid_1

Enter the full pathname of the local bin directory: [/usr/local/bin]:
The contents of "dbhome" have not changed. No need to overwrite.
The contents of "oraenv" have not changed. No need to overwrite.
The contents of "coraenv" have not changed. No need to overwrite.


Creating /etc/oratab file...
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.

To configure Grid Infrastructure for a Stand-Alone Server run the following command as the root user:
/opt/app/oracle/product/11.2.0/grid_1/perl/bin/perl -I/opt/app/oracle/product/11.2.0/grid_1/perl/lib -I/opt/app/oracle/product/11.2.0/grid_1/crs/install /opt/app/oracle/product/11.2.0/grid_1/crs/install/roothas.pl


To configure Grid Infrastructure for a Cluster execute the following command:
/opt/app/oracle/product/11.2.0/grid_1/crs/config/config.sh
This command launches the Grid Infrastructure Configuration Wizard. The wizard also supports silent operation, and the parameters can be passed through the response file that is available in the installation media.


# /opt/app/oracle/product/11.2.0/grid_1/perl/bin/perl -I/opt/app/oracle/product/11.2.0/grid_1/perl/lib -I/opt/app/oracle/product/11.2.0/grid_1/crs/install /opt/app/oracle/product/11.2.0/grid_1/crs/install/roothas.pl
Using configuration parameter file: /opt/app/oracle/product/11.2.0/grid_1/crs/install/crsconfig_params
Creating trace directory
User ignored Prerequisites during installation
LOCAL ADD MODE
Creating OCR keys for user 'grid', 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 rhel6m1 successfully pinned.
Adding Clusterware entries to upstart

rhel6m1     2015/03/10 16:40:10     /opt/app/oracle/product/11.2.0/grid_1/cdata/rhel6m1/backup_20150310_164010.olr
Successfully configured Oracle Grid Infrastructure for a Standalone Server
3. GI will have following resources created at this stage
$ crsctl stat res
NAME=ora.cssd
TYPE=ora.cssd.type
TARGET=OFFLINE
STATE=OFFLINE

NAME=ora.diskmon
TYPE=ora.diskmon.type
TARGET=OFFLINE
STATE=OFFLINE

NAME=ora.evmd
TYPE=ora.evm.type
TARGET=ONLINE
STATE=ONLINE on rhel6m1

NAME=ora.ons
TYPE=ora.ons.type
TARGET=OFFLINE
STATE=OFFLINE
4. Install database software with software only option. Patch both GI and database software to the same patch level as the current database setup where database being moved from.
5. If role separation being used them some directory locations ($ORACLE_BASE/admin, $ORACLE_BASE/cfgtoollogs) may not have write permissions for Oracle user, permissions might be set as 755 grid : oinstall. Change permissions as 775 to allow oracle user the write access to these location. Also manually create the audit file location
mkdir -p /opt/app/oracle/admin/ent11g2/adump
6. Copy the listener file from current setup to new server's $GI_HOME/network/admin. Change all reference to the hostname to reflect the new hostname.



7. Attach the storage device(s) to the new server. Depending on the storage type this may require server to shutdown. Once the server is restarted verify the disks that will be used by ASM are visible.Also HA services are running
# crsctl stat res

NAME=ora.cssd
TYPE=ora.cssd.type
TARGET=ONLINE
STATE=ONLINE on rhel6m1
8. With storage attached its only a matter of configuring listener,ASM and database so HAS manage them. First add the listener as grid user.
$ srvctl add listener -l listener -o /opt/app/oracle/product/11.2.0/grid_1 -p 1521
$ srvctl start listener -l listener
$ srvctl status listener -l listener
Listener LISTENER is enabled
Listener LISTENER is running on node(s): rhel6m1
9. Secondly add the ASM as grid user. The ASM pfile is located in the local server as opposed to ASM itself.
$ srvctl add asm -l listener -p /opt/app/oracle/product/11.2.0/grid_1/dbs/spfile+ASM.ora -d "/dev/sd*"
$ srvctl start asm
$ srvctl config asm
ASM home: /opt/app/oracle/product/11.2.0/grid_1
ASM listener: LISTENER
Spfile: /opt/app/oracle/product/11.2.0/grid_1/dbs/spfile+ASM.ora
ASM diskgroup discovery string: /dev/sd*
10. Finally as oracle user add the database and modify the auto start options of the resources
srvctl add database -d ent11g2 -o /opt/app/oracle/product/11.2.0/dbhome_1 -p +DATA/ent11g2/spfileent11g2.ora -a "data,flash,apps"
srvctl start database -d ent11g2

crsctl modify resource ora.DATA.dg -attr "AUTO_START"="always"
crsctl modify resource ora.FLASH.dg -attr "AUTO_START"="always"  
crsctl modify resource ora.LISTENER.lsnr -attr "AUTO_START"="always"  
crsctl modify resource ora.ent11g2.db -attr "AUTO_START"="always"
This concludes the steps for moving non-RAC database and ASM by way of attaching storage from one server to another.