溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Oracle 12C Rac到Rac搭建ADG

發(fā)布時(shí)間:2020-09-04 20:26:01 來源:網(wǎng)絡(luò) 閱讀:1122 作者:劉楓_Leo 欄目:關(guān)系型數(shù)據(jù)庫(kù)

1、環(huán)境介紹
搭建一套ADG災(zāi)備環(huán)境。主庫(kù)環(huán)境為12.1.2.0 RAC,備庫(kù)同主庫(kù),軟件補(bǔ)丁均已安裝。
2、配置步驟
2.1 歸檔

 select log_mode from v$database;  #####是否為歸檔模式
 alter database force logging;           #####強(qiáng)制歸檔

2.2 主庫(kù)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 密碼文件

拷貝主庫(kù)密碼文件到備庫(kù),最開始放在$ORACLE_HOME/dbs目錄下,后續(xù)配置完成后,需要將密碼文件存放在ASM磁盤組中并進(jìn)行改名。
 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 參數(shù)文件

拷貝主庫(kù)參數(shù)文件到備庫(kù),放在$ORACLE_HOME/dbs目錄下,恢復(fù)完成后,需要將參數(shù)文件存放在ASM磁盤組中,并通過pfile指定其位置。參數(shù)文件內(nèi)容如下:
*.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'
以上參數(shù)時(shí)我們需要修改的地方。

3.3 目錄結(jié)構(gòu)

mkdir -p /u01/app/oracle/admin/bmacdb/adump
ASM:
+DATADG/BMACDB/DATAFILE
+LOGDG/BMACDB/ONLINELOG
創(chuàng)建完目錄結(jié)構(gòu)后,啟動(dòng)數(shù)據(jù)庫(kù)到nomount狀態(tài)。
startup nomount

3.4 配置監(jiān)聽

在配置ADG開始階段,需要在備庫(kù)靜態(tài)注冊(cè)監(jiān)聽,搭建完成后,可以將靜態(tài)注冊(cè)信息刪掉。靜態(tài)注冊(cè)信息如下:/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))
    )
  )
配置完監(jiān)聽后啟動(dòng)監(jiān)聽,靜態(tài)監(jiān)聽信息如下:
Service "bmacdbdg" has 1 instance(s).
  Instance "bmacdb1", status UNKNOWN, has 1 handler(s) for this service...
主庫(kù)連接串配置
主庫(kù)tnsnames.ora新增到備庫(kù)的連接串,并且在RAC兩個(gè)節(jié)點(diǎn)同時(shí)新增:
BMACDBDG =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = IP地址)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = bmacdbdg)
    )
  )
配置完成后,進(jìn)行連通性測(cè)試:
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.

備庫(kù)連接串配置
備庫(kù)tnsnames.ora新增到主庫(kù)的連接串,并且在RAC兩個(gè)節(jié)點(diǎn)同時(shí)新增:
BMACDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = IP地址)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = bmacdb)
    )
  )
配置完成后,進(jìn)行連通性測(cè)試:
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、恢復(fù)備庫(kù)

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
給腳本授予執(zhí)行權(quán)限并執(zhí)行腳本:
chmod +x dg.sh
nohup ./dg.sh &

5、修改主庫(kù)參數(shù)

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、備庫(kù)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、備庫(kù)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
備庫(kù)配置信息:
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、應(yīng)用日志

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
向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI