Tuesday, 5 July 2016

Database rename

[oracle@Tstdbserver ~]$ ps -ef|grep -i tns
root        37     2  0 Mar16 ?        00:00:00 [netns]
oracle   15132  7994  0 07:28 pts/1    00:00:00 grep -i tns
oracle   17474     1  0 Mar29 ?        00:03:12 /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr LISTENER -inherit
[oracle@Tstdbserver ~]$ ps -ef|grep -i pmon
oracle    8227     1  0 07:15 ?        00:00:00 ora_pmon_ora11g
oracle   15134  7994  0 07:28 pts/1    00:00:00 grep -i pmon
[oracle@Tstdbserver ~]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.2.0.4.0 Production on Tue Jul 5 07:29:02 2016

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, OLAP, Data Mining and Real Application Testing options

SQL> alter database backup controlfile to trace as '/tmp/ORACL11g';

Database altered.

SQL> select name from v$database;

NAME
---------
ORA11G

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ora11g/system01.dbf
/u01/app/oracle/oradata/ora11g/sysaux01.dbf
/u01/app/oracle/oradata/ora11g/undotbs01.dbf
/u01/app/oracle/oradata/ora11g/users01.dbf

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ora11g/control01.ctl
/u01/app/oracle/fast_recovery_area/ora11g/control02.ctl

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ora11g/redo03.log
/u01/app/oracle/oradata/ora11g/redo02.log
/u01/app/oracle/oradata/ora11g/redo01.log

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@Tstdbserver ~]$ cd $ORACLE_HOME/dbs
[oracle@Tstdbserver dbs]$ ls -lrt
total 32
-rw-r--r-- 1 oracle oinstall 2851 May 15  2009 init.ora
-rw-r----- 1 oracle oinstall   24 Apr 26 07:43 lkSRC
-rw-r----- 1 oracle oinstall 1536 Apr 26 07:43 orapwSRC
-rw-r----- 1 oracle oinstall 3584 Jul  3 14:05 spfileSRC.ora_BKP
-rw-r--r-- 1 oracle oinstall 1024 Jul  5 07:12 initora11g.ora
-rw-rw---- 1 oracle oinstall 1544 Jul  5 07:13 hc_SRC.dat
-rw-r----- 1 oracle oinstall   24 Jul  5 07:17 lkORA11G
-rw-rw---- 1 oracle oinstall 1544 Jul  5 07:21 hc_ora11g.dat
[oracle@Tstdbserver dbs]$ vi initora11g.ora
[oracle@Tstdbserver dbs]$ cat initora11g.ora
ORCL11g.__db_cache_size=2902458368
ORCL11g.__java_pool_size=16777216
ORCL11g.__large_pool_size=33554432
ORCL11g.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
ORCL11g.__pga_aggregate_target=2399141888
ORCL11g.__sga_target=4294967296
ORCL11g.__shared_io_pool_size=0
ORCL11g.__shared_pool_size=1308622848
ORCL11g.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/ORCL11g/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/ORCL11g/control01.ctl','/u01/app/oracle/fast_recovery_area/ORCL11g/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='ORCL11g'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ORCL11gXDB)'
*.enable_goldengate_replication=TRUE
*.open_cursors=300
*.pga_aggregate_target=2391801856
*.processes=150
*.recyclebin='OFF'
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=4293918720
*.undo_tablespace='UNDOTBS1'
[oracle@Tstdbserver dbs]$ mkdir -p /u01/app/oracle/admin/ORCL11g/adump
[oracle@Tstdbserver dbs]$ mkdir -p /u01/app/oracle/fast_recovery_area/ORCL11g
[oracle@Tstdbserver dbs]$ ls -lrt
total 32
-rw-r--r-- 1 oracle oinstall 2851 May 15  2009 init.ora
-rw-r----- 1 oracle oinstall   24 Apr 26 07:43 lkSRC
-rw-r----- 1 oracle oinstall 1536 Apr 26 07:43 orapwSRC
-rw-r----- 1 oracle oinstall 3584 Jul  3 14:05 spfileSRC.ora_BKP
-rw-rw---- 1 oracle oinstall 1544 Jul  5 07:13 hc_SRC.dat
-rw-r----- 1 oracle oinstall   24 Jul  5 07:17 lkORA11G
-rw-rw---- 1 oracle oinstall 1544 Jul  5 07:21 hc_ora11g.dat
-rw-r--r-- 1 oracle oinstall 1038 Jul  5 07:32 initora11g.ora
[oracle@Tstdbserver dbs]$ cp initora11g.ora initORCL11g.ora
[oracle@Tstdbserver dbs]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.2.0.4.0 Production on Tue Jul 5 07:34:40 2016

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, OLAP, Data Mining and Real Application Testing options

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@Tstdbserver dbs]$ cd /tmp
[oracle@Tstdbserver tmp]$ ls -lrt
total 20
-rw-r--r-- 1 oracle oinstall  660 Jul  5 07:16 ora11g.sql
drwxr-xr-x 2 oracle oinstall 4096 Jul  5 07:24 OraInstall2016-07-05_07-24-23-AM
drwxr-xr-x 2 oracle oinstall 4096 Jul  5 07:24 hsperfdata_oracle
-rw-r--r-- 1 oracle oinstall 5235 Jul  5 07:29 ORACL11g
[oracle@Tstdbserver tmp]$ vi ORACL11g
[oracle@Tstdbserver tmp]$ cat ORACL11g
CREATE CONTROLFILE SET DATABASE "ORCL11G" RESETLOGS  NOARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/u01/app/oracle/oradata/ORCL11g/redo01.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 2 '/u01/app/oracle/oradata/ORCL11g/redo02.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 3 '/u01/app/oracle/oradata/ORCL11g/redo03.log'  SIZE 50M BLOCKSIZE 512
DATAFILE
  '/u01/app/oracle/oradata/ORCL11g/system01.dbf',
  '/u01/app/oracle/oradata/ORCL11g/sysaux01.dbf',
  '/u01/app/oracle/oradata/ORCL11g/undotbs01.dbf',
  '/u01/app/oracle/oradata/ORCL11g/users01.dbf'
