Oracle 10g Data Guard

下文出现的ora11 ora12是机器名,其上分别装有
相同版本的Linux,相同版本的ORACLE10g软件.
ora11上的数据库test1,用dbca创建
ora12不用建库,只需按下面的步骤做.
 
这下边是大体内容,但是还有不完善的地方,比如第一个修改完pfile以后,要利用这个pfile启动数据库并做一个spfile。文中没有标注。后续。

ora11,ORACLE_SID=test1,db_name=test1,db_unique_name=test1
     hosts       
 193.168.0.11   ora11.zhou.com  ora11    
 127.0.0.1       localhost.localdomain   localhost
 193.168.0.12   ora12.zhou.com  ora12
    
    inittest1.ora
        *.audit_file_dest='/u01/app/oracle/admin/test1/adump'
 *.background_dump_dest='/u01/app/oracle/admin/test1/bdump'
 *.compatible='10.2.0.1.0'
 *.control_files='/u01/app/oracle/oradata/test1/control01.ctl','/u01/app/oracle/oradata/test1/control02.ctl','/u01/app/oracle/oradata/test1/control03.ctl'
 *.core_dump_dest='/u01/app/oracle/admin/test1/cdump'
 *.db_block_size=8192
 *.db_domain=''
 *.db_file_multiblock_read_count=16
 *.db_name='test1'
 *.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
 *.db_recovery_file_dest_size=2147483648
 *.db_unique_name='test1'
 *.fal_client='TEST1'
 *.fal_server='TEST2'
 *.job_queue_processes=10
 *.log_archive_config='DG_CONFIG=(test1,test2)'
 *.log_archive_dest_1='LOCATION=/u01/app/oracle/arch/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=test1'
 *.log_archive_dest_2='SERVICE=test2 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=test2'
 *.log_archive_dest_3='LOCATION=/u01/app/oracle/arch3/ VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE) DB_UNIQUE_NAME=test1'
 *.log_archive_dest_state_1='ENABLE'
 *.log_archive_dest_state_2='defer'
 *.log_archive_dest_state_3='ENABLE'
 *.log_archive_format='%t_%s_%r.dbf'
 *.log_file_name_convert='/u01/app/oracle/oradata/test1','/u01/app/oracle/oradata/test1'
 *.open_cursors=300
 *.pga_aggregate_target=16777216
 *.processes=150
 *.remote_login_passwordfile='EXCLUSIVE'
 *.sga_target=167772160
 *.standby_file_management='AUTO'
 *.undo_management='AUTO'
 *.undo_tablespace='UNDOTBS1'
 *.user_dump_dest='/u01/app/oracle/admin/test1/udump'
    listener.ora
        SID_LIST_LISTENER_ =
   (SID_LIST =
     (SID_DESC =
       (GLOBAL_DBNAME = test1)
       (ORACLE_HOME = /u01/app/oracle/db)
       (SID_NAME = test1)
     )
   )
  
 LISTENER_ =
   (DESCRIPTION_LIST =
     (DESCRIPTION =
       (ADDRESS = (PROTOCOL = TCP)(HOST = ora11)(PORT = 1522))
     )
   )
    sqlnet.ora
        sqlnet.authentication_services=(NONE)
        names.directory_path=(tnsnames)
    tnsnames.ora
        TEST1 =
   (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = ora11)(PORT = 1522))
     (CONNECT_DATA =
       (SERVER = DEDICATED)
       (SERVICE_NAME = test1)
     )
   )
 
 TEST2 =
   (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = ora12)(PORT = 1521))
     (CONNECT_DATA =
       (SERVER = DEDICATED)
       (SERVICE_NAME = test2)
     )
   )
