What is DB_UNIQUE_NAME?
DB_UNIQUE_NAME specifies a globally unique name for the database. Databases with the same DB_NAME within the same DB_DOMAIN (for example, copies of a database created for reporting or a physical standby) must have a unique DB_UNIQUE_NAME. Every database’s DB_UNIQUE_NAME must be unique within the enterprise.
The value of DB_UNIQUE_NAME can be up to 30 characters and is case insensitive. The following characters are valid in a database name: alphanumeric characters, underscore (_), number sign (#), and dollar sign ($).
Note:
- Â Oracle 11g database duplicate in cluster or ODA environments works straight forward
- Oracle 12c database duplicate in cluster or ODA environments requires first to remove the database resource from the cluster and to add it back afterwards.
Â
Changing the db_unique_name requires a complete restart of the database.
oracle@rac1.localdomain(RACDBDEV1): sqlplus sys/sys@+ASM as sysdba
SELECT name, free_mb, total_mb, free_mb/total_mb*100
as percentage
FROM v$asm_diskgroup;
NAMEÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â FREE_MB TOTAL_MB PERCENTAGE
------------------------------ ---------- ---------- ----------
FRAÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 11953 12284 97.305438
DATAÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 9472 16377 57.8372107
Â
1)Â Create pfile: Backup Database and the the pfile
oracle@bt1.localdomain(RACDBDEV1):
sqlplus / as sysdba
show parameter spfile;
NAME TYPE VALUE
———————————— ———– ——————————
spfile string +DATA/RACDBDEV/PARAMETERFILE/spfileRACDBDEV1.ora
Â
create pfile=’$ORACLE_HOME/dbs/initRACDBDEV_may8.ora’ from spfile;
Â
this ensures that the pfile you are about to edit contains all the current settings. It is saved in a non-standard location for safety.
Â
Remove the database, instance and service resources from CRS, this does NOT affect database itself.
oracle@rac1.localdomain(RACDBDEV1): srvctl status database -d RACDBDEV
Instance RACDBDEV1 is running on node rac1
Instance RACDBDEV2 is running on node rac2
oracle@rac1.localdomain(RACDBDEV1):
srvctl config database -d RACDBDEV
oracle@rac1.localdomain(RACDBDEV1):
srvctl stop database -d RACDBDEV
oracle@rac1.localdomain(RACDBDEV1):
srvctl remove database -d RACDBDEV
2) Start the database and change the db_unique_name at database level.
sqlplus sys/sys@RACDBDEV as sysdba
Startup;
show parameter db_unique_name
Â
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_unique_name string RACDBDEV
show parameter db_domain
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_domain string localdomain
show parameter global_names
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
global_names boolean FALSE
Â
Â
Backup Database and the the pfile
oracle@bt1.localdomain(RACDBDEV1):
sqlplus / as sysdba
show parameter spfile;
NAME TYPE VALUE
———————————— ———– ——————————
spfile string +DATA/RACDBDEV/PARAMETERFILE/spfileRACDBDEV1.ora
Â
create pfile=’$ORACLE_HOME/dbs/initRACDBDEV_may8.ora’ from spfile;
Â
this ensures that the pfile you are about to edit contains all the current settings. It is saved in a non-standard location for safety.
Â
alter system set db_unique_name=RACTEST scope=spfile sid='*';
--- alter system set db_domain=TEST.abc.com scope=spfile sid='*'; << only required when db_domain needs to be changed. SQL> alter database rename global_name to test_test.abc.com;
--- alter system set db_domain=hotus.com scope=spfile sid='*';
--- alter database rename global_name to RACTEST.hotus.com;Â Â
Â
Possible Error:
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified
????
Â
ORA-65500: could not modify DB_UNIQUE_NAME, resource existsÂ
Â
Solution:
The only thing that cured this was to remove the database with srvctl which defeats the purpose.
 srvctl status database -d BTRAC
Instance RACDBDEV1 is not running on node bt1
Instance RACDBDEV2 is running on node bt2
srvctl stop database -d BTRAC
Â
srvctl remove database -d BTRAC
Remove the database BTRAC? (y/[n]) y
Y
Â
sqlplus sys/sys as sysdba
alter system set db_unique_name=RACTEST scope=spfile sid='*';
Â
3) Now add the database resource to cluster-level.
(As grid or oracle)
srvctl add database -d RACDBDEV -n bt1 -o /u01/app/oracle/product/12.1.0/dbhome_1 -p +DATA/RACDBDEV/PARAMETERFILE/spfileRACDBDEV1.ora
srvctl add instance -d RACDBDEV -i RACDBDEV1 -n bt1
srvctl add instance -d RACDBDEV -i RACDBDEV2 -n bt2
 4) Create dependency between database and ASM instance so that database starts after ASM instance starts.Â
