ITPub博客

首页 > 数据库 > Oracle > RMAN创建dataguard全过程

RMAN创建dataguard全过程

原创 Oracle 作者:ygzhou518 时间:2011-03-08 08:49:59 0 删除 编辑

目的:采用rman热备份在线创建Oracle HA (dataguard),实现primaryDB不关机

測試環境:

primaryDB:   ip 10.202.0.1   ORACLE_SID=ygzhou  DB_name=ygzhoudb  DB_unique_name=ygzhoudb

standbyDB:  ip 10.202.0.2   OEACLE_SID=ygzhou  DB_name=ygzhoudb  DB_unique_name=ygzhoudg   ----------------------安裝了oracle軟體;

檢查ORACLE版本

select *from v$version;

試驗步驟:

primaryDB:

 1   確認數據庫處于archive log狀態,SQL語句:SQL>archive log list;

 2   開啟數據庫到force logging模式,SQL語句:SQL> alter database force logging;

 3   在線修改spfile文件參數一般的方法:alter system set parameter_name=    scope=spfile/both sid='*';

      (1) alter system set db_unique_name=ygzhoudb scope=spfile; //設置數據庫的唯一標識

      (2) alter system set log_archive_config='dg_config=(ygzhoudb,ygzhoudg)' scope=spfile;

      (3) alter system set log_archive_dest_1='location=/home/data/archive/ valid_for=(all_logfiles,all_roles) db_unique_name=ygzhoudb' scope=spfile;

      (4) alter system set log_archive_dest_2='service=standby lgwr async valid_for=(online_logfiles,primary_roles) db_unique_name=ygzhoudg' scope=spfile;

      (5) alter system set log_archive_dest_state_1=enable scope=spfile;

      (6) alter system set log_archive_dest_stat_2=enable scope=spfile;

      (7) alter system set fal_client=primary scope=spfile;

      (8) alter system set fal_server=standby scope=spfile;

      (9)  alter system set undo_management=auto scpoe=spfile; //該參數影響primaryDB與standbyDB的操作同步 http://space.itpub.net/24867586/viewspace-688734

 4 為standbyDB生成pfile :from spfile

       create pfile from spfile='/home/oracle/produce/10.2.0.1/dbs/initygzhou.ora';

 5 rman 備份primaryDB

        (1)  rman target sys/oracle@primary   as sysdba

        (2)  show all:               //這里不自動備份控制文件

        (3)   backup full database format'/home/data/backup/fullbackup_%U';

6 生成standbyDB的控制文件

    alter database create standby database controlfile as '/home/oracle/oradata/rman/standby01.ctl';

7  配置tnsoracle.ora文件      //確定配置如下

  EXTPROC_CONNECTION_DATA =

       (DESCRIPTION =

              (ADDRESS_LIST =

                     (ADDRESS = (PROTOCOL =ITP)(KEY = EXTPROC0))

               )

               (CONNECT_DATA =

                       (SID = PLSExtProc)

                       (presentation = R0)

                )

               primary =

                        (description =

                              (address_list =

                                     (address = (protocol = tcp)(host = 10.202.0.1)(port = 1521))

                         )

                         (connect_data =

                               (service_name = primary)

                          )

                 standby =

                        (description =

                              (address_list =

                                     (address = (protocol = tcp)(host = 10.202.0.2)(port = 1521))

                         )

                         (connect_data =

                               (service_name = standby)

                          )

               ) 

 8 將rman 備份集、pfile、controlfile 、tnsoracle.ora文件上傳到standbyDB上

  采用linux操作系統的scp命令

   scp /home/data/backup/fullbackup_%U oracle@10.202.0.2:/home/data/backup/fullbackup_%U;

   scp /home/oracle/oradata/rman/standby01.ctl oracle@10.202.0.2:/home/oracle/oradata/rman/standby01.ctl ;

   scp /home/oracle/produce/10.2.0.1/dbs/initoracle.ora oracle@10.202.0.2:/home/oracle/produce/10.2.0.1/dbs/initoracle.ora;  

9  測試遠程登錄

         tnsping primary;

         tnsping standby;    

         sqlplus sys/oracle as sysdba@stan

standbyDB:

  1 檢查文件是否拷貝過來,這里學要將文件放置在與primaryDB上備份的存儲位置相同的目錄;

  2  修改pfile中的參數

      vi /home/oracle/produce/10.20.0.1/dbs/initygzhou.ora     //修改的參數

db_unique_name=stan

control_files='/home/oracle/oradata/rman/standby01.ctl','/home/oracle/oradata/rman/standby02.ctl','/home/oracle/oradata/rman/standby03.ctl',

log_archive_config='dg=(primary,standby)

log_archive_dest_1='location=/home/data/archive/ valid_for=(all_logfiles,all_roles) db_unique_name=ygzhoudg

log_archive_dest_2='server=prim lgwr async valid_for=(online_logfiles,primary_roles) db_uniquen_name=ygzhoudb

fal_client=standby

fal_server=primary

:wq    //退出保存pfile    其他的參數不做修改

  3 創建spfile,通過pfile

               sqlplus "/as sysdba"

               create spfile from pfile;

  4  測試遠程登錄

       tnsping primary;

       tnsping standby;

       sqlplus sys/oracle as sysdba@primary

  5  開啟standbyDB到nomount狀態

       startup nomount;

 6  開啟數據庫到mount狀態        //此時需要用到controlfile文件,所以需要確保spfile中的control_files參數中的路徑與controlfile實際保存路徑相同

       alter database mount standby database;

 7  利用rman備份集還原、恢復數據庫

     rman target /

    restore database from '/home/data/backup/fullbackup_%U';

 8  將standbyDB至于自動恢復狀態,應用redo服務

    alter database recover managed standby database disconnect  from  session;


ok!

rman dataguard配置全過程結束;

檢驗:

               在primaryDB上切換log,在standbyDB上檢測是否同步。

       


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24867586/viewspace-688605/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2011-02-11

  • 博文量
    167
  • 访问量
    366697