Friday, July 1, 2016

Changing Database Name using NID utility 12c

step1 #  Mount the database
step 2 # Change database name using NID utility
step 3 # Edit the dbname in pfile # 
step 4 # Mount the database using pfile 
step 5 # And Open the database with RESETLOGS # 
Step 6 # I recommend to change Instance Name and Update Network after changing the dbname and opening the database with reset logs 


step1 #  Mount the database
SQL> startup mount
ORACLE instance started.

Total System Global Area 1107296256 bytes
Fixed Size     2923488 bytes
Variable Size   805307424 bytes
Database Buffers   67108864 bytes
Redo Buffers   13852672 bytes
In-Memory Area   218103808 bytes
Database mounted.
SQL> !
[oracle@red ~]$ 
[oracle@red ~]$ ps -ef | grep pmon
oracle    4933     1  0 23:29 ?        00:00:00 ora_pmon_p1d2685
oracle    5064  5040  0 23:29 pts/3    00:00:00 grep pmon
[oracle@red ~]$ . oraenv
ORACLE_SID = [p1d2685] ? 
The Oracle base remains unchanged with value /u01/app/oracle

step 2 # Change database name using NID utility
[oracle@red ~]$ nid target=sys/oracle dbname=db12c

DBNEWID: Release 12.1.0.2.0 - Production on Fri Jul 1 23:30:19 2016
Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.
Connected to database P1D2685 (DBID=3669686930)

Connected to server version 12.1.0
Control Files in database:
    /u01/app/oracle/oradata/P1D2685/controlfile/o1_mf_bbngryqv_.ctl
    /u01/app/oracle/fast_recovery_area/P1D2685/controlfile/o1_mf_bbngrzv0_.ctl

Change database ID and database name P1D2685 to DB12C? (Y/[N]) => Y

Proceeding with operation
Changing database ID from 3669686930 to 1370138315
Changing database name from P1D2685 to DB12C
    Control File /u01/app/oracle/oradata/P1D2685/controlfile/o1_mf_bbngryqv_.ctl - modified
    Control File /u01/app/oracle/fast_recovery_area/P1D2685/controlfile/o1_mf_bbngrzv0_.ctl - modified
    Datafile /u01/app/oracle/oradata/P1D2685/datafile/o1_mf_system_bbngn72x_.db - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/P1D2685/datafile/o1_mf_sysaux_bbngjlcv_.db - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/P1D2685/datafile/o1_mf_undotbs1_bbngqnc4_.db - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/P1D2685/datafile/o1_mf_system_bbngtt8q_.db - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/P1D2685/datafile/o1_mf_users_bbngqjt9_.db - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/P1D2685/datafile/o1_mf_sysaux_bbngtt8k_.db - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/P1D2685/0BE3A840C7CC324FE0530100007FDF9B/datafile/o1_mf_system_bbnhczpz_.db - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/P1D2685/0BE3A840C7CC324FE0530100007FDF9B/datafile/o1_mf_sysaux_bbnhczqm_.db - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/P1D2685/0BE3A840C7CC324FE0530100007FDF9B/datafile/o1_mf_users_bbnhhfhk_.db - dbid changed, wrote new name
    Datafile /u01/in_mem.db - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/DB1/datafile/ggadmin01.db - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/P1D2685/datafile/o1_mf_temp_bbngtgv8_.tm - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/P1D2685/datafile/pdbseed_temp012015-01-05_02-22-32-AM.db - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/P1D2685/0BE3A840C7CC324FE0530100007FDF9B/datafile/o1_mf_temp_bbnhczqp_.db - dbid changed, wrote new name
    Control File /u01/app/oracle/oradata/P1D2685/controlfile/o1_mf_bbngryqv_.ctl - dbid changed, wrote new name
    Control File /u01/app/oracle/fast_recovery_area/P1D2685/controlfile/o1_mf_bbngrzv0_.ctl - dbid changed, wrote new name
    Instance shut down

Database name changed to DB12C.
Modify parameter file and generate a new password file before restarting.
Database ID for database DB12C changed to 1370138315.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.