(As grid or oracle)
srvctl modify instance -d RACDBDEV -i RACDBDEV1 -n bt1.localdomain -s +DATA
srvctl modify instance -d RACDBDEV -i RACDBDEV2 -n bt2.localdomain
srvctl status database -d RACDBDEV
Instance RACDBDEV1 is not running on node bt1
Instance RACDBDEV2 is not running on node bt2
srvctl add database -d RACDBDEV -i RACDBDEV1 -o $ORACLE_HOME -n bt1
srvctl add database -d RACDBDEV -i RACDBDEV2 -o $ORACLE_HOME -n bt2
Â
#$ srvctl add database -d myowndb -o $ORACLE_HOME -p $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
Please note that, for 11.2, it is no longer required to modify at instance level, it should be done at database level:
srvctl modify database -d <db_unique_name> -a "<diskgroup_list>
5) Create database service: the following example add service with both instances as preferredÂ
srvctl add service -d RACDBDEV -s RACDBDEVsrv -r " RACDBDEV1, RACDBDEV2"
Â
srvctl config database -d RACDBDEV
Â
Â
Â
-
Re-register amdbh12 – Administrator-managed RAC database having instances on host01, host02
- Spfile:Â On ASM
- Password file:Â On ASM
-
Database type-specific options / actions
- -dbtype RAC: To specify RAC database type
- Add instances separately using srvctl add instance
- -dbtype RAC: To specify RAC database type
- Spfile:Â On ASM
[oracle@host02 root]$ srvctl add database -d amdbh12 -oraclehome
/u01/app/oracle/product/12.1.0/dbhome_1 -dbtype RAC -spfile
+DATA/AMDBH12/PARAMETERFILE/spfile.301.928600475 -pwfile
+DATA/AMDBH12/PASSWORD/pwdamdbh12.291.928599609
Â
[oracle@host02 root]$ srvctl add instance -i amdbh121 -n host01 -d amdbh12
[oracle@host02 root]$ srvctl add instance -i amdbh122 -n host02 -d amdbh12
Â
Â
Â
– Check the database is now registered with clusterware
[root@host01 trace]# crsctl stat res -t |grep newdb
Â
Demo – How to Rename a single / RAC Database
Method 1: Recreate control file with the new DB name, the old tried and tested method.
Method 2: Use dbnew utility called NID

Node 1: bt1.localdomain SID: RACDBDEV1 DB_NAME: RACDBDEV
Node 2: bt2.localdomain SID: RACDBDEV2 DB_NAME: RACDBDEV
                        New DB_NAME: BTRAC
Â
How to find out if you’re accessing a RAC database?
You can tell if it is a cluster database by looking to see if the cluster database parameter is set:
Â
1)
Query
v$parameter to confirm that it’s a cluster database::
select name, value from v$parameter where name=’cluster_database’;Â
Â
NAMEÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â VALUEÂ
———————Â ———————Â
cluster_database     TRUEÂ
Â
If the cluster_database is set to “TRUE”, then the instance is RAC enabled.
Â
2)
Execute dbms_utility.is_cluster_database:
set serveroutput onÂ
 BEGINÂ
 IF dbms_utility.is_cluster_database THENÂ
     dbms_output.put_line(‘Running in SHARED/RAC mode.’);Â
 ELSEÂ
     dbms_output.put_line(‘Running in EXCLUSIVE mode.’);Â
 END IF;Â
END;Â
/Â
3)
Confirm if RAC is active
Query V$ACTIVE_INSTANCES – to tell how many instances are active:
Â
col INST_NAME FOR a30
select dbid, name from v$database;
SELECT * FROM V$ACTIVE_INSTANCES;Â
INST_NUMBER INST_NAMEÂ Â Â Â Â Â Â Â Â Â Â Â CON_ID
———– —————————— ——–
     $1 bt1.localdomain:RACDBDEV1        $0
     $2 bt2.localdomain:RACDBDEV2        $0