CHARACTER SET WE8MSWIN1252
;
[oracle@Tstdbserver tmp]$ vi /etc/oratab
[oracle@Tstdbserver tmp]$ . oraenv
ORACLE_SID = [ora11g] ? ORCL11g
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@Tstdbserver tmp]$ cd /u01/app/oracle/oradata/
[oracle@Tstdbserver oradata]$ ls -lrt
total 8
drwxr-x--- 2 oracle oinstall 4096 Mar 25 09:19 SRC
drwxr-xr-x 2 oracle oinstall 4096 Jul  5 07:20 ora11g
[oracle@Tstdbserver oradata]$ mv ora11g ORCL11g
[oracle@Tstdbserver oradata]$ ls -lrt
total 8
drwxr-x--- 2 oracle oinstall 4096 Mar 25 09:19 SRC
drwxr-xr-x 2 oracle oinstall 4096 Jul  5 07:20 ORCL11g
[oracle@Tstdbserver oradata]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.2.0.4.0 Production on Tue Jul 5 07:41:56 2016

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, OLAP, Data Mining and Real Application Testing options

SQL> @/tmp/ORACL11g

Control file created.

SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> alter database open RESETLOGS;

Database altered.

SQL> select name from v$database;

NAME
---------
ORCL11G

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ORCL11g/system01.dbf
/u01/app/oracle/oradata/ORCL11g/sysaux01.dbf
/u01/app/oracle/oradata/ORCL11g/undotbs01.dbf
/u01/app/oracle/oradata/ORCL11g/users01.dbf

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ORCL11g/control01.ctl
/u01/app/oracle/fast_recovery_area/ORCL11g/control02.ctl


SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ORCL11g/redo03.log
/u01/app/oracle/oradata/ORCL11g/redo02.log
/u01/app/oracle/oradata/ORCL11g/redo01.log

SQL> Database rename session completed!!!
SP2-0734: unknown command beginning "Database r..." - rest of line ignored.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@Tstdbserver oradata]$ ps -ef|grep -i pmon
oracle   15184     1  0 07:39 ?        00:00:00 ora_pmon_ORCL11g
oracle   15275  7994  0 07:44 pts/1    00:00:00 grep -i pmon

1 comment:

  1. How about changing it with NID Utiliry? that looks lot more simpler than all this
    $ORACLE_HOME/bin/nid target=sys/******* DBNAME=ORCL11g
    Then bring it up with pfile where you already modified dbname and do SQL> alter database open RESETLOGS;

    ReplyDelete