Thursday, April 2, 2015

Switchover database in dataguard

Here I have a primary database name prmy and a physical standby database called stdby. First I will switchover and make stdby as the new primary and prmy as the new physical standby:

1. export ORACLE_SID=prmy
2. sqlplus / as sysdba
3. alter database commit to switchover to physical standby with current session shutdown wait;
4. shutdown immediate
5. startup mount
6. alter database recover managed standby database disconnect;
7. exit
8. export ORACLE_SID=stdby
9. sqlplus / as sysdba
10. alter database commit to switchover to primary with session shutdown wait;
11. alter database open;

Enable Real Time Query in Oracle Data Guard

I have a physical standby database called stdby. I am going to enable real time query on it:

1. export ORACLE_SID=stdby
2. sqlplus / as sysdba
3. alter database recover managed standby database cancel;
4. alter database open;
5. alter database recover managed standby database using current logfile disconnect;


To disable real time query:

1. export ORACLE_SID=stdby
2. sqlplus / as sysdba
3. shutdown immediate
4. startup mount
5. alter database recover managed standby database disconnect;

Create a Snapshot Standby Database

Here I have a standby database named stdby which is a PHYSICAL STANDBY. I will convert it to a SNAPSHOT STANDBY:

1.  export ORACLE_SID=stdby
2. sqlplus / as sysdba
3. alter database recover managed standby database cancel;
4. alter database convert to snapshot standby

To revert back to physical standby

1. export ORACLE_SID=stdby
2. sqlplus / as sysdba
3. shutdown immediate
4. startup mount
5. alter database convert to physical standby;
6. shutdown immediate
7. startup mount
8. alter database recover managed standby database disconnect;

Create tablespace in shared storage

1. Create the directory which will act as the mount point:



[root@node1 ~]# mkdir -p /u01/nfs_storage

2. Make the necessary entries in the /etc/exports file:
/u01/nfs_storage *(rw,sync,no_wdelay,insecure,insecure_locks,no_root_squash)

3. Start the nfs service:



[root@node1 ~]# chkconfig nfs on
[root@node1 ~]# service nfs restart

4.Make the directory that will store the shared files



[root@node1 ~]# mkdir -p /u01/nfs_oradata
 
5. Make the entries in the /etc/fstab file:



node1:/u01/nfs_storage /u01/nfs_oradata nfs rw,bg,hard,nointr,tcp,vers=3,timeo=600,rsize=32768,wsize=32768  0 0

6. Now mount the nfs_oradata folder

[root@node1 ~]# mount /u01/nfs_oradata/

7, Make the directory where the tablespace is to be created and give the necessary ownereship:


[root@node1 ~]# mkdir -p /u01/nfs_oradata/orcl
[root@node1 ~]# chown -R oracle:oinstall /u01/nfs_oradata/orcl
 

  
8. Shutdown the database:

[oracle@node1 ~]$ sqlplus / as sysdba
 
SQL> shutdown immediate
  
SQL> exit

9. Format the directory in nfs format:

[oracle@node1 ~]$ cd /u01/app/oracle/product/11.2.0/db_1/rdbms/lib/
[oracle@node1 lib]$ make -f ins_rdbms.mk dnfs_on

10. Startup the database instance:

[oracle@node1 lib]$ sqlplus / as sysdba

SQL> startup

 11. Create the shared tablespace:

SQL> create tablespace tbs1 datafile '/u01/nfs_oradata/orcl/ts_01.DBF' SIZE 10m;
 
12. Check the shared storage information:

SQL> select * from v$dnfs_servers;
 
SQL> select * from v$dnfs_files;