如何進(jìn)行 11.2.0.4 DG for linux 部署,相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。
讓客戶(hù)滿(mǎn)意是我們工作的目標(biāo),不斷超越客戶(hù)的期望值來(lái)自于我們對(duì)這個(gè)行業(yè)的熱愛(ài)。我們立志把好的技術(shù)通過(guò)有效、簡(jiǎn)單的方式提供給客戶(hù),將通過(guò)不懈努力成為客戶(hù)在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:申請(qǐng)域名、網(wǎng)絡(luò)空間、營(yíng)銷(xiāo)軟件、網(wǎng)站建設(shè)、殷都網(wǎng)站維護(hù)、網(wǎng)站推廣。
1、oracle數(shù)據(jù)庫(kù) DB的工作示意圖
2、oracle dg的三大工作模式及對(duì)數(shù)據(jù)庫(kù)的需求依賴(lài)
3、本次實(shí)驗(yàn)的環(huán)境
4、oracle DG部署前的工作
在centdgpri機(jī)器上部署Oracle 11.2.0.4數(shù)據(jù)庫(kù)軟件并部署實(shí)例,在centdgstd機(jī)器上只安裝Oracle數(shù)據(jù)庫(kù)軟件,要求centdgpri和centdgstd機(jī)器上的oracle環(huán)境即數(shù)據(jù)庫(kù)相關(guān)的軟件部署路徑最好保持一致。
5、oracle DG的部署
主庫(kù)調(diào)整,開(kāi)啟歸檔
archive log list;
shutdown immediate;
startup mount;
alter system set log_archive_dest_1='location=/opt/oracle/arch';
alter database archivelog;
archive log list;
alter database open;
alter system archive log current
主庫(kù)調(diào)整,開(kāi)啟閃回
select force_logging, FLASHBACK_ON from v$database;
alter database force logging;
alter system set DB_RECOVERY_FILE_DEST_SIZE=10g;
alter system set db_recovery_file_dest='/opt/oracle/flash_recovery_area';
alter database FLASHBACK ON;
select force_logging, FLASHBACK_ON from v$database;
主庫(kù)調(diào)整,添加standby logfile日志
set linesize 1000
col member for a50
select * from v$logfile order by 1;
select GROUP# ,BYTES/1024/1024 size_M,STATUS,ARCHIVED from v$log;
alter database add standby logfile group 6 ('/opt/oracle/oradata/redo06.log') size 50m;
alter database add standby logfile group 7 ('/opt/oracle/oradata/redo07.log') size 50m;
alter database add standby logfile group 8 ('/opt/oracle/oradata/redo08.log') size 50m;
alter database add standby logfile group 9 ('/opt/oracle/oradata/redo09.log') size 50m;
alter database add standby logfile group 10 ('/opt/oracle/oradata/redo10.log') size 50m;
主庫(kù)調(diào)整,修改數(shù)據(jù)庫(kù)啟動(dòng)pfile文件
orcl.__db_cache_size=327155712 orcl.__java_pool_size=4194304 orcl.__large_pool_size=8388608 orcl.__oracle_base='/opt/oracle'#ORACLE_BASE set from environment orcl.__pga_aggregate_target=314572800 orcl.__sga_target=469762048 orcl.__shared_io_pool_size=0 orcl.__shared_pool_size=117440512 orcl.__streams_pool_size=0 *.audit_file_dest='/opt/oracle/admin/orcl/adump' *.audit_trail='db' *.compatible='11.2.0.4.0' *.control_files='/opt/oracle/oradata/orcl/control01.ctl','/opt/oracle/oradata/orcl/control02.ctl' *.db_block_size=8192 *.db_domain='' *.db_name='orcl' *.diagnostic_dest='/opt/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)' *.log_archive_dest_1='location=/opt/arch' *.memory_target=783286272 *.open_cursors=300 *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.undo_tablespace='UNDOTBS1'
log_archive_config='DG_CONFIG=(orcl,orcls)' log_archive_dest_1='LOCATION=/opt/oracle/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl' LOG_ARCHIVE_DEST_2='SERVICE=dbstandby LGWR ASYNC VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcls' LOG_ARCHIVE_DEST_STATE_1=ENABLE LOG_ARCHIVE_DEST_STATE_2=ENABLE FAL_SERVER=dbstandby FAL_CLIENT=dbprimary STANDBY_FILE_MANAGEMENT=AUTO *.log_file_name_convert='/opt/oracle/oradata','/opt/oracle/oradata' *.db_file_name_convert='/opt/oracle/oradata','/opt/oracle/oradata' |
主庫(kù)調(diào)整,重新生成spfile
startup pfile='$ORACLE_HOME/dbs/initorcl.ora';
create spfile from memory;
shutdown immediate;
startup;
show parameter spfile;
主庫(kù)調(diào)整,修改監(jiān)聽(tīng)配置文件listener.ora
LISTENER = (DESCRIPTION_LIST= (DESCRIPTION = (ADDRESS=(PROTOCOL=tcp)(HOST=centdgpri)(PORT=1521)) (ADDRESS=(PROTOCOL=ipc)(KEY= EXTPROC1521))) ) SID_LIST_LISTENER = (SID_LIST= (SID_DESC= (GLOBAL_DBNAME=orcl) (SID_NAME=orcl) (ORACLE_HOME=/opt/oracle/product/11.2.0.4/db) ) (SID_DESC = (GLOBAL_DBNAME = orcl_DGMGRL) (ORACLE_HOME = /opt/oracle/product/11.2.0.4/db) (SID_NAME= orcl) ) ) ADR_BASE_LISTENER = /opt/oracle |
主庫(kù)調(diào)整,修改TNS服務(wù)配置文件tnsnames.ora
DBPRIMARY= (DESCRIPTION= (ADDRESS_LIST= (ADDRESS=(PROTOCOL =TCP)(HOST=centdgpri)(PORT=1521)) ) (CONNECT_DATA=(SID=orcl)(SERVER=DEDICATED)) ) ORCL= (DESCRIPTION= (ADDRESS_LIST= (ADDRESS=(PROTOCOL =TCP)(HOST=centdgpri)(PORT=1521)) ) (CONNECT_DATA=(SID=orcl)(SERVER=DEDICATED)) ) DBSTANDBY= (DESCRIPTION= (ADDRESS_LIST= (ADDRESS=(PROTOCOL =TCP)(HOST=centdgstd)(PORT=1521)) ) (CONNECT_DATA=(SID=orcl)(SERVER=DEDICATED)) ) |
備庫(kù)調(diào)整,編輯數(shù)據(jù)庫(kù)啟動(dòng)pfile
*.audit_file_dest='/opt/oracle/diag/rdbms/orcl/orcl/adump' *.compatible='11.2.0.4.0' *.control_files='/opt/oracle/oradata/control01.ctl','/opt/oracle/oradata/control02.ctl' *.core_dump_dest='/opt/oracle/diag/rdbms/orcl/orcl/cdump' *.db_block_size=8192 *.db_create_file_dest='/opt/oracle/oradata' *.db_file_multiblock_read_count=16 *.db_name='orcl' *.db_recovery_file_dest='/opt/oracle/flash_recovery_area' *.db_recovery_file_dest_size=10G *.diagnostic_dest='/opt/oracle/diag/rdbms/orcl/orcl/trace' *.dispatchers='(PROTOCOL=TCP) (SERVICE=orcl)' *.job_queue_processes=10 *.log_archive_dest_1='LOCATION=/opt/oracle/arch' *.log_buffer=7356416 # log buffer update *.open_cursors=300 *.optimizer_dynamic_sampling=2 *.optimizer_mode='ALL_ROWS' *.pga_aggregate_target=186M *.plsql_warnings='DISABLE:ALL' # PL/SQL warnings at init.ora *.processes=150 *.query_rewrite_enabled='TRUE' *.remote_login_passwordfile='EXCLUSIVE' *.result_cache_max_size=2880K *.sga_target=560M *.skip_unusable_indexes=TRUE *.undo_management='AUTO' *.undo_tablespace='UNDOTBS1'
log_archive_config='DG_CONFIG=(orcls,orcl)' log_archive_dest_1='LOCATION=/opt/oracle/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcls' LOG_ARCHIVE_DEST_2='SERVICE=dbprimary LGWR ASYNC VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl' LOG_ARCHIVE_DEST_STATE_1=ENABLE LOG_ARCHIVE_DEST_STATE_2=ENABLE FAL_SERVER=dbprimary FAL_CLIENT=dbstandby STANDBY_FILE_MANAGEMENT=AUTO *.log_file_name_convert='/opt/oracle/oradata','/opt/oracle/oradata' *.db_file_name_convert='/opt/oracle/oradata','/opt/oracle/oradata' |
備庫(kù)調(diào)整,編輯監(jiān)聽(tīng)配置文件listener.ora
LISTENER = (DESCRIPTION_LIST= (DESCRIPTION = (ADDRESS=(PROTOCOL=tcp)(HOST=centdgstd)(PORT=1521)) (ADDRESS=(PROTOCOL=ipc)(KEY= EXTPROC1521))) ) SID_LIST_LISTENER = (SID_LIST= (SID_DESC= (GLOBAL_DBNAME=orcl) (SID_NAME=orcl) (ORACLE_HOME=/opt/oracle/product/11.2.0.4/db) ) (SID_DESC = (GLOBAL_DBNAME = orcls_DGMGRL) (ORACLE_HOME = /opt/oracle/product/11.2.0.4/db) (SID_NAME= orcl) ) ) ADR_BASE_LISTENER = /opt/oracle |
備庫(kù)調(diào)整,修改備庫(kù)TNS服務(wù)配置文件tnsnames.ora
DBPRIMARY= (DESCRIPTION= (ADDRESS_LIST= (ADDRESS=(PROTOCOL =TCP)(HOST=centdgpri)(PORT=1521)) ) (CONNECT_DATA=(SID=orcl)(SERVER=DEDICATED)) ) ORCLS= (DESCRIPTION= (ADDRESS_LIST= (ADDRESS=(PROTOCOL =TCP)(HOST=centdgstd)(PORT=1521)) ) (CONNECT_DATA=(SID=orcl)(SERVER=DEDICATED)) ) DBSTANDBY= (DESCRIPTION= (ADDRESS_LIST= (ADDRESS=(PROTOCOL =TCP)(HOST=centdgstd)(PORT=1521)) ) (CONNECT_DATA=(SID=orcl)(SERVER=DEDICATED)) ) |
6、主庫(kù)克隆島備庫(kù)
主庫(kù)創(chuàng)建sys密碼文件并傳送到備庫(kù)dbs目錄
orapwd file=$ORACLE_HOME/dbs/PWDorcl.ora password=WaterH2o entries=40 force=y
備庫(kù)創(chuàng)建和主庫(kù)一致的審計(jì)目錄
主庫(kù):
cd $ORACLE_BASE
tar -cvf diag.tar diag/
scp diag.tar centdgstd:/opt/oracle
備庫(kù):
mv diag $ORACLE_BASE/
cd $ORACLE_BASE
tar -xvf diag.tar
mkdir -p $ORACLE_BASE/flash_recovery_area
mkdir
-p $ORACLE_BASE/oradata
克隆主庫(kù)前的TNS服務(wù)測(cè)試,一定要在主備庫(kù)均進(jìn)行測(cè)試
tnsping dbprimary
tnsping dbstandby
sqlplus sys/WaterH2o@dbprimary as sysdba
sqlplus sys/WaterH2o@dbstndby as sysdba
主庫(kù)克隆到備機(jī)
rman target sys/WaterH2o@dbprimary
auxiliary sys/WaterH2o@dbstandby
duplicate
target database for standby from active database nofilenamecheck;
7、開(kāi)啟備庫(kù)的日志同步進(jìn)程
alter database recover managed standby database
disconnect from session;
8、查看主備庫(kù)的角色
select db_unique_name,database_role,switchover_status,open_mode from v$database;
9、驗(yàn)證物理DG的數(shù)據(jù)同步
select switchover_status from v$database; --查看有沒(méi)有g(shù)ap的歸檔日志
主庫(kù):
select STATUS, GAP_STATUS from V$ARCHIVE_DEST_STATUS where DEST_ID = 2;
主庫(kù):
SQL>select STATUS, GAP_STATUS from V$ARCHIVE_DEST_STATUS where DEST_ID = 2;
STATUS GAP_STATUS
--------- ------------------------
VALID RESOLVABLE GAP
備庫(kù):
SQL> select STATUS, GAP_STATUS from V$ARCHIVE_DEST_STATUS where DEST_ID = 2;
STATUS GAP_STATUS
--------- ------------------------
VALID NO
GAP
查看主備庫(kù)角色及狀態(tài)
select open_mode,database_role,db_unique_name from v$database;-
主庫(kù):
SQL> select open_mode,database_role,db_unique_name from v$database;
OPEN_MODE DATABASE_ROLE DB_UNIQUE_NAME
-------------------- ---------------- ------------------------------
READ WRITE PRIMARY orcl
SQL>
備庫(kù):
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 orcl
SQL>
查看主備庫(kù)的序列號(hào)
select max(sequence#) from v$archived_log;
archive log list;
主庫(kù):
SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
25
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /opt/arch
Oldest online log sequence 24
Next log sequence to archive 26
Current log sequence 26
SQL>
備庫(kù):
SQL> select max(sequence#) from v$archived_log;
MAX(SEQUENCE#)
--------------
25
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /opt/arch
Oldest online log sequence 17
Next log sequence to archive 0
Current log sequence 25
SQL>
10、DG Broker手工管理配置
DG部署前的主庫(kù)確認(rèn)開(kāi)啟閃回
select
flashback_on from v$database;
show parameter dg_broker_start
alter system set dg_broker_start=true;
show parameter
dg_broker_start
主庫(kù)登錄dgmrl客戶(hù)端
dgmgrl
sys/WaterH2o@dbprimary
創(chuàng)建dgb控制文件(注意一定要進(jìn)行tnsping TNS服務(wù)名測(cè)試)
create
configuration my_dgb as primary database is orcl connect identifier is dgb_p;
DGMGRL> create configuration my_dgb as primary database is orcl connect identifier is dbprimary; Configuration "my_dgb" created with primary database "orcl" |
添加備庫(kù)
DGMGRL> add database orcls as connect identifier is dbstandby maintained as physical; Database "orcls" added |
啟用配置文件
DGMGRL> enable configuration; Enabled. DGMGRL> |
驗(yàn)證配置啟動(dòng)狀態(tài)
DGMGRL> show configuration Configuration - my_dgb Protection Mode: MaxPerformance Databases: orcl - Primary database orcls - Physical standby database Fast-Start Failover: DISABLED Configuration Status: SUCCESS DGMGRL> |
開(kāi)啟主備庫(kù)StandbyFileManagement并同步到DGB
SQL>alter system set STANDBY_FILE_MANAGEMENT=AUTO scope=both;
DGMGRL> edit database orcl set property StandbyFileManagement='AUTO';
DGMGRL> edit database orcls set property StandbyFileManagement='AUTO';
DGMGRL> EDIT DATABASE orcl SET PROPERTY LogXptMode='async';
DGMGRL> EDIT DATABASE orcls SET PROPERTY LogXptMode='async';
取消物理DG的兩個(gè)參數(shù)
alter system set fal_server='' scope=both sid='*';
alter system set fal_client='' scope=both sid='*';
11、物理DG 通過(guò)Broker手工切換主備庫(kù)的角色
主備庫(kù)切換前的角色檢查
主庫(kù):
SQL> select database_role,switchover_status,open_mode from v$database; DATABASE_ROLE SWITCHOVER_STATUS OPEN_MODE ---------------- -------------------- -------------------- PRIMARY TO STANDBY READ WRITE |
備庫(kù):
SQL> select database_role,switchover_status,open_mode from v$database; DATABASE_ROLE SWITCHOVER_STATUS OPEN_MODE ---------------- -------------------- -------------------- PHYSICAL STANDBY NOT ALLOWED MOUNTED |
DGMGRIL控制臺(tái)切換主備庫(kù)
DGMGRL> show configuration Configuration - my_dgb Protection Mode: MaxPerformance Databases: orcl - Primary database orcls - Physical standby database Fast-Start Failover: DISABLED Configuration Status: SUCCESS DGMGRL> switchover to orcls Performing switchover NOW, please wait... Operation requires a connection to instance "orcl" on database "orcls" Connecting to instance "orcl"... Connected. New primary database "orcls" is opening... Operation requires startup of instance "orcl" on database "orcl" Starting instance "orcl"... ORACLE instance started. Database mounted. Database opened. Switchover succeeded, new primary is "orcls" DGMGRL> DGMGRL> show configuration Configuration - my_dgb Protection Mode: MaxPerformance Databases: orcls - Primary database orcl - Physical standby database Fast-Start Failover: DISABLED Configuration Status: SUCCESS DGMGRL> |
DGMGRIL控制臺(tái)手工切換主備庫(kù)的結(jié)果檢查
新主庫(kù): SQL> select db_unique_name,database_role,switchover_status,open_mode from v$database; DB_UNIQUE_NAME DATABASE_ROLE SWITCHOVER_STATUS OPEN_MODE ------------------------------ ---------------- -------------------- -------------------- orcls PRIMARY TO STANDBY READ WRITE 新備庫(kù): SQL> select db_unique_name,database_role,switchover_status,open_mode from v$database; DB_UNIQUE_NAME DATABASE_ROLE SWITCHOVER_STATUS OPEN_MODE ------------------------------ ---------------- -------------------- -------------------- orcl PHYSICAL STANDBY NOT ALLOWED MOUNTED |
12、啟動(dòng)DG FFS即啟動(dòng)Failvoer Fast Start
啟用FFS必須滿(mǎn)足的條件
主備庫(kù)日志同步模式是自動(dòng)同步
LogXptMode='async'
EDIT DATABASE orcl SET PROPERTY LogXptMode='async';
EDIT DATABASE orcls SET PROPERTY LogXptMode='async';
主備庫(kù)均開(kāi)啟閃回,目的是啟動(dòng)快速自動(dòng)恢復(fù)數(shù)據(jù)庫(kù)
select name,db_unique_name,flashback_on from v$database;
處理standby的備庫(kù)打開(kāi)閃回
alter database open read only;
alter database flashback on;
啟用主備庫(kù)的FFS
edit database orcl set property FastStartFailoverTarget=orcls;
edit database orcls set property FastStartFailoverTarget=orcl;
enable fast_start failover
啟用結(jié)果
13、DG Broker FFS功能測(cè)試
主庫(kù)shutdown abort故障模擬
登錄主庫(kù)發(fā)起shutdown abort
備庫(kù)告警日志提示備庫(kù)成功接管主庫(kù)
observer提示角色自動(dòng)切換
確認(rèn)角色自動(dòng)切換結(jié)果
主庫(kù)恢復(fù)后啟動(dòng)
observer日志提示主備角色分配
原主庫(kù)恢復(fù)后的主備庫(kù)角色查看
原主庫(kù)端查看
原備庫(kù)端查看
看完上述內(nèi)容,你們掌握如何進(jìn)行 11.2.0.4 DG for linux 部署的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!