Oracel10G Dateguard 配置最大性能保護模式

安裝環境:
OS:RHL5+ORACLE10G10.2.0.1
IP:192.168.1.202(primary) 192.168.1.102(standby)
ORACLE_SID:oradb
ORACLE_HOME:/u01/oracle/product/10gjava

配置standby database爲MAXIMIZE PERFORMANCE模式sql

1.設置主庫爲force logging
[oracle@primary /]$ sqlplus / as sysdba
SQL> startup
SQL> alter database force logging;
2.設置primary(主庫)爲歸檔模式:
SQL> archive log list
SQL> alter system set log_archive_dest_1='location=/opt/archivelog/arch1' scope=spfile;  //設置歸檔路徑
SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;
SQL> archive log list;
3.檢查primary(主庫)是否有口令文件,如沒有需創建
orapwd file='/u01/oracle/product/10g/dbs/orawdorcl.ora' password=oracledb entries=5
4.爲主數據庫添加"備用聯機日誌文件"
SQL> alter database add standby logfile group 4 ('/u01/oracle/product/oradata/oradb/redo04.log') size 50M;
Database altered.
SQL> alter database add standby logfile group 5 ('/u01/oracle/product/oradata/oradb/redo05.log') size 50m;
Database altered.
SQL> alter database add standby logfile group 6 ('/u01/oracle/product/oradata/oradb/redo06.log') size 50M;
Database altered.
SQL> alter database add standby logfile group 7 ('/u01/oracle/product/oradata/oradb/redo07.log') size 50M;
Database altered.
5.修改primary(主庫)參數文件
SQL> create pfile='/u01/oracle/product/10g/dbs/initoradb.ora' from spfile;
[oracle@primary /]$ vi /u01/oracle/product/10g/dbs/initoradb.ora
oradb.__db_cache_size=155189248
oradb.__java_pool_size=4194304
oradb.__large_pool_size=4194304
oradb.__shared_pool_size=62914560
oradb.__streams_pool_size=0
*.audit_file_dest='/u01/oracle/product/admin/oradb/adump'
*.background_dump_dest='/u01/oracle/product/admin/oradb/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/oracle/product/oradata/oradb/control01.ctl','/u01/oracle/product/oradata/oradb/control02.ctl','/u01/oracle/product/oradata/oradb/control03.ctl'
*.core_dump_dest='/u01/oracle/product/admin/oradb/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='oradb'
*.db_recovery_file_dest='/u01/oracle/product/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=oradbXDB)'
*.job_queue_processes=10
*.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'
*.LOG_ARCHIVE_MAX_PROCESSES=30
*.open_cursors=300
*.pga_aggregate_target=75497472
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=228589568
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/oracle/product/admin/oradb/udump'數據庫

#add below parameter for primary database   //添加如下配置信息
*.DB_UNIQUE_NAME='primary'
*.FAL_CLIENT='primary'
*.FAL_SERVER='standby'
*.log_archive_config='DG_CONFIG=(primary,standby)'
*.log_archive_dest_1='location=/opt/archivelog/arch1 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=primary'
*.log_archive_dest_2='SERVICE=standby arch ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby'
*.LOG_ARCHIVE_DEST_STATE_1='ENABLE'
*.LOG_ARCHIVE_DEST_STATE_2='ENABLE'
*.STANDBY_FILE_MANAGEMENT='AUTO'網絡

 6.primary(主庫)用PFILE創建SPFILE
[oracle@primary /]$ sqlplus '/ as sysdba'
SQL> create spfile from pfile='/u01/oracle/product/10g/dbs/initoradb.ora';
7.創建備用庫的控制文件
SQL> alter database create standby controlfile as '/u01/oracle/product/oradata/oradb/standby_ctl01.ctl';
8. 配置primary(主庫) listener.ora,tnsnames.ora 文件
[root@primary /]# cd /u01/app/oracle/10.2.0/db_1/network/admin
[root@primary admin]# vi listener.ora
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = oradb)
      (ORACLE_HOME = /u01/oracle/product/10g)
      (SID_NAME = oradb)
    )
  )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521))
    )
  )session

