以下内容为主库是rac,备库也是rac类型,通过dbca的方式来搭建物理DG:
SELECT CDB FROM V$DATABASE;
alter database archivelog;
alter database force logging;
alter database flashback on;
alter database open;
alter pluggable database all open;
alter pluggable database all save state;
select thread#,group#,bytes/1024/1024 SIZE_MB, status,members from v$log;
select thread#,group#,member from v$logfile;
set line 9999 pagesize 9999
col db_id format a15
col GROUP# format 99999
select (select instance_name from gv$instance na where na.inst_id=a.INST_ID) instance_name, GROUP#, DBID db_id, THREAD#, SEQUENCE#, BYTES, USED, ARCHIVED, STATUS, FIRST_CHANGE#, NEXT_CHANGE#,LAST_CHANGE# from gv$standby_log a order by INST_ID,THREAD#,GROUP#;
alter database add standby logfile thread 1 group 5 ('+DATA','+FRA') size 200M ,group 6 ('+DATA','+FRA') size 200M ,group 7 ('+DATA','+FRA') size 200M ;
alter database add standby logfile thread 2 group 8 ('+DATA','+FRA') size 200M ,group 9 ('+DATA','+FRA') size 200M ,group 10 ('+DATA','+FRA') size 200M ;
--------配置tns
tns_rac19c =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.54)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.55)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rac19c)
)
)
tns_rac19cdg =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.54)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.55)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rac19cdg)
)
)
--------配置监听
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = rac19c)
(ORACLE_HOME = /u01/app/oracle/product/19.3.0/dbhome_1)
(SID_NAME = rac19c1)
)
(SID_DESC =
(GLOBAL_DBNAME = rac19cdg)
(ORACLE_HOME = /u01/app/oracle/product/19.3.0/dbhome_1)
(SID_NAME = rac19cdg1)
)
(SID_DESC =
(GLOBAL_DBNAME = rac19c_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/19.3.0/dbhome_1)
(SID_NAME = rac19c1)
)
(SID_DESC =
(GLOBAL_DBNAME = rac19cdg_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/19.3.0/dbhome_1)
(SID_NAME = rac19cdg1)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = rac19c)
(ORACLE_HOME = /u01/app/oracle/product/19.3.0/dbhome_1)
(SID_NAME = rac19c2)
)
(SID_DESC =
(GLOBAL_DBNAME = rac19cdg)
(ORACLE_HOME = /u01/app/oracle/product/19.3.0/dbhome_1)
(SID_NAME = rac19cdg2)
)
(SID_DESC =
(GLOBAL_DBNAME = rac19c_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/19.3.0/dbhome_1)
(SID_NAME = rac19c2)
)
(SID_DESC =
(GLOBAL_DBNAME = rac19cdg_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/19.3.0/dbhome_1)
(SID_NAME = rac19cdg2)
)
)
srvctl stop listener -l LISTENER
srvctl start listener -l LISTENER
dbca -silent -createDuplicateDB \
-gdbName rac19c \
-sid rac19cdg \
-sysPassword lhr \
-primaryDBConnectionString 192.168.59.54:1521/rac19c \
-nodelist raclhr-19c-n1,raclhr-19c-n2 \
-adminManaged \
-databaseConfigType RAC \
-createAsStandby -dbUniqueName rac19cdg \
-datafileDestination '+DATA' \
-initParams db_create_file_dest=+DATA, db_create_online_log_dest_1=+DATA
---全参数 rac环境
set line 1000
set pagesize 1000
col name format a25
col VALUE format a100
SELECT a.NAME,
i.instance_name,
a.VALUE
FROM gv$parameter a, gv$instance i
WHERE a.inst_id = i.inst_id and a.name in ('dg_broker_start','db_name','db_unique_name','log_archive_config','log_archive_dest_1','log_archive_dest_2','log_archive_dest_state_1','log_archive_dest_state_2','log_archive_max_processes','remote_login_passwordfile','db_file_name_convert','log_file_name_convert','standby_file_management','fal_server','fal_client','dg_broker_config_file1','dg_broker_config_file2')
ORDER BY a.name, i.instance_name;
--主库修改参数
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=rac19c' sid='*';
alter system set LOG_ARCHIVE_DEST_2='service=tns_rac19cdg VALID_FOR=(online_logfiles,primary_role) DB_UNIQUE_NAME=rac19cdg' sid='*';
alter system set log_archive_config='dg_config=(rac19c,rac19cdg)' sid='*';
alter system set db_file_name_convert='+DATA','+DATA' scope=spfile sid='*';
alter system set log_file_name_convert='+DATA','+DATA' scope=spfile sid='*';
alter system set standby_file_management=auto scope=spfile sid='*';
alter system set fal_client='tns_rac19c' sid='*';
alter system set fal_server='tns_rac19cdg' sid='*';
---创建路径
ASMCMD> mkdir +DATA/dgshare/
--主库
show parameter dg
alter system set dg_broker_config_file1='+DATA/dgshare/dr1rac19c.dat' SID='*';
alter system set dg_broker_config_file2='+DATA/dgshare/dr2rac19c.dat' SID='*';
alter system set dg_broker_start=true sid='*';
--备库
show parameter dg
alter system set dg_broker_config_file1='+DATA/dgshare/dr1rac19cDG.dat' SID='*';
alter system set dg_broker_config_file2='+DATA/dgshare/dr2rac19cDG.dat' SID='*';
alter system set dg_broker_start=true sid='*';
--备库修改参数
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=rac19cdg' scope=spfile sid='*';
alter system set log_archive_config='dg_config=(rac19c,rac19cdg)';
alter system set db_file_name_convert='+DATA','+DATA' scope=spfile sid='*';
alter system set log_file_name_convert='+DATA','+DATA' scope=spfile sid='*';
alter system set standby_file_management=auto scope=spfile sid='*';
alter system set fal_client='tns_rac19cdg' sid='*';
alter system set fal_server='tns_rac19c' sid='*';
srvctl stop db -d rac19c
srvctl start db -d rac19c
srvctl stop db -d rac19cdg
srvctl start db -d rac19cdg
--备库查询实时应用
alter database recover managed standby database cancel;
alter database recover managed standby database using current logfile disconnect;
! ps -ef|grep ora_mrp
select INST_ID, dbid,name,DB_UNIQUE_NAME,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from gv$database;
COL NAME FOR A100
SET LINESIZE 9999 PAGESIZE 9999
COL NEXT_CHANGE# FOR 999999999999999
SELECT THREAD#, NAME, SEQUENCE#, ARCHIVED, APPLIED, A.NEXT_CHANGE#
FROM V$ARCHIVED_LOG A
WHERE A.SEQUENCE# >= (SELECT MAX(B.SEQUENCE#) - 3
FROM V$ARCHIVED_LOG B
WHERE B.THREAD# = A.THREAD#
AND B.RESETLOGS_CHANGE# = A.RESETLOGS_CHANGE#
AND B.RESETLOGS_CHANGE# =
(SELECT D.RESETLOGS_CHANGE# FROM V$DATABASE D)
AND B.APPLIED = 'YES'
GROUP BY B.THREAD#)
ORDER BY A.THREAD#, A.SEQUENCE#;
cp /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/tnsnames.ora /u01/app/19.3.0/grid/network/admin/tnsnames.ora
chown grid.oinstall /u01/app/19.3.0/grid/network/admin/tnsnames.ora
dgmgrl sys/lhr@rac19c
show configuration
create configuration rac19c as
primary database is rac19c
connect identifier is tns_rac19c;
add database rac19cdg as
connect identifier is tns_rac19cdg
maintained as physical;
enable configuration
show database verbose rac19c;
show database verbose rac19cdg;
alter database recover managed standby database cancel;
alter database flashback on;
select flashback_on,force_logging from v$database;
alter database recover managed standby database using current logfile disconnect;
edit database rac19c set property 'FastStartFailoverTarget'='rac19cdg';
edit database rac19cdg set property 'FastStartFailoverTarget'='rac19c';
最终结果:
[root@raclhr-19c-n1 admin]# crsctl stat res -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr
ONLINE ONLINE raclhr-19c-n1 STABLE
ONLINE ONLINE raclhr-19c-n2 STABLE
ora.chad
ONLINE ONLINE raclhr-19c-n1 STABLE
ONLINE ONLINE raclhr-19c-n2 STABLE
ora.net1.network
ONLINE ONLINE raclhr-19c-n1 STABLE
ONLINE ONLINE raclhr-19c-n2 STABLE
ora.ons
ONLINE ONLINE raclhr-19c-n1 STABLE
ONLINE ONLINE raclhr-19c-n2 STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr(ora.asmgroup)
1 ONLINE ONLINE raclhr-19c-n1 STABLE
2 ONLINE ONLINE raclhr-19c-n2 STABLE
3 ONLINE OFFLINE STABLE
ora.DATA.dg(ora.asmgroup)
1 ONLINE ONLINE raclhr-19c-n1 STABLE
2 ONLINE ONLINE raclhr-19c-n2 STABLE
3 OFFLINE OFFLINE STABLE
ora.FRA.dg(ora.asmgroup)
1 ONLINE ONLINE raclhr-19c-n1 STABLE
2 ONLINE ONLINE raclhr-19c-n2 STABLE
3 OFFLINE OFFLINE STABLE
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE raclhr-19c-n1 STABLE
ora.LISTENER_SCAN2.lsnr
1 ONLINE ONLINE raclhr-19c-n2 STABLE
ora.LISTENER_SCAN3.lsnr
1 ONLINE ONLINE raclhr-19c-n2 STABLE
ora.MGMT.dg(ora.asmgroup)
1 ONLINE ONLINE raclhr-19c-n1 STABLE
2 ONLINE ONLINE raclhr-19c-n2 STABLE
3 OFFLINE OFFLINE STABLE
ora.OCR.dg(ora.asmgroup)
1 ONLINE ONLINE raclhr-19c-n1 STABLE
2 ONLINE ONLINE raclhr-19c-n2 STABLE
3 OFFLINE OFFLINE STABLE
ora.asm(ora.asmgroup)
1 ONLINE ONLINE raclhr-19c-n1 Started,STABLE
2 ONLINE ONLINE raclhr-19c-n2 Started,STABLE
3 OFFLINE OFFLINE STABLE
ora.asmnet1.asmnetwork(ora.asmgroup)
1 ONLINE ONLINE raclhr-19c-n1 STABLE
2 ONLINE ONLINE raclhr-19c-n2 STABLE
3 OFFLINE OFFLINE STABLE
ora.cvu
1 ONLINE ONLINE raclhr-19c-n2 STABLE
ora.qosmserver
1 ONLINE ONLINE raclhr-19c-n2 STABLE
ora.rac19c.db
1 ONLINE ONLINE raclhr-19c-n1 Open,HOME=/u01/app/o
racle/product/19.3.0
/dbhome_1,STABLE
2 ONLINE ONLINE raclhr-19c-n2 Open,HOME=/u01/app/o
racle/product/19.3.0
/dbhome_1,STABLE
ora.rac19cdg.db
1 ONLINE ONLINE raclhr-19c-n1 Open,Readonly,HOME=/
u01/app/oracle/produ
ct/19.3.0/dbhome_1,S
TABLE
2 ONLINE ONLINE raclhr-19c-n2 Open,Readonly,HOME=/
u01/app/oracle/produ
ct/19.3.0/dbhome_1,S
TABLE
ora.raclhr-19c-n1.vip
1 ONLINE ONLINE raclhr-19c-n1 STABLE
ora.raclhr-19c-n2.vip
1 ONLINE ONLINE raclhr-19c-n2 STABLE
ora.scan1.vip
1 ONLINE ONLINE raclhr-19c-n1 STABLE
ora.scan2.vip
1 ONLINE ONLINE raclhr-19c-n2 STABLE
ora.scan3.vip
1 ONLINE ONLINE raclhr-19c-n2 STABLE
--------------------------------------------------------------------------------
About Me
........................................................................................................................ ● 本文作者:小麦苗,部分内容整理自网络,若有侵权请联系小麦苗删除 ● 本文在itpub、博客园、CSDN和个人微 信公众号( xiaomaimiaolhr)上有同步更新 ● 本文itpub地址: http://blog.itpub.net/26736162 ● 本文博客园地址: http://www.cnblogs.com/lhrbest ● 本文CSDN地址: https://blog.csdn.net/lihuarongaini ● 本文pdf版、个人简介及小麦苗云盘地址: http://blog.itpub.net/26736162/viewspace-1624453/ ● 数据库笔试面试题库及解答: http://blog.itpub.net/26736162/viewspace-2134706/ ● DBA宝典今日头条号地址: http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826 ........................................................................................................................ ● QQ群号: 230161599 、618766405 ● 微 信群:可加我微 信,我拉大家进群,非诚勿扰 ● 联系我请加QQ好友 ( 646634621 ),注明添加缘由 ● 于 2019-08-01 06:00 ~ 2019-08-31 24:00 在西安完成 ● 最新修改时间:2019-08-01 06:00 ~ 2019-08-31 24:00 ● 文章内容来源于小麦苗的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解 ● 版权所有,欢迎分享本文,转载请保留出处 ........................................................................................................................ ● 小麦苗的微店: https://weidian.com/s/793741433?wfr=c&ifr=shopdetail ● 小麦苗出版的数据库类丛书: http://blog.itpub.net/26736162/viewspace-2142121/ ● 小麦苗OCP、OCM、高可用网络班: http://blog.itpub.net/26736162/viewspace-2148098/ ● 小麦苗腾讯课堂主页: https://lhr.ke.qq.com/ ........................................................................................................................ 使用 微 信客户端扫描下面的二维码来关注小麦苗的微 信公众号( xiaomaimiaolhr)及QQ群(DBA宝典)、添加小麦苗微 信, 学习最实用的数据库技术。
........................................................................................................................ |