Sunday, December 14, 2014

How to delete spfile entries in Oracle 11gr2


Do not use '' or 'NULL' values. Use instead following reset -value

alter system reset parameter scope sid='*';

e.g.

alter system reset db_file_name_convert scope=spfile sid='*';


How to create static listener for Data Guard in Grid Infrastructure Standby environment

My environment has Grid Infrastructure installed and hence two separate homes. Please note that this server works as Data Guard node with the intention to be used as Active Data Guard -mode.

GRID_HOME = /oracle/app/11.2.0/grid
DB_HOME = /oracle/app/oracle/product/11.2.0/dbhome_1/


Primary Database = primsid
Primary SERVICE_NAME = PRIMARYSVC
Data Guard database instance name = DGSID
Data Guard database unique name = primsiddg
Data Guard SERVICE_NAME = DGSVC

What I wanted:

I wanted to create static listener for my Data Guard database, because I wanted to create the Data Guard -database from using the 'Active duplicate' -mode. This requires the standby database can be connected using listener connection even though the database is in NOMOUNT -state.


How to achieve this;

1) Do no create listener.ora in the GRID_HOME. Leave it empty.
2) Create listener.ora in the DB_HOME. These are my settings. Please note ORACLE_HOME and ADR_BASE_LISTENER - values.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = DGSVC)
      (ORACLE_HOME = /oracle/app/oracle/product/11.2.0/dbhome_1)
      (SID_NAME = DGSID)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = dg-server.domain.com)(PORT = 1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /oracle/app/oracle/product/11.2.0/dbhome_1

3) Start the listener GRID_HOME with grid environment variables on
4) Check listener status

oracle@dg-server:/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin$ listener status

LSNRCTL for Solaris: Version 11.2.0.4.0 - Production on 14-DEC-2014 17:34:58

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dg-server.domain.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Solaris: Version 11.2.0.4.0 - Production
Start Date                14-DEC-2014 17:33:42
Uptime                    0 days 0 hr. 1 min. 15 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File   /oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /oracle/app/oracle/product/11.2.0/dbhome_1/diag/tnslsnr/dg-server/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg-server)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM", status READY, has 1 handler(s) for this service...
Service "DGSVC" has 2 instance(s).
  Instance "DGSID", status UNKNOWN, has 1 handler(s) for this service...
  Instance "DGSID", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully

In case you see double services like this "BLOCKED" -- check your local_listener -value at database and clear the value.

SQL> alter system set local_listener = '';

Jarjestelma on muutettu.

SQL> alter system register;


Jarjestelma on muutettu.


5) If you have instance with UNKNOWN -status, you're ok. UNKNOWN is the status which we want.
6) Start database with pfile on nomout -state
SQL> startup nomount pfile = 'initPRIMSID.ora';
ORACLE instance started.

Total System Global Area 6415736832 bytes
Fixed Size                  2239440 bytes
Variable Size            1136661552 bytes
Database Buffers         5272240128 bytes

Redo Buffers                4595712 bytes
7) Restore controlfiles
RMAN> restore controlfile from 'PRIMSID_stby.ctl';

8) Start active duplication
oracle@dg-server:/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin$ rman TARGET sys/pw@PRIMARYSVC AUXILIARY sys/pw@DGSVC

Recovery Manager: Release 11.2.0.4.0 - Production on Sun Dec 14 17:46:34 2014

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

connected to target database: PRIMSID (DBID=1185966409)
connected to auxiliary database: DGSID (not mounted)


Wednesday, December 3, 2014

How to move disks inside ASM diskgroups


Simple commands (without any details go as follow). Modify the datafile names to suit your own needs. These files do not use OMF and hence full filename needs to said during RMAN commands.

Locate file which needs to be moved;
SQL> SELECT file_name FROM dba_data_files;


Take the file offline;
SQL> ALTER DATABASE DATAFILE '+DATA/database/datafile/db_name_data01.dbf' OFFLINE;


Log on to RMAN
OS> rman target / 


Copy the datafile to new location
RMAN> COPY DATAFILE '+DATA/database/datafile/db_name_data01.dbf' TO '+DATA_DISK_GROUP_1/database/datafile/db_name_data01.dbf';


Log on to SQL to rename the file again
SQL> ALTER DATABASE RENAME FILE '+DATA/database/datafile/db_name_data01.dbf' TO '+DATA_DISK_GROUP_1/database/datafile/db_name_data01.dbf';


Log on to RMAN
OS> rman target /

Switch datafile
RMAN> SWITCH DATAFILE '+DATA_DISK_GROUP_1/database/datafile/db_name_data01.dbf' TO COPY;

Log on to SQL  to recover and put the file online again.

SQL> RECOVER DATAFILE '+DATA_DISK_GROUP_1/database/datafile/db_name_data01.dbf';
SQL> ALTER DATABASE DATAFILE '+DATA_DISK_GROUP_1/database/datafile/db_name_data01.dbf' ONLINE;

Done.