ora12,ORACLE_SID=test2,db_name=test1,db_unique_name=test2
    hosts       
 193.168.0.11   ora11.zhou.com  ora11    
 127.0.0.1       localhost.localdomain   localhost
 193.168.0.12   ora12.zhou.com  ora12
 
    
    inittest2.ora (里面出现的目录,没有的,要手动建立)
        *.audit_file_dest='/u01/app/oracle/admin/test2/adump'
 *.background_dump_dest='/u01/app/oracle/admin/test2/bdump'
 *.compatible='10.2.0.1.0'
 *.control_files='/u01/app/oracle/oradata/test1/control01.ctl','/u01/app/oracle/oradata/test1/control02.ctl','/u01/app/oracle/oradata/test1/control03.ctl'
 *.core_dump_dest='/u01/app/oracle/admin/test2/cdump'
 *.db_block_size=8192
 *.db_domain=''
 *.db_file_multiblock_read_count=16
 *.db_name='test1'
 *.db_unique_name='test2'
 *.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
 *.db_recovery_file_dest_size=2147483648
 *.job_queue_processes=10
 *.open_cursors=300
 *.pga_aggregate_target=16777216
 *.processes=150
 *.remote_login_passwordfile='EXCLUSIVE'
 *.sga_target=167772160
 *.undo_management='AUTO'
 *.undo_tablespace='UNDOTBS1'
 *.user_dump_dest='/u01/app/oracle/admin/test2/udump'
 *.fal_server='TEST1'
 *.fal_client='TEST2'
 *.log_archive_config='DG_CONFIG=(test1,test2)'
 *.log_archive_dest_1='LOCATION=/u01/app/oracle/arch/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=test2'
 *.log_archive_dest_2='SERVICE=test1 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=test1'
 *.log_archive_dest_3='LOCATION=/u01/app/oracle/arch3/ VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE) DB_UNIQUE_NAME=test2'
 *.log_archive_dest_state_1='ENABLE'
 *.log_archive_dest_state_2='enable'
 *.log_archive_dest_state_3='ENABLE'
 *.log_file_name_convert='/u01/app/oracle/oradata/test1','/u01/app/oracle/oradata/test1'
 *.nls_language='SIMPLIFIED CHINESE'
 *.nls_territory='CHINA'
 *.remote_login_passwordfile='EXCLUSIVE'
 *.STANDBY_ARCHIVE_DEST='/u01/app/oracle/standbyarch/'
 *.standby_file_management='AUTO'
    listener.ora
       SID_LIST_LISTENER =
   (SID_LIST =
     (SID_DESC =
       (GLOBAL_DBNAME = test1)
       (ORACLE_HOME = /u01/app/oracle/db)
       (SID_NAME = test2)
     )
   )
  
 LISTENER =
   (DESCRIPTION_LIST =
     (DESCRIPTION =
       (ADDRESS = (PROTOCOL = TCP)(HOST = ora12)(PORT = 1521))
     )
   )
    sqlnet.ora
        sqlnet.authentication_services=(NONE)
        names.directory_path=(tnsnames)
    tnsnames.ora
        TEST1 =
   (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = ora11)(PORT = 1522))
     (CONNECT_DATA =
       (SERVER = DEDICATED)
       (SERVICE_NAME = test1)
     )
   )
 
 TEST2 =
   (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = ora12)(PORT = 1521))
     (CONNECT_DATA =
       (SERVER = DEDICATED)
       (SERVICE_NAME = test2)
     )
   )