step 3 # Edit the dbname in pfile # 
[oracle@red dbs]$ vi initp1d2685.ora
[oracle@red dbs]$ 
[oracle@red dbs]$ cat initp1d2685.ora 
p1d2685.__data_transfer_cache_size=0
p1d2685.__db_cache_size=134217728
p1d2685.__java_pool_size=16777216
p1d2685.__large_pool_size=33554432
p1d2685.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
p1d2685.__pga_aggregate_target=385875968
p1d2685.__sga_target=721420288
p1d2685.__shared_io_pool_size=16777216
p1d2685.__shared_pool_size=285212672
p1d2685.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/p1d2685/adump'
*.audit_trail='db'
*.compatible='12.1.0.2.0'
*.control_files='/u01/app/oracle/oradata/P1D2685/controlfile/o1_mf_bbngryqv_.ctl','/u01/app/oracle/fast_recovery_area/P1D2685/controlfile/o1_mf_bbngrzv0_.ctl'
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/oradata'
*.db_domain=''
*.db_name='db12c'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4560m
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=db12cXDB)'
*.enable_pluggable_database=true
*.inmemory_size=209715200
*.memory_target=1048m
*.open_cursors=300
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'

step 4 # Mount the database using pfile 
[oracle@red dbs]$ . oraenv
ORACLE_SID = [p1d2685] ?      
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@red dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Fri Jul 1 23:35:22 2016
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to an idle instance.

SQL> startup pfile='$ORACLE_HOME/dbs/initp1d2685.ora';
ORACLE instance started.
Total System Global Area 1107296256 bytes
Fixed Size     2923488 bytes
Variable Size   788530208 bytes
Database Buffers   83886080 bytes
Redo Buffers   13852672 bytes
In-Memory Area   218103808 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

step 5 # And Open the database with RESETLOGS # 
SQL> alter database open RESETLOGS;
Database altered.

SQL> show parameter db_name;
NAME     TYPE VALUE
------------------------------------ 
db_name      string db12c

Step 6 # Shutdown the Instance. Changing instance_name by renaming the parameter file # 
[oracle@red dbs]$ cp initp1d2685.ora initdb12c.ora

[oracle@red ~]$ . oraenv
ORACLE_SID = [p1d2685] ? db12c
ORACLE_HOME = [/home/oracle] ? /u01/app/oracle/product/12.1.0/dbhome_1/
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@red ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Sat Jul 2 06:13:01 2016
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to an idle instance.

SQL> startup;
ORACLE instance started.

Total System Global Area 1107296256 bytes
Fixed Size     2923488 bytes
Variable Size   822084640 bytes
Database Buffers   50331648 bytes
Redo Buffers   13852672 bytes
In-Memory Area   218103808 bytes
Database mounted.
Database opened.
SQL> show parameter db_name;

NAME     TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name      string db12c
SQL> 
SQL> create spfile from pfile;
File created.
# Shutdown and startup the database using spfile # 
Update /etc/oratab file after changing the Instance Name as follows # 
#
db12c:/u01/app/oracle/product/12.1.0/dbhome_1:N
mldb69:/u01/app/oracle/product/12.1.0/dbhome_1:N


SQL> !
Update Listener and Network configuration Files # 
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.30)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = mldb69)
      (ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_1)
      (SID_NAME = mldb69)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = db12c)
      (ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_1)
      (SID_NAME = db12c)
    )

)

P1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.30)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = db12c)
    )
  )

[oracle@red admin]$ lsnrctl reload listener 
[oracle@red admin]$ tnsping p1
TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 02-JUL-2016 06:19:02
Copyright (c) 1997, 2014, Oracle.  All rights reserved.
Used parameter files:
/u01/app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.30)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = db12c)))
OK (0 msec)


--Nikhil Tatineni--
--Nid Utility # 

Querys to monitor RAC

following few  Query's will help to find out culprits-  Query to check long running transaction from last 8 hours  Col Sid Fo...