您好,登錄后才能下訂單哦!
1、環境介紹
搭建一套ADG災備環境。主庫環境為12.1.2.0 RAC,備庫同主庫,軟件補丁均已安裝。
2、配置步驟
2.1 歸檔
select log_mode from v$database; #####是否為歸檔模式
alter database force logging; #####強制歸檔
2.2 主庫standby log
alter database add standby logfile thread 1 group 5 ('+DATADG') size 2048M;
alter database add standby logfile thread 1 group 6 ('+DATADG') size 2048M;
alter database add standby logfile thread 1 group 7 ('+DATADG') size 2048M;
alter database add standby logfile thread 1 group 8 ('+DATADG') size 2048M;
alter database add standby logfile thread 1 group 9 ('+DATADG') size 2048M;
alter database add standby logfile thread 1 group 10 ('+DATADG') size 2048M;
alter database add standby logfile thread 2 group 11 ('+DATADG') size 2048M;
alter database add standby logfile thread 2 group 12 ('+DATADG') size 2048M;
alter database add standby logfile thread 2 group 13 ('+DATADG') size 2048M;
alter database add standby logfile thread 2 group 14 ('+DATADG') size 2048M;
alter database add standby logfile thread 2 group 15 ('+DATADG') size 2048M;
alter database add standby logfile thread 2 group 16 ('+DATADG') size 2048M;
3、文件
3.1 密碼文件
拷貝主庫密碼文件到備庫,最開始放在$ORACLE_HOME/dbs目錄下,后續配置完成后,需要將密碼文件存放在ASM磁盤組中并進行改名。
scp orapwbmacdb IP: $ORACLE_HOME/dbs1
ASMCMD> pwcopy /u01/app/oracle/product/12.1.0/dbhome_1/dbs/orapwbmacdb1 +datadg/bmacdbdg/password/orapwbmacdb
copying /u01/app/oracle/product/12.1.0/dbhome_1/dbs/orapwbmacdb1 -> +datadg/bmacdbdg/password/orapwbmacdb
3.2 參數文件
拷貝主庫參數文件到備庫,放在$ORACLE_HOME/dbs目錄下,恢復完成后,需要將參數文件存放在ASM磁盤組中,并通過pfile指定其位置。參數文件內容如下:
*.audit_file_dest='/u01/app/oracle/admin/bmacdb/adump'
*.control_files='+DATADG/BMACDB/control01.ctl','+DATADG/BMACDB/control02.ctl'
*.db_file_name_convert='+DATADG/BMACDB/DATAFILE/','+DATADG/BMACDB/DATAFILE/','+SSDDG/BMACDB/DATAFILE/','+DATADG/BMACDB/DATAFILE/','+DATADG/bmacdb/','+DATADG/BMACDB/DATAFILE/'
*.db_unique_name='bmacdbdg'
*.log_archive_config='DG_CONFIG=(bmacdb,bmacdbdg)'
*.log_archive_dest_1='LOCATION=+ARCHDG VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=bmacdbdg'
*.log_archive_dest_2='SERVICE=BMACDB1 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=BMACDB'
*.log_file_name_convert='+SSDDG/bmacdb/','+LOGDG/BMACDB/ONLINELOG/'
*.fal_server='BMACDB'
以上參數時我們需要修改的地方。
3.3 目錄結構
mkdir -p /u01/app/oracle/admin/bmacdb/adump
ASM:
+DATADG/BMACDB/DATAFILE
+LOGDG/BMACDB/ONLINELOG
創建完目錄結構后,啟動數據庫到nomount狀態。
startup nomount
3.4 配置監聽
在配置ADG開始階段,需要在備庫靜態注冊監聽,搭建完成后,可以將靜態注冊信息刪掉。靜態注冊信息如下:/u01/app/12.1.0/grid/network/admin/listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = bmacdbdg)
(ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_1)
(SID_NAME = bmacdb1)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = IP地址)(PORT = 1521))
)
)
配置完監聽后啟動監聽,靜態監聽信息如下:
Service "bmacdbdg" has 1 instance(s).
Instance "bmacdb1", status UNKNOWN, has 1 handler(s) for this service...
主庫連接串配置
主庫tnsnames.ora新增到備庫的連接串,并且在RAC兩個節點同時新增:
BMACDBDG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = IP地址)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bmacdbdg)
)
)
配置完成后,進行連通性測試:
sqlplus sys/password@BMACDBDG as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Tue Jun 18 14:28:16 2019
Copyright (c) 1982, 2014, Oracle. All rights reserved.
備庫連接串配置
備庫tnsnames.ora新增到主庫的連接串,并且在RAC兩個節點同時新增:
BMACDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = IP地址)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bmacdb)
)
)
配置完成后,進行連通性測試:
sqlplus sys/password@BMACDB as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Tue Jun 18 14:29:29 2019
Copyright (c) 1982, 2014, Oracle. All rights reserved.
4、恢復備庫
source /home/oracle/.profile
rman target sys/password@BMACDB auxiliary sys/password@BMACDBDG <<EOF
run
{
allocate channel cl1 type disk;
allocate auxiliary channel c1 type disk;
duplicate target database for standby from active database nofilenamecheck;
release channel c1;
release channel cl1;
}
EOF
給腳本授予執行權限并執行腳本:
chmod +x dg.sh
nohup ./dg.sh &
5、修改主庫參數
alter system set log_archive_config='dg_config=(bmacdb,bmacadg,bmacdg,bmacdbdg)';
alter system set log_archive_dest_4='service=BMACDBDG async valid_for=(online_logfiles,primary_role) db_unique_name=bmacdbdg';
6、備庫spfile
SQL> create spfile ='+datadg/bmacdbdg/spfilebmacdb.ora' from pfile;
File created.
oracle@bmacdrdb1:/home/oracle>cd $ORACLE_HOME/dbs
oracle@bmacdrdb1:/u01/app/oracle/product/12.1.0/dbhome_1/dbs>cat initbmacdb1.ora
spfile ='+datadg/bmacdbdg/spfilebmacdb.ora'
7、備庫RAC添加資源
srvctl add database -db bmacdbdg -dbname bmacdb -oraclehome /u01/app/oracle/product/12.1.0/dbhome_1 -dbtype RAC -role PHYSICAL_STANDBY
srvctl add instance -db bmacdbdg -instance bmacdb1 -node bmacdrdb1
srvctl add instance -db bmacdbdg -instance bmacdb2 -node bmacdrdb2
srvctl modify database -db bmacdbdg -spfile '+datadg/bmacdbdg/spfilebmacdb.ora' -pwfile '+datadg/bmacdbdg/password/orapwbmacdb'
srvctl modify database -db bmacdbdg -diskgroup DATADG,LOGDG
備庫配置信息:
oracle@bmacdrdb1:/home/oracle>srvctl config database -d bmacdbdg
Database unique name: bmacdbdg
Database name: bmacdb
Oracle home: /u01/app/oracle/product/12.1.0/dbhome_1
Oracle user: oracle
Spfile: +datadg/bmacdbdg/spfilebmacdb.ora
Password file: +datadg/bmacdbdg/password/orapwbmacdb
Domain:
Start options: open
Stop options: immediate
Database role: PHYSICAL_STANDBY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATADG,LOGDG
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: bmacdb1,bmacdb2
Configured nodes: bmacdrdb1,bmacdrdb2
Database is administrator managed
8、應用日志
alter database recover managed standby database disconnect from session;
alter database recover managed standby database cancel;
alter database open;
alter database recover managed standby database using current logfile disconnect;
select open_Mode,DATABASE_ROLE from v$database;
OPEN_MODE DATABASE_ROLE
-------------------- ----------------
READ ONLY WITH APPLY PHYSICAL STANDBY
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。