[root@primary admin]# vi tnsnames.ora
PRIMARY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVER = DEDICATED)
      (SERVICE_NAME = oradb)
    )
  )
STANDBY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.102)(PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVER = DEDICATED)
      (SERVICE_NAME = oradb)
    )
  )
EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )oracle

到此primary(主庫)就配置完成,下面進入standby(備庫)配置:app

1. 安裝oracle 10g 數據庫軟件,不建立數據庫。
注:standby(備庫)安裝的數據庫版本與目錄結構與primary(主庫)相同。
2.拷貝 primary(主庫)的密碼文件,控制文件,數據文件,參數文件,日誌文件到 standby(備庫)
[root@primary admin]# cd /u01/oracle/product/
[root@primary product]# ls
10g  admin  flash_recovery_area  oradata  oraInventory
[root@primary product]# scp -r admin root@192.168.1.102:/u01/oracle/product/
[root@primary product]# scp -r oradata root@192.168.1.102:/u01/oracle/product/
[root@primary product]# scp -r flash_recovery_area root@192.168.1.102:/u01/oracle/product/
[root@primary product]# scp -r admin root@192.168.1.102:/u01/oracle/product/
[root@primary dbs]# cd /u01/oracle/product/10g/dbs/
[root@primary product]# scp -r initoradb.ora root@192.168.1.102:/u01/oracle/product/10g/dbs/
[root@primary product]# scp -r orapworadb root@192.168.1.102:/u01/oracle/product/10g/dbs/
3.登陸 standby(備庫) 進行配置:
[root@standby /]# cd /u01/oracle/product/
[root@standby product]# chown -R oracle:oinstall admin flash_recovery_area oradata
[root@standby product]# cd oradata
[root@standby oradb]# ls
control01.ctl  control03.ctl  redo01.log  redo03.log  redo05.log  redo07.log         sysaux01.dbf  temp01.dbf     users01.dbf
control02.ctl  example01.dbf  redo02.log  redo04.log  redo06.log  standby_ctl01.ctl  system01.dbf  undotbs01.dbf
[root@standby oradb]# rm -rf control01.ctl
[root@standby oradb]# mv standby_ctl01.ctl control01.ctl
[root@standby oradb]# rm -rf control02.ctl control03.ctl
[root@standby oradb]# ls
control01.ctl  redo01.log  redo03.log  redo05.log  redo07.log    system01.dbf  undotbs01.dbf
example01.dbf  redo02.log  redo04.log  redo06.log  sysaux01.dbf  temp01.dbf    users01.dbf
[root@standby oradb]# cp control01.ctl control02.ctl
[root@standby oradb]# cp control01.ctl control03.ctl
[root@standby oradb]# ls
control01.ctl  control03.ctl  redo01.log  redo03.log  redo05.log  redo07.log    system01.dbf  undotbs01.dbf
control02.ctl  example01.dbf  redo02.log  redo04.log  redo06.log  sysaux01.dbf  temp01.dbf    users01.dbf
[root@standby /]# cd /u01/oracle/product/10g/dbs/
[root@standby dbs]# chown -R oracle:oinstall orapworadb initoradb.ora
4.修改 standby(備庫)參數文件
[root@standby /]# cd /u01/oracle/product/10g/dbs
[root@standby dbs]# vi initoradb.ora
修改成以下:
oradb.__db_cache_size=150994944
oradb.__java_pool_size=4194304
oradb.__large_pool_size=4194304
oradb.__shared_pool_size=67108864
oradb.__streams_pool_size=0
*.audit_file_dest='/u01/oracle/product/admin/oradb/adump'
*.background_dump_dest='/u01/oracle/product/admin/oradb/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/oracle/product/oradata/oradb/control01.ctl','/u01/oracle/product/oradata/oradb/control02.ctl','/u01/oracle/product/oradata/oradb/control03.ctl'
*.core_dump_dest='/u01/oracle/product/admin/oradb/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='oradb'
*.db_recovery_file_dest='/u01/oracle/product/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=oradbXDB)'
*.job_queue_processes=10
*.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'
*.LOG_ARCHIVE_MAX_PROCESSES=30
*.open_cursors=300
*.pga_aggregate_target=75497472
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=228589568
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/oracle/product/admin/oradb/udump'dom

