Wednesday, 27 November 2019

Oracle NID UTILITY TARGET -- Change DBNAME ONLY


  • [oracle@srv3 admin]$ sqlplus sys/system123@rac as sysdba


SQL*Plus: Release 12.1.0.2.0 Production on Wed Nov 27 17:11:06 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> sho parameter db_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_name                              string      RAC
SQL> sho parameter db_unique

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      RAC
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options


  • [oracle@srv3 admin]$ nid TARGET=sys/system123@RAC DBNAME=STDRAC SETNAME=YES


DBNEWID: Release 12.1.0.2.0 - Production on Wed Nov 27 17:11:30 2019

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

Connected to database RAC (DBID=2608333762)

NID-00121: Database should not be open


Change of database name failed during validation - database is intact.
DBNEWID - Completed with validation errors.

  • [oracle@srv3 admin]$ sqlplus sys/system123@rac as sysdba


SQL*Plus: Release 12.1.0.2.0 Production on Wed Nov 27 17:11:53 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options


  • SQL> shut immediate;

Database closed.
Database dismounted.
ORACLE instance shut down.
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor


Warning: You are no longer connected to ORACLE.
SQL> exit

  • [oracle@srv3 admin]$ sqlplus / as sysdba


SQL*Plus: Release 12.1.0.2.0 Production on Wed Nov 27 17:13:22 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to an idle instance.


  • SQL> startup mount;

ORACLE instance started.

Total System Global Area  754974720 bytes
Fixed Size                  2928968 bytes
Variable Size             549457592 bytes
Database Buffers          197132288 bytes
Redo Buffers                5455872 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options


  • [oracle@srv3 admin]$ nid TARGET=sys/system123@RAC DBNAME=STDRAC SETNAME=YES


DBNEWID: Release 12.1.0.2.0 - Production on Wed Nov 27 17:13:40 2019

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

Connected to database RAC (DBID=2608333762)

Connected to server version 12.1.0

Control Files in database:
    /u01/app/oracle/oradata/RAC/control01.ctl
    /u01/app/oracle/fast_recovery_area/RAC/control02.ctl


  • Change database name of database RAC to STDRAC? (Y/[N]) => Y


Proceeding with operation
Changing database name from RAC to STDRAC
    Control File /u01/app/oracle/oradata/RAC/control01.ctl - modified
    Control File /u01/app/oracle/fast_recovery_area/RAC/control02.ctl - modified
    Datafile /u01/app/oracle/oradata/RAC/system01.db - wrote new name
    Datafile /u01/app/oracle/oradata/RAC/idata01.db - wrote new name
    Datafile /u01/app/oracle/oradata/RAC/sysaux01.db - wrote new name
    Datafile /u01/app/oracle/oradata/RAC/undotbs01.db - wrote new name
    Datafile /u01/app/oracle/oradata/RAC/users01.db - wrote new name
    Datafile /u01/app/oracle/oradata/RAC/ilog01.db - wrote new name
    Datafile /u01/app/oracle/oradata/RAC/indx01.db - wrote new name
    Datafile /u01/app/oracle/oradata/RAC/temp01.db - wrote new name
    Control File /u01/app/oracle/oradata/RAC/control01.ctl - wrote new name
    Control File /u01/app/oracle/fast_recovery_area/RAC/control02.ctl - wrote new name
    Instance shut down

Database name changed to STDRAC.
Modify parameter file and generate a new password file before restarting.
Succesfully changed database name.
DBNEWID - Completed succesfully.


###################   Change CDB Database name Example ###################
[SMRCDB] to [STDRAC]

oracle@srv4:/u01/app/oracle/product/12.2.0/dbhome_1/network/admin> . oraenv
ORACLE_SID = [SMRCDB] ?
The Oracle base remains unchanged with value /u01/app/oracle
oracle@srv4:/u01/app/oracle/product/12.2.0/dbhome_1/network/admin> sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Thu Aug 6 22:55:13 2020

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 1795162112 bytes
Fixed Size                  8793832 bytes
Variable Size             704643352 bytes
Database Buffers         1073741824 bytes
Redo Buffers                7983104 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
oracle@srv4:/u01/app/oracle/product/12.2.0/dbhome_1/network/admin> nid TARGET=sys/system123@SMRCDB DBNAME=STDRAC SETNAME=YES

DBNEWID: Release 12.2.0.1.0 - Production on Thu Aug 6 22:56:25 2020

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

Connected to database SMRCDB (DBID=3280283628)

Connected to server version 12.2.0

Control Files in database:
    /u01/app/oracle/oradata/SMRCDB/control01.ctl
    /u01/app/oracle/fast_recovery_area/SMRCDB/control02.ctl

Change database name of database SMRCDB to STDRAC? (Y/[N]) => Y

Proceeding with operation
Changing database name from SMRCDB to STDRAC
    Control File /u01/app/oracle/oradata/SMRCDB/control01.ctl - modified
    Control File /u01/app/oracle/fast_recovery_area/SMRCDB/control02.ctl - modified
    Datafile /u01/app/oracle/oradata/SMRCDB/system01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/sysaux01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/undotbs01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/pdbseed/system01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/pdbseed/sysaux01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/users01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/pdbseed/undotbs01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/temp01.db - wrote new name
    Datafile /u01/app/oracle/oradata/SMRCDB/pdbseed/temp012020-08-04_22-52-23-393-PM.db - wrote new name
    Control File /u01/app/oracle/oradata/SMRCDB/control01.ctl - wrote new name
    Control File /u01/app/oracle/fast_recovery_area/SMRCDB/control02.ctl - wrote new name
    Instance shut down

Database name changed to STDRAC.
Modify parameter file and generate a new password file before restarting.
Succesfully changed database name.
DBNEWID - Completed succesfully.


  • Create pfile from  SMRCDB pfile change db_name to 'STDRAC' and start database with pfile.

oracle@srv4:/u01/app/oracle/oradata/SMRCDB> cat /u01/app/oracle/product/12.2.0/dbhome_1/dbs/initSTDRAC.ora
STDRAC.__data_transfer_cache_size=0
STDRAC.__db_cache_size=1107296256
STDRAC.__inmemory_ext_roarea=0
STDRAC.__inmemory_ext_rwarea=0
STDRAC.__java_pool_size=16777216
STDRAC.__large_pool_size=33554432
STDRAC.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
STDRAC.__pga_aggregate_target=603979776
STDRAC.__sga_target=1795162112
STDRAC.__shared_io_pool_size=67108864
STDRAC.__shared_pool_size=553648128
STDRAC.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/SMRCDB/adump'
*.audit_trail='db'
*.compatible='12.2.0'
*.control_files='/u01/app/oracle/oradata/SMRCDB/control01.ctl','/u01/app/oracle/fast_recovery_area/SMRCDB/control02.ctl'
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/oradata/SMRCDB/'
#DB_CREATE_FILE_DEST='/u01/app/oracle/oradata/SMRCDB/'
*.db_name='STDRAC'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area/SMRCDB'
*.db_recovery_file_dest_size=10398m
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=STDRACXDB)'
*.enable_pluggable_database=true
*.local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=srv4.example.com)(PORT=1523))'
*.log_archive_format='%t_%s_%r.dbf'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=570m
*.processes=800
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=1708m
*.undo_tablespace='UNDOTBS1'
oracle@srv4:/u01/app/oracle/oradata/SMRCDB>


oracle@srv4:/u01/app/oracle/product/12.2.0/dbhome_1/network/admin>
SQL> startup pfile='/u01/app/oracle/product/12.2.0/dbhome_1/dbs/initSTDRAC.ora';
ORACLE instance started.

Total System Global Area 1795162112 bytes
Fixed Size                  8793832 bytes
Variable Size             704643352 bytes
Database Buffers         1073741824 bytes
Redo Buffers                7983104 bytes
Database mounted.
Database opened.
SQL>
SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
STDRAC    READ WRITE           PRIMARY



SQL> sho pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
SQL> select CDB from v$database;

CDB
---
YES



No comments:

Post a Comment