在前面的3个小节中,分别介绍了使用expdp,传输表空间以及rman的异机恢复等方式实现单实例数据库向rac环境的迁移,本节中将介绍下使用physical dataguard实现这一过程,核心思想是构建基于单实例数据库的物理备库(rac环境),而后进行主备库的切换,尽可能的减少迁移数据的时间消耗和对生产环境的影响!但同前3种方式相比,迁移的难度也增加了不少!由于文章篇幅限制,本节演示将分为上下两篇文章。本文主要参考下列的文章,感谢作者分享!
http://space.itpub.net/4227/viewspace-622322
一:环境介绍
primary数据库(单实例环境)
IP:192.168.1.49/24
操作系统版本:rhel5.4 64位
数据库版本:10.2.0.5
physical standby数据库(rac环境,2个节点)
节点1 IP:192.168.1.41/24
节点2 IP:192.168.1.42/24
操作系统版本:centos4.8 64位
数据库版本:10.2.0.5
二:配置primary数据库的tnsnames.ora文件以及dataguard相关的设置,由于即将构建的备库为rac环境,因而需要增加undotbs2表空间和thread 2日志组
[oracle@server49 ~]$ cd $ORACLE_HOME/network/admin STANDBY = SQL> show parameter name; NAME TYPE VALUE
NAME OPEN_MODE LOG_MODE FOR SQL> alter database force logging; SQL> select bytes/(1024*1024) MB,autoextensible from dba_data_files where tablespace_name='UNDOTBS1'; MB AUT SQL> create undo tablespace undotbs2 datafile '/u01/app/oracle/oradata/orcl/undotbs02.dbf' size 30M autoextend on maxsize 10G; SQL> select bytes/(1024*1024) MB,autoextensible from dba_data_files where tablespace_name in ('UNDOTBS1','UNDOTBS2'); MB AUT QL> select a.group#,a.member,b.bytes/(1024*1024) MB,b.thread# from v$logfile a,v$log b where a.group#=b.group#; GROUP# MEMBER MB THREAD# SQL> alter database add logfile thread 2 group 4 '/u01/app/oracle/oradata/orcl/redo04.log' size 50M; SQL> alter database add logfile thread 2 group 5 '/u01/app/oracle/oradata/orcl/redo05.log' size 50M; SQL> alter database add logfile thread 2 group 6 '/u01/app/oracle/oradata/orcl/redo06.log' size 50M; SQL> select a.group#,a.member,b.bytes/(1024*1024) MB,b.thread# from v$logfile a,v$log b where a.group#=b.group#; GROUP# MEMBER MB THREAD# SQL> alter database enable thread 2; SQL> alter system set log_archive_config='DG_CONFIG=(PRIMARY,STANDBY)'; SQL> archive log list; SQL> !mkdir -p /u01/app/oracle/archive_log SQL> alter system set log_archive_dest_2='SERVICE=standby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby'; SQL> alter system set fal_server=standby; SQL> alter system set fal_client=primary; SQL> alter system set standby_file_management=auto; |
三:在primar库上生成pfile,并使用rman备份数据库,将备份的数据复制到rac节点1上
SQL> create pfile='/home/oracle/rman_bak/initorcl.ora' from spfile; [oracle@server49 ~]$ rman target / RMAN> run { RMAN> backup format '/home/oracle/rman_bak/control01.ctl' current controlfile for standby; |
四:standby(节点1)数据库上,同样配置tnsnames.ora文件,创建密码文件,修改参数文件
[oracle@rac1 ~]$ cat $ORACLE_HOME/network/admin/tnsnames.ora ORCL2 = ORCL = LISTENERS_ORCL =
STANDBY = [oracle@rac1 ~]$ crs_stat -t -v [oracle@rac1 ~]$ cat /home/oracle/rman_bak/initorcl.ora *.__db_cache_size=79691776 *.__java_pool_size=4194304 *.__large_pool_size=4194304 *.__shared_pool_size=109051904 *.__streams_pool_size=8388608 *.audit_file_dest='/u01/app/oracle/admin/orcl/adump' *.background_dump_dest='/u01/app/oracle/admin/orcl/bdump' *.core_dump_dest='/u01/app/oracle/admin/orcl/cdump' *.user_dump_dest='/u01/app/oracle/admin/orcl/udump' *.compatible='10.2.0.5.0' *.control_files='+DATA/ORCL/CONTROLFILE/CONTROL01.CTL','+FRA/ORCL/CONTROLFILE/CONTROL02.CTL' *.db_block_size=8192 *.db_domain='yang.com' *.db_file_multiblock_read_count=16 *.db_name='orcl' *.db_recovery_file_dest='+FRA' *.db_recovery_file_dest_size=21474836480 *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)' *.fal_client='STANDBY' *.fal_server='PRIMARY' *.job_queue_processes=10 *.log_archive_config='DG_CONFIG=(PRIMARY,STANDBY)' *.log_archive_dest_1='LOCATION=+FRA/ORCL/ARCHIVELOG VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=STANDBY' *.log_archive_dest_2='SERVICE=PRIMARY LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PRIMARY' *.log_archive_format='%t_%s_%r.dbf' *.open_cursors=300 *.pga_aggregate_target=71303168 *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.sga_target=213909504 *.standby_file_management='AUTO' *.undo_management='AUTO' *.cluster_database=true *.cluster_database_instances=2 *.db_unique_name='standby' *.log_file_name_convert=('/u01/app/oracle/flash_recover_area', '+FRA/ORCL/ARCHIVELOG') *.db_file_name_convert=('/u01/app/oracle/oradata/orcl', '+DATA/ORCL/DATAFILE') orcl1.undo_tablespace='UNDOTBS1' orcl2.undo_tablespace='UNDOTBS2' orcl1.instance_number=1 orcl2.instance_number=2 orcl1.thread=1 orcl2.thread=2 orcl1.local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.41)(PORT=1521))' orcl2.local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.42)(PORT=1521))' |
[oracle@rac1 ~]$ sqlplus /nolog Total System Global Area 213909504 bytes SQL> create spfile='+DATA/ORCL/PARAMETERFILE/SPFILEORCL1.ORA' from pfile='/home/oracle/rman_bak/initorcl.ora'; |
[oracle@rac1 ~]$ rman target / ASMCMD> pwd |
[oracle@rac1 ~]$ rman target sys/123456@primary auxiliary / RMAN> duplicate target database for standby; [oracle@rac1 ~]$ rman target / RMAN> report schema; Starting implicit crosscheck backup at 2012-01-09 15:35:29 Starting implicit crosscheck copy at 2012-01-09 15:35:31 searching for all files in the recovery area RMAN-06139: WARNING: control file is not current for REPORT SCHEMA List of Permanent Datafiles List of Temporary Files ASMCMD> pwd |
八:启动节点1数据库到应用日志模式下,中间若出现归档日志的gap,则需要在主库上restore相应的归档日志文件
[oracle@rac1 ~]$ sqlplus /nolog SQL> conn /as sysdba SQL> alter database recover managed standby database disconnect from session; SQL> select name,database_role from gv$database; NAME DATABASE_ROLE
FIRST_TIME NEXT_TIME SEQUENCE# APPLIED [oracle@rac1 ~]$ tail -f /u01/app/oracle/admin/orcl/bdump/alert_orcl1.log primary数据库操作: [oracle@server49 ~]$ sqlplus /nolog SQL> conn /as sysdba [oracle@rac1 ~]$ tail -f /u01/app/oracle/admin/orcl/bdump/alert_orcl1.log SQL>select first_time,next_time,sequence#,applied from v$archived_log; FIRST_TIME NEXT_TIME SEQUENCE# APPLIED primary数据库操作: 节点1数据库继续查询: FIRST_TIME NEXT_TIME SEQUENCE# APPLIED 上述过程没有问题后,就可以启动节点2的数据库实例到mount状态! NAME DB_UNIQUE_ OPEN_MODE DATABASE_ROLE 最后确定下主库和备库的日志传输和应用状况是否正常!
FIRST_TIME NEXT_TIME SEQUENCE# APPLIED THREAD# FIRST_TIME NEXT_TIME SEQUENCE# APPLIED THREAD#
NAME DB_UNIQUE_NAME DATABASE_ROLE SWITCHOVER_STATUS |
本文出自 “斩月” 博客,谢绝转载!