active dg实验

改好监听,tnsname啥的    
    
    
    sid,servicename,dbname 都是boss,uniquename才不一样
    
    
    
    SQL> alter database force logging;  
    Database altered.  
     
    SQL> alter system set db_unique_name='boss1' scope=spfile;  
    System altered.  
     
    SQL> alter system set log_archive_config='DG_CONFIG=(boss1,boss2)';    
    System altered.  
     
    SQL> alter system set log_archive_dest_1='LOCATION=/oracle/app/arch valid_for=(all_logfiles,all_roles) db_unique_name=boss1' scope=both;
    System altered.  
    
    SQL> alter system set log_archive_dest_2='SERVICE=boss2 lgwr sync valid_for=(online_logfile,primary_role) db_unique_name=boss2';  
    
    --LGWR ASYNC 从原理上 比LGWR SYNC 有很高的性能, 相对差的数据同步程度
    
    System altered.  
     
    SQL> alter system set fal_client='boss1';  --tns名
    System altered.  
     
    SQL> alter system set fal_server='boss2';  --tns名
    System altered.  
     
    SQL> alter system set standby_file_management=auto;  
    System altered.  
     
    SQL> alter database add standby logfile group 4 '/oracle/app/oradata/boss/standby04.log' size 50M;  
    Database altered.  
     
    SQL> alter database add standby logfile group 5 '/oracle/app/oradata/boss/standby05.log' size 50M;  
    Database altered.  
     
    SQL> alter database add standby logfile group 6 '/oracle/app/oradata/boss/standby06.log' size 50M;  
    Database altered.  
     
    SQL> alter database add standby logfile group 7 '/oracle/app/oradata/boss/standby07.log' size 50M;  
    Database altered.  

     
    SQL> create pfile='/home/oracle/initdg.ora' from spfile;  
    File created.
    
    
    shutdown immediate
    startup

    
    
    把pfile传到备库
    
    修改:
    *.db_unique_name='boss2'
    *.fal_client='boss2'
*.fal_server='boss1'
*.log_archive_dest_1='LOCATION=/oracle/app/arch valid_for=(all_logfiles,all_roles) db_unique_name=boss2'
*.log_archive_dest_2='SERVICE=boss1 lgwr sync valid_for=(online_logfile,primary_role) db_unique_name=boss1'
    
    
    
    lsnrctl start  
    orapwd file=$ORACLE_HOME/dbs/orapwboss password=oracle entries=100

    SQL> create spfile from pfile='/oracle/app/product/11g/dbs/initboss.ora';  
    File created.  
     
    SQL> startup nomount  
    
    发现2机的路径没建好
    mkdir /oracle/app/flash_recovery_area
    mkdir /oracle/app/flash_recovery_area/boss
    mkdir /oracle/app/arch
    mkdir -p /oracle/app/admin/boss/adump
    mkdir /oracle/app/admin/boss/dpdump
    mkdir /oracle/app/admin/boss/pfile
    mkdir -p /oracle/app/oradata/boss
    
    startup nomount
    
    
     
    rman target sys/oracle@boss1 auxiliary sys/oracle@boss2


配置静态监听,后面会贴出监听写法


    rman target sys/oracle@boss1 auxiliary sys/oracle@boss2
    
    duplicate target database for standby nofilenamecheck from active database;
    

    
SQL> SQL> select open_mode,database_role,db_unique_name from v$database;

OPEN_MODE            DATABASE_ROLE    DB_UNIQUE_NAME
-------------------- ---------------- ------------------------------
MOUNTED              PHYSICAL STANDBY boss2


alter database open;




SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ ONLY
    
alter database recover managed standby database using current logfile disconnect;


SQL> select open_mode,database_role,db_unique_name from v$database;

OPEN_MODE            DATABASE_ROLE    DB_UNIQUE_NAME
-------------------- ---------------- ------------------------------
READ ONLY WITH APPLY PHYSICAL STANDBY boss2




测试一下:在主库
conn scott/tiger
SQL> create table fuck as select * from dept;

Table created.

在备库
conn scott/tiger
SQL> select * from fuck;

    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON






set linesize 120
col name for a40
select NAME,sequence#,applied,ARCHIVAL_THREAD# from v$archived_log where  ARCHIVAL_THREAD#=1 order by sequence#;

NAME                                      SEQUENCE# APPLIED   ARCHIVAL_THREAD#
---------------------------------------- ---------- --------- ----------------
/oracle/app/flash_recovery_area/BOSS/arc          5 NO                       1
hivelog/2013_11_13/o1_mf_1_5_985ortmh_.a
rc

/oracle/app/arch/1_6_831372933.dbf                6 NO                       1
/oracle/app/arch/1_7_831372933.dbf                7 NO                       1
/oracle/app/arch/1_8_831372933.dbf                8 NO                       1
/oracle/app/arch/1_9_831372933.dbf                9 NO                       1
boss2                                             9 YES                      1
boss2                                            10 YES                      1
/oracle/app/arch/1_10_831372933.dbf              10 NO                       1

NAME                                      SEQUENCE# APPLIED   ARCHIVAL_THREAD#
---------------------------------------- ---------- --------- ----------------
/oracle/app/arch/1_11_831372933.dbf              11 NO                       1
boss2                                            11 YES                      1
boss2                                            12 YES                      1
/oracle/app/arch/1_12_831372933.dbf              12 NO                       1








主机:
[oracle@dg1 admin]$ cat listener.ora
# listener.ora Network Configuration File: /oracle/app/product/11g/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =  
  (SID_LIST =  
    (SID_DESC =  
      (GLOBAL_DBNAME = boss_main)  
      (ORACLE_HOME = /oracle/app/product/11g)  
      (SID_NAME = boss)  
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = dg1)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /oracle/app



[oracle@dg1 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /oracle/app/product/11g/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

boss1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dg1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = boss_main)
    )
  )

boss2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dg2)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = boss_standby)
    )
  )
 
 


备机:


[oracle@dg2 admin]$ cat listener.ora
# listener.ora Network Configuration File: /oracle/app/product/11g/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = boss_standby)
      (ORACLE_HOME = /oracle/app/product/11g)
      (SID_NAME = boss)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = dg2)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /oracle/app






[oracle@dg2 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /oracle/app/product/11g/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

boss1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dg1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = boss_main)
    )
  )

boss2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 180.200.2.23)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = boss_standby)
    )
  )





你可能感兴趣的:(数据库,dataguard)