Oracle 11G使用DG Broker建立DataGuard
Oracle 11G使用DG Broker建立DataGuard
1.環境:
a.主機環境:CentOS6.5
b.軟體環境:oracle 11.2.0.4
c.主機資訊:
DG1:192.168.100.51(資料庫sid:atest)
DG2:192.168.100.52
2.前提工作(主從都要設定):
a.關閉防火牆:/etc/init.d/iptables stop
b.關閉selinux:setenforce 0
查看狀態:getenforce(關閉狀態:Permissive)
3.3.主庫設定:
a.設定主庫db_unique_name:
alter system set db_unique_name='patest' scope=spfile;
b.設定主庫為強制記錄日誌:
alter database force logging;
檢查狀態(YEs為強制):
select name,force_logging from v$database;
c.設定standy_file_management:
alter system set standby_file_management ='AUTO';
d.建立standbylog:
alter database add standby logfile group 11 '/u01/app/oracle/oradata/ATEST/standbylog/standby11.log' size 50m;
alter database add standby logfile group 12 '/u01/app/oracle/oradata/ATEST/standbylog/standby12.log' size 50m;
alter database add standby logfile group 13 '/u01/app/oracle/oradata/ATEST/standbylog/standby13.log' size 50m;
alter database add standby logfile group 14 '/u01/app/oracle/oradata/ATEST/standbylog/standby14.log' size 50m;
e.開啟歸檔(簡單不詳述):
alter system set log_archive_dest_1='location=/u01/app/oracle/oradata/ATEST/archivelog';
alter database archivelog;
f.開啟DGbroker:
alter system set DG_BROKER_START=TRUE;
g.傳輸pfile和密碼檔案:
create pfile from spfile;
scp initatest.ora orapwatest 192.168.100.52:/u01/app/oracle/product/11.2.0/db1/dbs/
h.設定監聽:atest,patest,patest_DGMGRL
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = atest)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db1)
(SID_NAME = atest)
)
(SID_DESC =
(GLOBAL_DBNAME = patest)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db1)
(SID_NAME = atest)
)
(SID_DESC =
(GLOBAL_DBNAME = patest_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db1)
(SID_NAME = atest)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vijay01.database.com)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
i.設定tnsnames.ora
ATEST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.51)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = atest)
)
)
PATEST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.51)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = atest)
)
)
SATEST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.52)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = atest)
)
)
4.備庫設定:
a.設定監聽:atest,satest,satest_DGMGRL
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = atest)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db1)
(SID_NAME = atest)
)
(SID_DESC =
(GLOBAL_DBNAME = satest)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db1)
(SID_NAME = atest)
)
(SID_DESC =
(GLOBAL_DBNAME = satest_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db1)
(SID_NAME = atest)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vijay02.database.com)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app/oracle
b.設定tnsnames.ora
ATEST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.52)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = atest)
)
)
SATEST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.52)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = atest)
)
)
PATEST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.51)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = atest)
)
)
5.備份主庫:
a.rman target /
b.backup database;
6.在備庫上複製主庫:
a.修改備庫pfile上的db_unique_name=satest
b.啟動資料庫到nomount:
startup nomount
c.登陸rman:
rman target sys/123456@patest auxiliary sys/123456@satest
d.開始複製:
duplicate target database for standby nofilenamecheck from active database;
7.設定DGbroker:
a.登陸dgmgrl:
dgmgrl sys/123456@patest
b.設定主庫:
create configuration dgc as primary database is patest connect identifier is patest;
c.添加備庫:
add database satest as connect identifier is satest maintained as physical;
d.啟用設定檔:
enable configuration
e.查看DGbroker配置:
show configuration [verbose];
show database [verbose] 'satest';
show database 'patest''StatusReport';
f.查看資料庫的DG狀態:
SELECT GROUP#,dbid,archived,status from v$standby_log;
select dest_id,valid_type,valid_role,valid_now from v$archive_dest;
select process,status,group#,thread#,sequence# from v$managed_standby order by process,group#,thread#,sequence#;
select name,value,time_computed from v$dataguard_stats;
select timestamp,facility,dest_id,message_num,error_code,message from v$dataguard_status order by timestamp;
select recid,archived,applied from v$archived_log;
8.DG不同步檢查步驟:
1.檢查密碼檔案
2.檢查網路
3.檢查參數檔案
4.檢查防火牆或selinux
5.如以上均無問題,只能說明dg環境有問題,需要重新搭建dg(重新傳輸資料檔案到主庫,在重新同步)