Translate into your own language

Tuesday, July 19, 2016

Renaming the database to a new name and revert it back to its original name

Original database name: BEFORE
Rename database to   : AFTER

Step 1.

Change the cluster_database parameter to FALSE

[oracle@host1 admin]$ export ORACLE_SID=BEFORE1

[oracle@host1 admin]$ sqlplus "/ as sysdba"

SQL*Plus: Release 11.2.0.4.0 Production on Mon Sep 1 09:38:14 2014

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

USERNAME       INST_NAME    HOST_NAME                           SID   SERIAL#  VERSION    STARTED  SPID       OPID  CPID
-------------- ------------ ----------------------------------- ----- -------- ---------- -------- ---------- ----- ----------
SYS            BEFORE1       host1.intra.searshc.com    236   29       11.2.0.4.0 20140901 7868       35    7867


SQL> alter system set
  2  cluster_database=false scope=spfile sid='*';
System altered.

--------------------------------

STEP 2.

Shutdown the database from srvctl command

$srvctl stop database -d BEFORE

--------------------------------

STEP 3.

Start the instance 1 in mount mode

[oracle@host1 admin]$ export ORACLE_SID=BEFORE1
[oracle@host1 admin]$ sqlplus "/ as sysdba"

SQL*Plus: Release 11.2.0.4.0 Production on Mon Sep 1 09:40:05 2014

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

Connected to an idle instance.

select
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0

SQL> startup mount
ORACLE instance started.

Total System Global Area 1603411968 bytes
Fixed Size                  2253664 bytes
Variable Size             469765280 bytes
Database Buffers         1124073472 bytes
Redo Buffers                7319552 bytes
Database Buffers         1124073472 bytes
Redo Buffers                7319552 bytes
Database mounted.
SQL>

---------------------------------

STEP 4.

Run the nid command

[oracle@host1 admin]$ nid target=sys/password@BEFORE DBNAME=AFTER

DBNEWID: Release 11.2.0.4.0 - Production on Mon Sep 1 09:45:33 2014

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

Connected to database BEFORE (DBID=2458372709)

Connected to server version 11.2.0

Control Files in database:
    +DATA_DATA1/after/control01.ctl
    +DATA_DATA1/after/control02.ctl

Change database ID and database name BEFORE to AFTER? (Y/[N]) => y

Proceeding with operation
Changing database ID from 2458372709 to 1208276477
Changing database name from BEFOR to AFTER
    Control File +DATA_DATA1/after/control01.ctl - modified
    Control File +DATA_DATA1/after/control02.ctl - modified
    Datafile +DATA_DATA1/after/system01.db - dbid changed, wrote new name
    Datafile +DATA_DATA1/after/sysaux01.db - dbid changed, wrote new name
    Datafile +DATA_DATA1/after/undotbs01.db - dbid changed, wrote new name
    Datafile +DATA_DATA1/after/users01.db - dbid changed, wrote new name
    Datafile +DATA_DATA1/after/undotbs02.db - dbid changed, wrote new name
    Datafile +DATA_DATA1/after/temp01.db - dbid changed, wrote new name
    Control File +DATA_DATA1/after/control01.ctl - dbid changed, wrote new name
    Control File +DATA_DATA1/after/control02.ctl - dbid changed, wrote new name
    Instance shut down

Database name changed to AFTER.
Modify parameter file and generate a new password file before restarting.
Database ID for database AFTER changed to 1208276477.
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.

[oracle@host1 admin]$

---------------------------------

STEP 5.

Create pfile from spfile

[oracle@host1 admin]$

[oracle@host1 admin]$ export ORACLE_SID=BEFORE1
[oracle@host1 admin]$ sqlplus "/ as sysdba"

SQL*Plus: Release 11.2.0.4.0 Production on Mon Sep 1 09:49:14 2014

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

Connected to an idle instance.

select
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0

SQL> create pfile from SPFILE='+DATA_DATA1/BEFORE/spfilebefore.ora';

File created.

--------------------------------

STEP 6.

Modify the newly created pfile

Update the below value in parameter file :

AFETR2.__db_cache_size=1124073472
AFTER1.__db_cache_size=1124073472
AFTER2.__java_pool_size=16777216
AFTER1.__java_pool_size=16777216
AFTER2.__large_pool_size=33554432
AFTER1.__large_pool_size=100663296
AFTER1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
AFTER2.__pga_aggregate_target=536870912
AFTER1.__pga_aggregate_target=536870912
AFTER2.__sga_target=1610612736
AFTER1.__sga_target=1610612736
AFTER2.__shared_io_pool_size=0
AFTER1.__shared_io_pool_size=0
AFTER2.__shared_pool_size=419430400
AFTER1.__shared_pool_size=352321536
AFTER2.__streams_pool_size=0
AFTER1.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/AFTER/adump'

*.db_name='AFTRCHNG'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=AFTERXDB)'
AFTER1.instance_number=1
AFTER2.instance_number=2

AFTER1.thread=1
AFTER2.thread=2
AFTER1.undo_tablespace='UNDOTBS2'
AFTER2.undo_tablespace='UNDOTBS1'

-----------------------------------

Step 7.