Â
show parameter CLUSTER_DATABASE;
NAMEÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â TYPEÂ Â Â Â VALUE
———————————— ———– ——————————
cluster_database           boolean   TRUE
cluster_database_instances      integer   2
Â
If cluster_database is set to “TRUE” instance is RAC is enabled.
Â
select * from v$session where type =’BACKGROUND’;
Â
Using the ps command to query for the RAC background processes:Â
Here we can see whether we are running RAC – Â query for the RAC background processes using the ps command:
ps -ef | grep lck
Â
grid   4692   1 0 12:47 ?    00:00:00 asm_lck1_+ASM2
grid   4716   1 0 12:47 ?    00:00:01 asm_lck0_+ASM2
oracle  14992   1 0 14:29 ?    00:00:01 ora_lck1_RACDBDEV2
oracle  15028   1 0 14:29 ?    00:00:00 ora_lck0_RACDBDEV2
oracle  20711 4542 0 14:44 pts/0  00:00:00 grep lck
Steps to rename RAC Databases using the dbnew NID utility:
Â
I) To change only DBID just invoke: Â Â Â Â Â Â Â Â Â Â
    nid target=username/pass
II) To change both DBID and DBNAME invoke: Â Â
    nid target=username/pass DBNAME=new_database_name
III)To change only DBNAME invoke: Â Â Â Â Â Â Â Â Â Â Â Â Â
    nid target=username/pass DBNAME=new_database_name SETNAME=y
Â
-
Backup Database and the the pfile
oracle@bt1.localdomain(RACDBDEV1):
sqlplus / as sysdba
create pfile=’/home/oracle/initold_RACDBDEV1.ora’ from spfile;
Â
this ensures that the pfile you are about to edit contains all the current settings. It is saved in a non-standard location for safety.
Â
-
Stop rac database
oracle@bt1.localdomain(RACDBDEV1):
srvctl status database -d RACDBDEV
Instance RACDBDEV1 is running on node bt1
Instance RACDBDEV2 is running on node bt2
srvctl stop database -d RACDBDEV
Â
-
startup mount the database:
oracle@bt1.localdomain(RACDBDEV1):
sqlplus / as sysdba
startup mount
exit
Â
-
Exit and run the “nid” utility – we only need change the db_name
Incase of RAC, we need to set cluster_database=FALSE to change DB name. Then stop and mount the DB again
alter system set cluster_database=FALSE scope=spfile;
shutdown immediate;
startup mount
exit
Â
nid target=/ DBNAME=BTRAC SETNAME=y logfile=BTRAC_Instance.log
more BTRAC_Instance.log
Â
DBNEWID: Release 12.1.0.2.0 – Production on Wed May 3 15:45:36 2017
Â
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
Â
Connected to database RACDBDEV (DBID=940509235)
Â
Connected to server version 12.1.0
Â
Control Files in database:
  +DATA/RACDBDEV/CONTROLFILE/current.281.942892467
  +FRA/RACDBDEV/CONTROLFILE/current.256.942892467
Â
Changing database name from RACDBDEV to BTRAC
  Control File +DATA/RACDBDEV/CONTROLFILE/current.281.942892467 – modified
  Control File +FRA/RACDBDEV/CONTROLFILE/current.256.942892467 – modified
  Datafile +DATA/RACDBDEV/DATAFILE/system.278.94289238 – wrote new name
  Datafile +DATA/RACDBDEV/DATAFILE/sysaux.277.94289233 – wrote new name
  Datafile +DATA/RACDBDEV/DATAFILE/undotbs1.280.94289242 – wrote new name
  Datafile +DATA/RACDBDEV/DATAFILE/undotbs2.285.94289261 – wrote new name
  Datafile +DATA/RACDBDEV/DATAFILE/users.279.94289242 – wrote new name
  Datafile +DATA/RACDBDEV/TEMPFILE/temp.284.94289247 – wrote new name
  Control File +DATA/RACDBDEV/CONTROLFILE/current.281.942892467 – wrote new name
  Control File +FRA/RACDBDEV/CONTROLFILE/current.256.942892467 – wrote new name
  Instance shut down
Â
Database name changed to BTRAC.
Modify parameter file and generate a new password file before restarting.
Succesfully changed database name.
DBNEWID – Completed succesfully.
Â
The instance will also have been shut down at the end of the nid command.
Â
-
Copy the old initRACDBDEV1.ora as initnew1.ora, update the DB_NAME, instance_name parameter to reflect the new name.Then startup mount
Copy  and edit the newly created /home/oracle/initnew_sid.ora to $ORACLE_HOME/dbs/initnew_sid.ora then edit the new file and change the db_name parameter.
Â
cp /home/oracle/initold_RACDBDEV1.ora /home/oracle/initRACDBDEV1.ora
Â
sqlplus / as sysdba
startup mount;
ORACLE instance started.
Â
Total System Global Area  ######## bytes
Fixed Size         ######## bytes
Variable Size       ######## bytes
Database Buffers      ######## bytes
Redo Buffers        ######## bytes
ORA-01103: database name ‘BTRAC’ in control file is not ‘RACDBDEV’
Â
SYS @ RACDBDEV1 03:57:28> show parameter spfile
Â
NAMEÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â TYPEÂ Â Â Â VALUE
———————————— ———– ——————————
spfile                string   +DATA/RACDBDEV/PARAMETERFILE/spfi
                         le.288.942892669
