Database Clone by rebuilding control file.

pentium發表於2013-04-23

前面我們用了rman 裡的duplicate方法去在本機clone個db, 這裡我們用CREATE CONTROLFILE 方法在另一臺伺服器上Clone. 缺點是用這個方法clone, 需要shutdown 原資料庫,傳輸datafile到另臺伺服器。

1- tar $ORACLE_HOME for 10.2.0 and 11.1.0 on ora6
tar –cvf

2- scp them to srv7 (if the file is too large, may face File is too large issue. use ulimit –a to see the limitation).

scp jxiaos@EAP-SRV6:/u01/app/oracle/product/ora11g.tar /u01

scp jxiaos@EAP-SRV6:/u04/oradata/OLD_DB/*.* /u04/oradata/CLONEDDB/

[@more@]

[oracle@EAP-SRV7] :/u01 > scp jxiaos@EAP-SRV6:/u01/app/oracle/product/ora11g.tar /u01/
jxiaos@EAP-SRV6's password:
ora11g.tar 1% 198MB 30.3MB/s 07:24 ETA

cp ~.profile to srv7

3- untar and relink

tar –xvf

export ORACLE_HOME=/u01/app/oracle/product/10.2.0
cd $ORACLE_HOME/oui/bin
$ORACLE_HOME/oui/bin/runInstaller -silent -clone ORACLE_BASE="/u01/app/oracle" ORACLE_HOME="/u01/app/oracle/product/10.2.0" ORACLE_HOME_NAME="OraClient10g_home1" -invPtrLoc="/etc"

export ORACLE_HOME=/u01/app/oracle/product/11.1.0
cd $ORACLE_HOME/oui/bin
./runInstaller -clone -silent -jreloc /usr/java5_64/jre -ignorePreReq ORACLE_HOME="/u01/app/oracle/product/11.1.0" ORACLE_HOME_NAME="OraDb11g_home1" ORACLE_BASE="/u01/app/oracle"


4-
Create cre_ctl.sql (create control file)
alter database backup controlfile to trace;
get the statement in /u01/app/oracle/admin/diag/rdbms/OLD_DB/OLD_DB/trace/OLD_DB_vktm_20775158.trc
--修改REUSE to SET,因為我們要不同的資料庫名。
CREATE CONTROLFILE SET DATABASE "CLONEDDB" RESETLOGS NOARCHIVELOG
MAXLOGFILES 20
MAXLOGMEMBERS 3
MAXDATAFILES 1000
MAXINSTANCES 1
MAXLOGHISTORY 584
LOGFILE
GROUP 1 '/u02/oradata/CLONEDDB/CLONEDDB_redo01m1.log' SIZE 200M,
GROUP 2 '/u02/oradata/CLONEDDB/CLONEDDB_redo02m1.log' SIZE 200M,
GROUP 3 '/u02/oradata/CLONEDDB/CLONEDDB_redo03m1.log' SIZE 200M,
GROUP 4 '/u02/oradata/CLONEDDB/CLONEDDB_redo04m1.log' SIZE 200M,
GROUP 5 '/u02/oradata/CLONEDDB/CLONEDDB_redo05m1.log' SIZE 200M,
GROUP 6 '/u02/oradata/CLONEDDB/CLONEDDB_redo06m1.log' SIZE 200M,
GROUP 7 '/u02/oradata/CLONEDDB/CLONEDDB_redo07m1.log' SIZE 200M,
GROUP 8 '/u02/oradata/CLONEDDB/CLONEDDB_redo08m1.log' SIZE 200M
-- STANDBY LOGFILE
DATAFILE
'/u04/oradata/CLONEDDB/CLONEDDB_system01.dbf',
'/u04/oradata/CLONEDDB/CLONEDDB_sysaux01.dbf',
'/u04/oradata/CLONEDDB/CLONEDDB_undotbs1.dbf',
'/u04/oradata/CLONEDDB/CLONEDDB_cists01.dbf',
'/u04/oradata/CLONEDDB/CLONEDDB_tools01.dbf',
'/u04/oradata/CLONEDDB/CLONEDDB_tivoliorts01.dbf',
'/u04/oradata/CLONEDDB/CLONEDDB_cists03.dbf',
'/u04/oradata/CLONEDDB/CLONEDDB_cists04.dbf',
......

CHARACTER SET WE8ISO8859P1
;

Shutdown db OLD_DB
scp ~oracle/admin/OLD_DB/cre_ctl.sql to srv7
scp /u04/oradata/OLD_DB/* to srv7
(the oradata is very large, use nohup scp jxiaos@EAP-SRV6:/u04/oradata/OLD_DB/*.* /u04/oradata/CLONEDDB &
scp initCLONEDDB.ora

********************************************************************
1. nohup scp jxiaos@EAP-SRV6:/u04/oradata/OLD_DB/*.* /u04/oradata/CLONEDDB
2.輸入密碼
3.按Ctrl+z掛起當前程式
4.使用命令bg讓掛起的程式繼續執行 退出系統後,這種方法好像不行。 使用這種方法:echo "/pathname/script.sh"|at now
********************************************************************

5 create

/u01/app/oracle/admin/CLONEDDB/pfile/initCLONEDDB.ora
cd $ORACLE_HOME/dbs
ln -s /u01/app/oracle/admin/CLONEDDB/pfile/initCLONEDDB.ora .

~admin/CLONEDDB,/.. and CLONEDDB/adump,pfile,rman (diag will be created automatically after lsnrctl start once)
u*/oradata/CLONEDDB


/var/opt/oracle/oratab, -> CLONEDDB:/u01/app/oracle/product/11.1.0:Y
.profile
/opt/bin/oraenv and dbhome
/var/opt/oracle/*
ln -s /var/opt/oracle/listener.ora .
ln -s /var/opt/oracle/tnsnames.ora .


6 startup nomount
@cre_ctl.sql

7 Open resetlogs: alter database open resetlogs;

8 Change dbid ;
startup mount
nid target=/ (this command not on sqlplus)

startup mount;
alter database open resetlogs;

select dbid, name from v$database;

SQL> select dbid, name from v$database;

DBID NAME
---------- ---------
4134645123 CLONEDDB

9. add temp file:
alter tablespace TEMP add tempfile '/u04/oradata/CLONEDDB/CLONEDDB_temp01.dbf' size 4096M REUSE;

10 - start listener

11- copy dba directory to srv7 and configure cron (not done it yet)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/14377/viewspace-1060424/,如需轉載,請註明出處,否則將追究法律責任。

相關文章