Create the dump directory and password file.

$mkdir -p /u01/app/oracle/admin/AFTER/adump

$orapwd file=orapwAFTER password=n4u2ck

-----------------------------------

STEP 8.

Create spfile from pfile.

SQL> create SPFILE='+DATA_DATA1/BEFORE/spfileAFTER.ora' from pfile;

-----------------------------------

Step 9.

Rename the parameter file and delete all it contents and give value of above spfile in the pfile.

[oracle@host1 dbs]$ cp initBEFORE1.ora initAFTER1.ora

SPFILE='+DATA_DATA1/BEFORE/spfileAFTER.ora'

-----------------------------------

Step 10.

Start the AFTER database in mount mode

[oracle@host1 dbs]$export ORACLE_SID=AFTER1

[oracle@host1 dbs]$ sqlplus "/ as sysdba"

SQL*Plus: Release 11.2.0.4.0 Production on Mon Sep 1 08:21:21 2014

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options


USERNAME       INST_NAME    HOST_NAME                           SID   SERIAL#  VERSION    STARTED  SPID       OPID  CPID
-------------- ------------ ----------------------------------- ----- -------- ---------- -------- ---------- ----- ----------
SYS            AFTER1       host1.intra.searshc.com    106   5        11.2.0.4.0 20140901 10444      29    10443


SQL> shut immediate
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 1603411968 bytes
Fixed Size                  2253664 bytes
Variable Size             469765280 bytes
Database Buffers         1124073472 bytes
Redo Buffers                7319552 bytes
Database mounted.

-----------------------------------------

Step 11.

Open the database in resetlog mode

SQL> alter database open resetlogs;

Database altered.

----------------------------------------

Step 12.

Change the cluster_database parameter to TRUE

SQL> alter system set
  2  cluster_database=true scope=spfile sid='*';

System altered.

----------------------------------------

Step 13.

Shutdow the database

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down

----------------------------------------

Step 14.

Add the services to the SRVCTL

[oracle@host1 dbs]$ srvctl add database -d AFTER -o /u01/app/oracle/product/11.2.4/dbhome_1 -p +DATA_DATA1/BEFORE/spfileafter.ora -y AUTOMATIC -s OPEN -a "RAC5_DATA"
[oracle@host1 dbs]$ srvctl config database -d AFTER
Database unique name: AFTER
Database name:
Oracle home: /u01/app/oracle/product/11.2.4/dbhome_1
Oracle user: oracle
Spfile: +DATA_DATA1/BEFORE/spfileafter.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: AFTER
Database instances:
Disk Groups: RAC5_DATA
Mount point paths:
Services:
Type: RAC
Database is administrator managed
[oracle@host1 dbs]$ srvctl add instance -d AFTER -i AFTER2 -n hostb
[oracle@host1 dbs]$ srvctl add instance -d AFTER -i AFTER1 -n host1
[oracle@host1 dbs]$ srvctl config database -d AFTER
Database unique name: AFTER
Database name:
Oracle home: /u01/app/oracle/product/11.2.4/dbhome_1
Oracle user: oracle
Spfile: +DATA_DATA1/BEFORE/spfileafter.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: AFTER
Database instances: AFTER1,AFTER2
Disk Groups: RAC5_DATA
Mount point paths:
Services:
Type: RAC
Database is administrator managed
[oracle@host1 dbs]$

--------------------------------------------


Step 15.

SQL> alter system set cluster_database=TRUE scope=spfile sid='*';

----------------------------------------------

Steps 16.

Start the database with srvctl command

[oracle@host1 dbs]$ srvctl start database -d AFTER

[oracle@host1 dbs]$ srvctl status database -d AFTER
Instance AFTER1 is running on node host1
Instance AFTER2 is running on node hostb

--------------------------------------------


For renaming it back to original name we need to previous BEFORE database from configuration
using srvctl command and follow the all above steps:


Stop the database and run the below command:

[oracle@host1 dbs]$ srvctl remove database -d BEFORE
Remove the database BEFORE? (y/[n]) y


-------------------------------------------


Now we need to rename it to the original name:

Step 1.

Please verify the local listener and set it:



SQL> show parameter listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ----------------------------------------------------------------------------------------------------
listener_networks                    string
local_listener                       string
remote_listener                      string      host.com:1522


SQL> alter database open;

Database altered.

SQL> select instance_name,status from gv$instance;

INSTANCE_NAME    STATUS
---------------- ------------
AFTER1             OPEN

SQL> !tnsping NEW

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 02-SEP-2014 13:18:43

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

Used parameter files:
/u01/app/oracle/product/11.2.4/dbhome_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host.com)(PORT = 1522)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = AFTER)))
OK (0 msec)

SQL> !nslookup host1-vip
Server:         151.149.224.164
Address:        151.149.224.164#53

Name:   host1-vip.intra.searshc.com
Address: 151.149.141.85


SQL> alter system set local_listener='(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST =151.149.141.85)(PORT = 1522)))' scope=both;

System altered.

SQL> alter system register;

System altered.


--------------------------------------


NOW FOLLOW THE THE REMAINING STEPS FROM 1 - 16

No comments:

Post a Comment