Â
create pfile=’/home/oracle/initRACDBDEV1.ora’ from spfile;
exit
Â
Edit the pfile:
vi /home/oracle/initrac1.ora
  ChangeÂ
*.db_name=’BTRAC’
*.cluster_database=true
Â
sqlplus / as sysdba
Â
shutdown immediate
startup mount pfile=’/home/oracle/initRACDBDEV1.ora’
Â
-
Resetlog open the database.
Â
ALTER DATABASE OPEN;
 ??? RESETLOGS;
select open_mode from v$database;
OPEN_MODE
——————–Â
READ WRITE
Â
-
Create spfile
Â
Â
create spfile=’+DATA/RACDBDEV/PARAMETERFILE/spfileRACDBDEV1.ora’ from pfile=’/home/oracle/initRACDBDEV1.ora’;
—Â alter system set cluster_database=TRUE scope=spfile;
exit
Â
NOTE: Step 8 for RAC only. For single node DB, steps are over.
-
Add DB to the cluster
oracle@bt1.localdomain(RACDBDEV1):Â
srvctl add database -d BTRAC
-o $ORACLE_HOME -r primary -s OPEN -p +DATA/RACDBDEV/PARAMETERFILE/spfileRACDBDEV1.ora
srvctl add instance -d BTRAC -i RACDBDEV1 -n bt1
srvctl add instance -d BTRAC -i RACDBDEV2 -n bt2
srvctl config database -d BTRAC -a
Â
srvctl add database -d NEW -o $ORACLE_HOME -r primary -s OPEN -p +DATA/RACDBDEV/PARAMETERFILE/spfileRACDBDEV1.ora
srvctl add instance -d NEW -i NEW1 -n bt1
srvctl add instance -d NEW -i NEW2 -n bt2
srvctl config database -d NEW -a
Â
Database unique name:NEW
Database name:
Oracle home: /home/oracle/product/11.2
Oracle user: oracle
Spfile: +DG_SYS01/NEW/spfileNEW.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: NEW
Database instances: NEW1,NEW2
Disk Groups:
Mount point paths:
Services:
Type: RAC
Database is enabled
Database is administrator managed
oracle@bt1.localdomain(RACDBDEV1): srvctl start database -d BTRAC
Â
Possible ERROR:
PRCR-1079 : Failed to start resource ora.btrac.db
CRS-5017: The resource action “ora.btrac.db start” encountered the following error:
ORA-01102: cannot mount database in EXCLUSIVE mode
. For details refer to “(:CLSN00107:)” in “/u01/app/grid/diag/crs/bt2/crs/trace/crsd_oraagent_oracle.  trc”.
CRS-2674: Start of ‘ora.btrac.db’ on ‘bt2’ failed
CRS-2632: There are no more servers to try to place resource ‘ora.btrac.db’ on that would satisfy its  placement policy
Â
Solution:
Recreate spfile with *.cluster_database=true
in /home/oracle/initRACDBDEV1.ora
oracle@bt1.localdomain(RACDBDEV1): vi initRACDBDEV1.ora
Â
oracle@bt1.localdomain(RACDBDEV1):srvctl start database -d BTRAC
oracle@bt1.localdomain(RACDBDEV1):srvctl status database -d BTRAC
Instance RACDBDEV1 is running on node bt1
Instance RACDBDEV2 is running on node bt2
Â
Test second node:
oracle@bt1.localdomain(RACDBDEV1):ssh bt2
Last login: Wed May 3 17:11:53 2017 from redbox.fios-router.home
oracle@bt2.localdomain(RACDBDEV2):
srvctl status database -d BTRAC
Instance RACDBDEV1 is running on node bt1
Instance RACDBDEV2 is running on node bt2
Â
-
Edit /etc/oratab to change the old sid to the new one.
Â
-
Edit tnsnames.ora to do likewise. Also applies to OID, LDAP, whatever you use for alias resolution.
Â
-
Stop the appropriate listener, edit listener.ora and restart the listener. If the listener in question serves other databases, just edit the listener.ora file and run lsnrctl reload listener_name.
Â
Reference: Reference: (Doc ID 1604421.1)
Â