1)broken配置
可以在主库/备库/额外一台上配置
修改监听:
vi $ORACLE_HOME/network/admin/listener.ora
主库(新增如下代码):
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME= orcl)
(ORACLE_HOME =/oracle/app/product/11.2.0/db_1)
(SID_NAME =orcl)
)
(SID_DESC =
(GLOBAL_DBNAME=orcl_DGMGRL)
(ORACLE_HOME =/oracle/app/product/11.2.0/db_1)
(SID_NAME =orcl)
)
)
备库(新增):
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME= orcl_std)
(ORACLE_HOME =/oracle/app/product/11.2.0/db_1)
(SID_NAME =orcl)
)
(SID_DESC =
(GLOBAL_DBNAME=orcl_std_DGMGRL)
(ORACLE_HOME =/oracle/app/product/11.2.0/db_1)
(SID_NAME =orcl)
)
)
重启监听
lsnrctl reload
用tnsping进行检验是否配置正确。
2)参数设置(主备都要)
SQL> show parameter dg_broker_start
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dg_broker_start boolean FALSE
SQL> alter system set dg_broker_start =true scope=both;
3)配置DG Broken
Oracle用户:
dgmgrl 执行命令
DGMGRL> connect sys/oracle
注意,这里有个bug:无论用什么密码连进去都是可以的,但最后切换时会报错
DGMGRL> help create
DGMGRL> create configuration dg as primary database is orcl connect identifier is orcl;
orcl为连接字符串
DGMGRL> help add
DGMGRL> add database orcl_std as connect identifier is orcl_std;
orcl_std为连接字符串
查看配置文件:
show configuration
启用配置文件:
enable configuration
停用配置:
disable configuration
显示数据库:
show database verbose orcl;
显示数据库状态报告:
show database orcl statusreport;
---------------------------------------------------------------------
STATUS REPORT
INSTANCE_NAME SEVERITY ERROR_TEXT
yzw WARNING ORA-16714: the value of property ArchiveLagTarget is inconsistent with the database setting
yzw WARNING ORA-16714: the value of property LogArchiveMaxProcesses is inconsistent with the database setting
yzw WARNING ORA-16714: the value of property LogArchiveMinSucceedDest is inconsistent with the database setting
-------------------------------------------------------------------------
解决方法:重新定义以上参数
DGMGRL> edit database dbsty set property ArchiveLagTarget=0;
DGMGRL> edit database orcl set property LogFileNameConvert='/oracle/app/oradata/orcl/,/oracle/app/oradata/orcl/';
DGMGRL> edit database orcl_std set property LogFileNameConvert='/oracle/app/oradata/orcl/,/oracle/app/oradata/orcl/';
注意:LogFileNameConvert、LogFileNameConvert这两个参数dgmgrl读不到,需要重新配置一下
从主库连到备库的方法:
Sqlplus sys/oracle@orcl as sysdba
Ssqlplus sys/密码@tns中的名称 as sydba
检测是否开启DG Broken:
ps -ef | grep dmon
前提:
1.很重要,搭建dg broker 之前一定一定要使备库日志应用与主库一致;
2.DG broken 需要创建备库日志组 日志大小相同 推荐备库组数=主库组数+1
日志组数会自动增加
alter database add standby logfile ('/oracle/app/oradata/yzw/stdb_redo01.log') size 200m;