合 Duplicating an Active Database
duplicate体系结构
搞点英语出来吧,英语不好的哥们就好好翻译翻译吧,这段英语是必须看懂的。。。。
You can duplicate a source database to a destination database, which can be on the same or different computers. The database instance associated with the duplicate database is called the auxiliary instance. All duplication techniques require a connection to the auxiliary instance. The diagram shows you the following techniques for database duplication:
- From an active database, connected to the target and auxiliary instances
- From backup, connected to the target and auxiliary instances
- From backup, connected to the auxiliary instance, not connected to the target, but with recovery catalog connection
- From backup, connected to the auxiliary instance, not connected to the target and the recovery catalog
Choosing a technique to duplicate your database—always with connection to the auxiliary instance:
简单点就是 ①基于备份 ,而基于备份又分为3种情况 ②基于活动数据库
本次实验简介
本次实验就是基于active database的duplicate技术。
Active database duplication 通过网络,直接copy target 库到auxiliary 库,然后创建复制库。 这种方法就不需要先用RMAN 备份数据库,然后将备份文件发送到auxiliary端。这个功能的作用是非常大的。 尤其是对T级别的库。 因为对这样的库进行备份,然后将备份集发送到备库,在进行duplicate 的代价是非常大的。 一备份要占用时间,二要占用备份空间,三在网络传送的时候,还需要占用带宽和时间。所以Active database duplicate 很好的解决了以上的问题。 它对大库的迁移非常有用。
本次实验原理
环境及搭建要求
环境:
- 源数据库和目标数据库服务器:RHEL6.5
- RMAN客户端:windows 7 系统下的rman client
- source host : 192.168.59.129 sid:orcl database:11gR2
- Destination host :192.168.59.133 sid:orcl database:11gR2
注意事项说明:
- 这里的duplicate database 和 source database 的目录结构完全一样
- 源数据库和辅助数据库的几种不同名称:source/target database ---->>>>>----- (destination host)/duplicate database (auxiliary instance)
- 这里我利用了windows下的rman client来连接目标和辅助数据库,当然也可以利用目标库或者辅助库的rman client来操作
- 目标数据库应该处于归档模式
source database环境:
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
对辅助数据库的要求
辅助数据库应该提前安装好数据库,配置好环境变量。。。。。你懂的。。。。
辅助数据库的环境变量配置:
[root@rhel6 ~]# su - oracle
[oracle@rhel6 ~]$ more .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
export PATH=$PATH:/sbin/:$HOME/bin
# for oracle user
unset USERNAME
export GLOBAL_DB_UNIQUE_NAME=orcl
export ORACLE_HOSTNAME=192.168.59.133
export ORACLE_UNQNAME=orcl
export EDITOR=vi
export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export PATH=$ORACLE_HOME/bin:$PATH
umask 022
#export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
export SQLPATH=$ORACLE_HOME/sqlplus/admin
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias asmcmd='rlwrap asmcmd'
alias alert_log='tail -200f $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLESID/trace/alert$ORACLE_SID.log'
alias alert_xml='tail -200f $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/alert/log.xml'
alias alert_listener='tail -200f $ORACLE_BASE/diag/tnslsnr/rhel6/listener/trace/listener.log'
[oracle@rhel6 ~]$
正式开始
duplicate database 设置
首先在duplicate database上进行设置:
创建pfile 参数文件
[oracle@rhel6 ~]$ cd $ORACLE_HOME/dbs
[oracle@rhel6 dbs]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@rhel6 dbs]$ ll -h
total 4.0K
-rw-r--r--. 1 oracle oinstall 2.8K May 15 2009 init.ora
[oracle@rhel6 dbs]$ vi initorcl.ora
[oracle@rhel6 dbs]$ more initorcl.ora
DB_NAME=orcl
[oracle@rhel6 dbs]$
截图:
创建密码文件
[oracle@rhel6 dbs]$ orapwd file=?/dbs/orapworcl password=lhr
[oracle@rhel6 dbs]$ ll -h
total 12K
-rw-r--r--. 1 oracle oinstall 2.8K May 15 2009 init.ora
-rw-r--r--. 1 oracle oinstall 13 Jul 20 16:03 initorcl.ora
-rw-r-----. 1 oracle oinstall 1.5K Jul 20 16:09 orapworcl
[oracle@rhel6 dbs]$
创建和source database的数据文件相关的目录结构
[oracle@rhel6 oracle]$ pwd
/u01/app/oracle
[oracle@rhel6 oracle]$ ll
total 8
drwxr-xr-x. 2 oracle oinstall 4096 May 18 17:14 checkpoints
drwxr-xr-x. 3 oracle oinstall 4096 May 18 16:04 product
[oracle@rhel6 oracle]$ mkdir -p /u01/app/oracle/oradata/orcl
[oracle@rhel6 oracle]$
不然在duplicate时会报如下错误:
ORA-19505: failed to identify file "/u01/app/oracle/oradata/orcl/users01.dbf"
ORA-27040: file create error, unable to create file
启动Auxiliary 到nomout 状态
[oracle@rhel6 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sun Jul 20 16:48:04 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 217157632 bytes
Fixed Size 2211928 bytes
Variable Size 159387560 bytes
Database Buffers 50331648 bytes
Redo Buffers 5226496 bytes
SQL>
在Target 和Auxiliary 都配置Oracle Net(Listener.ora and tnsnames.ora)
注意:
- 对于Listener.ora 的配置需要配置成静态监听,何谓静态监听???哈哈百度吧。。。。
- target和auxiliary都需要配置listener.ora和tnsnames.ora
- 如果rman client不在target和auxiliary库上,那么也应该配置tnsnames.ora的
target database配置:
[oracle@rhel6 admin]$ more listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.129)(PORT = 1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl.lhr.com)
(SID_NAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
)
(SID_DESC =
(GLOBAL_DBNAME = rman.lhr.com)
(SID_NAME = rman)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)