#add below parameter for standby database                    //添加如下配置信息
*.DB_UNIQUE_NAME='standby'
*.log_archive_config='DG_CONFIG=(primary,standby)'
*.log_archive_dest_1='location=/opt/archivelog/arch1 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby'
*.log_archive_dest_2='SERVICE=standby arch ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=primary'
*.LOG_ARCHIVE_DEST_STATE_1='ENABLE'
*.LOG_ARCHIVE_DEST_STATE_2='ENABLE'
*.STANDBY_FILE_MANAGEMENT='AUTO'
*.FAL_CLIENT='standby'
*.FAL_SERVER='primary'ide

5.配置standby(備庫) 的listener.ora,tnsnames.ora 文件
[root@standby /]# cd /u01/oracle/product/10g/network/admin/
[root@standby admin]# vi listener.ora
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = oradb)
      (ORACLE_HOME = /u01/oracle/product/10g)
      (SID_NAME = oradb)
    )
  )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.102)(PORT = 1521))
    )
  )
[root@standby admin]# vi tnsnames.ora
primary =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = oradb)
    )
  )
STANDBY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.102)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = oradb)
    )
 
EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )測試

6. 測試 primary(主庫)與 standby(備庫)之間網絡連通
[oracle@standby ~]$ lsnrctl start
[oracle@standby ~]$ tnsping primary
[oracle@primary ~]$ lsnrctl start
[oracle@primary ~]$ tnsping standby

7. 打開standby(備庫)
[oracle@standby admin]$ sqlplus / as sysdba
SQL> startup mount pfile='/u01/oracle/product/10g/dbs/initoradb.ora';
SQL> create spfile from pfile='/u01/oracle/product/10g/dbs/initoradb.ora';
SQL> alter database recover managed standby database disconnect from session;

注;Data Guard 啓動順序:standby(備庫) -->  primary(主庫)
    Data Guard 啓動順序: primary(主庫) -->  standby(備庫)

8.打開 primary(主庫)
[oracle@primary /]$ sqlplus / as sysdba
SQL> startup

測試 primary(主庫)與 standby(備庫) 歸檔日誌文件是否同步:
primary(主庫)操做:
SQL> alter system switch logfile;
SQL> select FIRST_TIME,NEXT_TIME, APPLIED,SEQUENCE# from v$archived_log order by SEQUENCE#;
FIRST_TIM NEXT_TIME APP  SEQUENCE#
--------- --------- --- ----------
26-OCT-11 27-OCT-11 YES  12
27-OCT-11 27-OCT-11 YES  13

standby(備庫)操做:
SQL> select FIRST_TIME,NEXT_TIME, APPLIED,SEQUENCE# from v$archived_log order by SEQUENCE#;

FIRST_TIM NEXT_TIME APP  SEQUENCE#
--------- --------- --- ----------
26-OCT-11 26-OCT-11 YES  12
26-OCT-11 26-OCT-11 YES  13
測試成功 !!!

查看當前數據庫的運行模式及狀態:SQL> select switchover_status,database_role,protection_mode from v$database; 備庫中止歸檔日誌應用SQL> alter database recover managed standby database cancel;SQL> shutdown immediate;   注意:數據庫關機順序。。。。。

相關文章
相關標籤/搜索