ora11:
sqlplus sys/oracle as sysdba
alter database force logging;
alter database begin backup;
host cp /u01/app/oracle/oradata/test1/*.dbf /u01/app/oracle/oradata/bak
alter database end backup;
alter database create standby controlfile as '/u01/app/oracle/oradata/bak/test1.ctl';
quit
$ scp /u01/app/oracle/oradata/bak/*.* ora12.zhou.com:/u01/app/oracle/oradata/test1/

 
ora12:
oracle:
cd /u01/app/oracle/oradata/test1/
cp ../bak/* .
cp test1.ctl control01.ctl
cp test1.ctl control02.ctl
cp test1.ctl control03.ctl
cd $ORACLE_HOME/dbs
vi inittest2.ora
  db_name='test1'
  【需要创建密码文件。orapwd file=/u01/app/oracle/product/10.2.0/db_1/dbs/orapwtest2 password=oracle】
sqlplus sys/oracle as sysdba
startup mount pfile=$ORACLE_HOME/dbs/inittest2.ora
[
ora11,test1:
alter system set log_archive_dest_state_2='enable';
]
alter database add standby LOGFILE GROUP 9 '/u01/app/oracle/oradata/test1/standbyredo09.log' size 50m;
alter database add standby LOGFILE GROUP 10 '/u01/app/oracle/oradata/test1/standbyredo10.log' size 50m;
$ tail -f -n 300 /u01/app/oracle/admin/test2/bdump/alert_test2.log
alter database recover managed standby database disconnect from session;
[
test1:
  select process,CLIENT_PROCESS from v$managed_standby;
      ARCH      ARCH
      ARCH      ARCH
      LNS       LNS   (alter system switch logfile;会启动这个进程)
test2:
  select process,CLIENT_PROCESS from v$managed_standby;
     ARCH      ARCH
     ARCH      ARCH
     MRP0      N/A
     RFS       LGWR
 
  当ora11,运行alter system switch logfile;
  本地生成/u01/app/oracle/arch/1_13_702341059.dbf
  并传输到ora12,
  /u01/app/oracle/arch/1_13_702341059.dbf
  /u01/app/oracle/arch3/1_13_702341059.dbf 
  ora12的alert_test2.log出现:
  RFS[2]: Successfully opened standby log 9: '/u01/app/oracle/oradata/test1/standbyredo09.log'
  Sat Nov  7 18:32:06 2009
  RFS[3]: Successfully opened standby log 10: '/u01/app/oracle/oradata/test1/standbyredo10.log'
  Sat Nov  7 18:32:08 2009
  Media Recovery Log /u01/app/oracle/arch3/1_13_702341059.dbf
  Media Recovery Waiting for thread 1 sequence 14 (in transit)
 
]
观察alert_test2.log,看MRP是否完成恢复
如完成,
[
  MRP0: Background Managed Standby Recovery process started (test2)
 Managed Standby Recovery not using Real Time Apply
  parallel recovery started with 2 processes
 
 Waiting for all non-current ORLs to be archived...
 
 Completed: alter database recover managed standby database disconnect from session
]

ora11,sys:
  create table test(id number);
  insert into test values(1);
  commit;
看ora12,
  date
    Sat Nov  7 18:43:25 CST 2009
  ll oradata/test1/ 
   Nov  7 18:43 standbyredo10.log
  redo信息会及时传送的
 
recover managed standby database cancel;
[
  alert_test2.log:
    MRP0: Background Media Recovery process shutdown (test2)
]
======================================
下边是将物理备库转换为逻辑备库
======================================
alter database open read only;
  Database altered. 
shutdown immediate
startup nomount pfile=$ORACLE_HOME/dbs/inittest2.ora
create spfile from pfile;
shutdown immediate
startup nomount
alter database mount standby database; 
alter database set standby database to maximize performance;
alter database recover managed standby database disconnect from session;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
ora11:
sqlplus sys/oracle as sysdba
execute dbms_logstdby.build;
ora12:
sqlplus sys/oracle as sysdba
alter database recover to logical standby test2;
[see alert_test2.log
    DBID will be changed from 1079383424 to new DBID of 786363321 for database TEST1
    DBNAME will be changed from TEST1 to new DBNAME of TEST2
]
shutdown immediate
startup mount
alter database open resetlogs;
ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;
[
  see alert_test2.log
  LOGMINER: Begin mining logfile during dictionary load for session 1 thread 1 sequence 15, /u01/app/oracle/standbyarch/1_15_702341059.dbf
  Sat Nov  7 19:06:56 2009
  LOGMINER: Turning ON Log Auto Delete
]
select * from test;
  1
create pfile from spfile;
quit
$ cat inittest2.ora
    *.db_name='TEST2'
    (原来*.db_name='TEST1')
OK

本文出自 “周旭光_不断进取” 博客,转载请与作者联系!

你可能感兴趣的:(oracle,Data,dg,guard,数据守卫)