Dataguard 物理安裝

linyu2012發表於2009-09-21

一 : 環境配置
1.檢視linux版本號
[oracle@fastrise02 /]$ lsb_release -a
LSB Version: :core-3.0-ia32:core-3.0-noarch:graphics-3.0-ia32:graphics-3.0-noarch
Distributor ID: CentOS
Description: CentOS release 4.7 (Final)
Release: 4.7
Codename: Final

2.檢視oracle版本號
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

3.配置oracle帳戶的環境變數
編輯 vi .bash_profile

ORACLE_BASE=/u01
ORACLE_HOME=/u01/oracle
ORACLE_SID=snowdb
PATH=$ORACLE_HOME/bin:$PATH
NLS_LANG=american_america.ZHS16GBK;
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH NLS_LANG

4.配置hosts、IP、listener.ora、tnsname.ora.

vi /etc/hosts
172.16.99.195 fastrise01
172.16.99.196 fastrise02

vi /etc/sysconfig/network-scripts/ifcfg-eth0
ONBOOT=yes
USERCTL=no
IPV6INIT=no
PEERDNS=yes
GATEWAY=172.16.99.254
TYPE=Ethernet
DEVICE=eth0
HWADDR=00:0c:29:31:2d:fe
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=172.16.99.196

vi /u01/oracle/network/admin/listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = fastrise02)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)

vi /u01/oracle/network/admin/tnsnames.ora
FASTRISE02 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.99.196)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = snowdb)
)
)
FASTRISE01 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.99.195)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = snowdb)
)
)
5.建立主資料庫(dbca)
ORA_SID =snowdb

二:建立並配置主、備庫庫
配置步驟首先,裝好主庫fastrise01和備庫fastrise02上的oracle,建sid同為snowdb的庫,所有設定完全相同。然後停止shutdown兩臺上的oracle,將主庫fastrise01上的所有資料檔案、控制檔案、初始化init***.ora檔案、redo檔案和password檔案都copy到備庫fastrise02機器的相應位置(還可以利用熱備,rman等來建立初始備庫),這樣,我們就擁有了兩臺完全一樣的ORACLE SERVER 。
1.在primary database上設定force logging
SQL>create pfile from spfile;
SQL>alter database force logging;
2.修改primary database初始化引數
SERVICE_NAMES=SNOWDB
DB_UNIQUE_NAME='UQN_NODE1'
LOG_ARCHIVE_CONFIG='DG_CONFIG=(UQN_NODE2,UQN_NODE1)'
LOG_ARCHIVE_DEST_2=
'SERVICE=FASTRISE02 ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=UQN_NODE2'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
LOG_ARCHIVE_MAX_PROCESSES=30
FAL_SERVER=FASTRISE02
FAL_CLIENT=FASTRISE01
STANDBY_FILE_MANAGEMENT=AUTO
透過 VALID_FOR 屬性指定傳輸及接收物件
valid_for 配合其 redo_log_type,database_role 屬性,其理解為:為指定角色設定日誌檔案的歸檔路徑,主要目的是為了輔助一旦發生角色切換操作後資料庫的正常運轉。
redo_log_type 可設定為: online_logfile ,standby_logfile ,all_logfiles
database_role 可設定為: primary_role ,standby_role , all_roles
online_logfile: 表示歸檔聯機重做日誌
standby_logfile:表示歸檔備用資料庫的重做日誌/接受的重做日誌
all_logfiles: online_logfile && standby_logfile
primary_role: 僅當資料庫角色為主庫時候歸檔生效
standby_role: 僅當資料庫角色為備庫時候歸檔生效
all_role: 任意角色歸檔均生效
3. 設定primary database為archivelog模式
SQL>shutdown immediate;
SQL>startup mount;
SQL>alter database archivelog;
SQL>alter database open:
4.在primary database上建立standby database的控制檔案
SQL> shutdown immediate;
SQL> startup mount pfile='/u01/oracle/dbs/initsnowdb.ora';
SQL> alter database create standby controlfile as '/u01/testst.ctl';
SQL>alter database open;
然後將該controlfile複製到standby server的對應位置
5.修改standby databse的初始化引數
SERVICE_NAMES=SNOWDB
DB_UNIQUE_NAME='UQN_NODE2'
LOG_ARCHIVE_CONFIG='DG_CONFIG=(UQN_NODE1,UQN_NODE2)'
LOG_ARCHIVE_DEST_2=
'SERVICE=FASTRISE01 ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=UQN_NODE1'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
LOG_ARCHIVE_MAX_PROCESSES=30
FAL_SERVER=FASTRISE01
FAL_CLIENT=FASTRISE02
STANDBY_FILE_MANAGEMENT=AUTO
6.啟動primary database
SQL>startup pfile='/u01/oracle/dbs/initsnowdb.ora';
7.啟動standby database
SQL>startup nomount pfile='/u01/oracle/dbs/initsnowdb.ora'
SQL>alter database mount standby database;
8.啟動standby database到recover manage模式
SQL>alter database recover managed standby database disconnect from session;
三:測試主備庫方案
1.檢視歸檔情況及其傳輸方法
⑴檢視全部歸檔數:
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/oradata/arch1
Oldest online log sequence 48
Next log sequence to archive 50
Current log sequence 50
⑵檢視正在應用歸檔:
SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
SEQUENCE# APP
---------- ---
8 NO
8 YES
⑶檢視日誌無法傳送
SQL>select dest_name,status,error from v$archive_dest;
檢視相應的歸檔路徑的狀態是否valid,否則根據error資訊進行處理
⑷檢視歸檔是否有錯誤同步
SELECT DESTINATION, STATUS, ARCHIVED_THREAD#, ARCHIVED_SEQ# FROM V$ARCHIVE_DEST_STATUS WHERE STATUS <> 'DEFERRED' AND STATUS <> 'INACTIVE';
DESTINATION
--------------------------------------------------------------------------------
STATUS ARCHIVED_THREAD# ARCHIVED_SEQ#
--------- ---------------- -------------
/u01/oradata/arch1
VALID 1 49

fastrise02
VALID 1 16

[@more@]test

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15242702/viewspace-1027187/,如需轉載,請註明出處,否則將追究法律責任。

相關文章