没有连接到target的复制
将orcl数据库的备份复制为orcl1
一、创建orcl的备份:
run{
backup database plus archivelog;}二、复制数据库为orcl1
1. 为orcl1创建参数文件:
cd $ORACLE_HOME/dbs
vi initorcl1.ora写入如下内容:
DB_NAME=orcl1
DB_BLOCK_SIZE=81922. 启动实例:
export ORACLE_SID=orcl1sqlplus / as sysdba
startup nomount
3. 将归档放到备份所在的位置:
cp /u01/app/oracle/archivelog/* /u01/app/oracle/backup/rmanbk/
4. 开始复制:
rman auxiliary /
run
{ set newname for database to '/u01/app/oracle/oradata/orcl1/%b'; duplicate target database to orcl1 backup location '/u01/app/oracle/backup/rmanbk/' logfile group 1 ('/u01/app/oracle/oradata/orcl1/redo01.log') size 50M reuse, group 2 ('/u01/app/oracle/oradata/orcl1/redo02.log') size 50M reuse, group 3 ('/u01/app/oracle/oradata/orcl1/redo03a.log') size 50M reuse;}5. 检查状态:
SQL> select status from v$instance;
SQL> select name from v$database;Active Database Duplicate
利用Rman的duplicate命令,可以很方便的将原库复制出一个新库,但是在Oracle11g之前,执行duplicate要求首先对原库用rman进行备份,然后将备份复制到复制库,同时连接源库(作为target)和复制库(作为auxiliary),执行duplicate命令进行复制,在Oracle11g中推出的active database duplicate特性则省略了进行rman备份的步骤,能够直接从原库复制出新库,对于一些大型的数据库来说,这个特性可以节省很多操作时间
以下是在同一个主机上执行duplicate:
原库:orcl(归档模式)
新库:nylg一、手工创建nylg实例:
首先创建dump路径,初始化参数文件,password文件,网络连接:
export ORACLE_SID=orcl
sqlplus / as sysdbacreate pfile from spfile;cp $ORACLE_HOME/dbs/initorcl.ora $ORACLE_HOME/dbs/initnylg.oravi initnylg.ora修改参数:
%s/orcl/nylg/g
log_archive_dest_1='location=/u01/app/oracle/archivelog1'mkdir -p /u01/app/oracle/archivelog1
添加入以下内容:
DB_FILE_NAME_CONVERT=('/u01/app/oracle/oradata/orcl/','/u01/app/oracle/oradata/nylg/')
LOG_FILE_NAME_CONVERT=('/u01/app/oracle/oradata/orcl11g/','/u01/app/oracle/oradata/nylg/')创建nylg的dump文件目录:mkdir -p $ORACLE_BASE/admin/nylg/adump为数据文件和日志文件创建目录:
mkdir -p /u01/app/oracle/oradata/nylg为orcl1创建口令文件:
orapwd file=$ORACLE_HOME/dbs/orapwnylg password=amkdir -p /u01/app/oracle/flash_recovery_area/nylg
创建连接到orcl和nylg实例的网络连接符:
ORCL =
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = orcl) (PORT = 1521) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ))NYLG =
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = nylg) (PORT = 1521) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = nylg) ))对nylg进行静态注册:
su - gridcd $ORACLE_HOME/network/admin
vi listener.ora加入以下内容:SID_LIST_LISTENER =
(SID_LIST = (SID_DESC = (SID_NAME = nylg) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (GLOBAL_DBNAME = nylg) ))二、将nylg启动到nomount状态
export ORACLE_SID=nylgsqlplus / as sysdbacreate spfile from pfile;startup nomount三、启动rman,同时连接原库和新库
rman target sys/a@orcl auxiliary sys/a@nylg
四、执行duplicateRMAN> duplicate target database to nylg from active database;
五、检查新库状态
export ORACLE_SID=nylg
sqlplus / as sysdbaselect instance_name,status from v$instance;