Oracle physical dataguard with broker部署
一、环境说明
主库:10.110.96.88
备库:10.110.96.87
数据库实例:gisc
二、主库操作
1.开启force logging
ALTER DATABASE FORCE LOGGING;
2.开启日志归档
a.查看日志归档是否开启
ARCHIVE LOG LIST;
b.如果没有开始归档则开启
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;
3.创建standby redo logs
a.查看重做日志文件组信息的两个视图v$log,v$logfile
b.修改重做日志文件大小
默认重做日志文件组有3个,因为重做日志文件组至少为2个,所以采用删除一个再创建一个的方式进行依次修改。
ALTER DATABASE DROP LOGFILE GROUP 1;
ALTER DATABASE ADD LOGFILE GROUP 1('/home/oracle/app/oradata/gisc/redo01.log') SIZE 1G;
ALTER DATABASE DROP LOGFILE GROUP 2;
ALTER DATABASE ADD LOGFILE GROUP 2('/home/oracle/app/oradata/gisc/redo02.log') SIZE 1G;
ALTER DATABASE DROP LOGFILE GROUP 3;
ALTER DATABASE ADD LOGFILE GROUP 3('/home/oracle/app/oradata/gisc/redo03.log') SIZE 1G;
因为日志文件组3在使用,所以修改时报了异常:
SQL> alter database drop logfile group 3;
alter database drop logfile group 3
*
ERROR at line 1:
ORA-01624: log 3 needed for crash recovery of instance gisc (thread 1)
ORA-00312: online log 3 thread 1: '/home/oracle/app/oradata/gisc/redo03.log'
解决方法是执行:ALTER SYSTEM CHECKPOINT,如下代码示:
ALTER SYSTEM CHECKPOINT;
2 ALTER DATABASE DROP LOGFILE GROUP 3;
3 ALTER DATABASE ADD LOGFILE GROUP 3('/home/oracle/app/oradata/gisc/redo03.log') SIZE 1G;
c.The standby redo logs should be at least as big as the largest online redo log and there should be one extra group per thread compared the online redo logs.
d.创建standby redo logs操作语句:
ALTER DATABASE ADD STANDBY LOGFILE ('/home/oracle/app/oradata/gisc/standby_redo01.log') SIZE 1g;
ALTER DATABASE ADD STANDBY LOGFILE ('/home/oracle/app/oradata/gisc/standby_redo02.log') SIZE 1g;
ALTER DATABASE ADD STANDBY LOGFILE ('/home/oracle/app/oradata/gisc/standby_redo03.log') SIZE 1g;
ALTER DATABASE ADD STANDBY LOGFILE ('/home/oracle/app/oradata/gisc/standby_redo04.log') SIZE 1g;
4.开启闪回数据库
该操作需在日志归档模式开启后操作。
ALTER DATABASE FLASHBACK ON;
5.设置初始化参数
a.参数设置命令格式
alter system set parameter_name=value [scope=both/spfile/memory]
memory:仅对内存中参数有效,数据库重启后失效;
spfile:仅对spfile参数文件有效,对当前运行的实例无效,重启数据库后生效;
both:对内存和参数文件都有效。
If a server parameter file was used to start up the database, then BOTH
is the default. If a parameter file was used to start up the database, then MEMORY
is the default, as well as the only scope you can specify.
b.设置参数内容
DB_NAME=gisc
DB_UNIQUE_NAME=gisc
LOG_ARCHIVE_CONFIG='DG_CONFIG=(gisc,gisc_stdby)'
CONTROL_FILES='/home/oracle/app/oradata/gisc/control01.ctl', '/home/oracle/app/fast_recovery_area/gisc/control02.ctl'
#日志本地归档
LOG_ARCHIVE_DEST_1=
'LOCATION=/home/oracle/app/oradata/archive_logs
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=gisc'
#日志发往备库,配置broker时LOG_ARCHIVE_DEST_2需设置为空,配置broker成功后会自动配置
#LOG_ARCHIVE_DEST_2=
#'SERVICE=GISC87 ASYNC
# VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
# DB_UNIQUE_NAME=gisc_stdby'
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT='%t_%s_%r.arc' scope=spfile #以下参数主库切换为备库时发挥作用
FAL_SERVER=gisc_stdby
#数据文件和日志文件目录转换路径,主备库可不一样,前面是备库路径,后面是主库路径。
DB_FILE_NAME_CONVERT='/home/oracle/app/oradata/gisc','/home/oracle/app/oradata/gisc' scope=spfile
LOG_FILE_NAME_CONVERT='/home/oracle/app/oradata/gisc','/home/oracle/app/oradata/gisc' scope=spfile
STANDBY_FILE_MANAGEMENT='AUTO'
6.为备库创建初始化参数文件
执行如下命令从spfile创建pfile,以便以文本方式为备库修改参数
create pfile='/home/oracle/dg/initgisc.ora' from spfile;
7.修改监听参数$ORACLE_HOME/network/admin/listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = gisc-db2)(PORT = ))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
#注意加_DGMGRL后缀,配置broker时用到
(GLOBAL_DBNAME = gisc_DGMGRL)
(ORACLE_HOME = /home/oracle/app/oracle/product/12.1./dbhome)
(SID_NAME = gisc)
)
) ADR_BASE_LISTENER = /home/oracle/app
8.修改客户端连接参数$ORACLE_HOME/network/admin/tnsnames.ora,备库需执行同样的操作
gisc88 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.110.96.88)(PORT = ))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = gisc)
)
)
gisc87 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.110.96.87)(PORT = ))
(CONNECT_DATA =
(SERVER = DEDICATED)
# (SERVICE_NAME = gisc_stdby) (SID = gisc) (UR=A)
)
)
三、备库操作
1.拷贝主库密码文件到备库相应位置
scp oracle@10.0.96.88:/home/oracle/app/oracle/product/12.1./dbhome/dbs/orapwgisc $ORACLE_HOME/dbs
2.拷贝一.6中生成的参数文件到备库,并修改为备库中的相应参数值。
a.拷贝到备库
scp oracle@10.0.96.88:/home/oracle/dg/initgisc.ora $ORACLE_HOME/dg
b. 修改备库中的相应参数,其中涉及备库中的路径,应改为相应备库中的路径,如基路径、数据文件路径、日志文件路径、恢复区路径、控制文件路径等。
这里主备库路径一致,所以相应路径就不用改了。
1 gisc.__oracle_base='/home/oracle/app'
2
3 *.audit_file_dest='/home/oracle/app/admin/gisc/adump'
4
5 *.control_files='/home/oracle/app/oradata/gisc/control01.ctl','/home/oracle/app/fast_recovery_area/gisc/control02.ctl'
6
7 *.db_file_name_convert='/home/oracle/app/oradata/gisc','/home/oracle/app/oradata/gisc'
8
9 *.log_file_name_convert='/home/oracle/app/oradata/gisc','/home/oracle/app/oradata/gisc'
10
11 *.db_recovery_file_dest='/home/oracle/app/fast_recovery_area'
12
13 *.diagnostic_dest='/home/oracle/app'
14
15 DB_UNIQUE_NAME=gisc_stdby
16 LOG_ARCHIVE_DEST_1=
17 'LOCATION=/home/oracle/app/oradata/archive_logs
18 VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
19 DB_UNIQUE_NAME=gisc_stdby'
#日志发往主库,配置broker时LOG_ARCHIVE_DEST_2需设置为空,转换为主库时会自动配置
20 #LOG_ARCHIVE_DEST_2=
21 #'SERVICE=gisc88 ASYNC
22 # VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
23 # DB_UNIQUE_NAME=gisc'
24
25 FAL_SERVER=gisc
3.创建相应目录
mkdir -p /home/oracle/app/oradata/gisc/pdbseed
mkdir -p /home/oracle/app/oradata/gisc/pdb1
mkdir -p /home/oracle/app/fast_recovery_area/gisc
mkdir -p /home/oracle/app/admin/gisc/adump
4.确保设置了环境变量:
export ORACLE_SID=gisc
5.确保配置了监听,如果没有可用netca图形界面进行配置。
6.修改监听参数$ORACLE_HOME/network/admin/listener.ora
1 LISTENER =
2 (DESCRIPTION_LIST =
3 (DESCRIPTION =
4 (ADDRESS = (PROTOCOL = TCP)(HOST = gisc-db2)(PORT = 1521))
5 (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
6 )
7 )
8 SID_LIST_LISTENER =
9 (SID_LIST =
10 (SID_DESC =
#注意加_DGMGRL后缀,配置broker时用到
11 (GLOBAL_DBNAME = gisc_stdby_DGMGRL)
12 (ORACLE_HOME = /home/oracle/app/oracle/product/12.1.0/dbhome)
13 (SID_NAME = gisc)
14 )
15 )
16
17 ADR_BASE_LISTENER = /home/oracle/app
7.修改客户端连接参数$ORACLE_HOME/network/admin/tnsnames.ora
1 gisc88 =
2 (DESCRIPTION =
3 (ADDRESS = (PROTOCOL = TCP)(HOST = 10.110.96.88)(PORT = 1521))
4 (CONNECT_DATA =
5 (SERVER = DEDICATED)
6 (SERVICE_NAME = gisc)
7 )
8 )
9 gisc87 =
10 (DESCRIPTION =
11 (ADDRESS = (PROTOCOL = TCP)(HOST = 10.110.96.87)(PORT = 1521))
12 (CONNECT_DATA =
13 (SERVER = DEDICATED)
14 # (SERVICE_NAME = gisc_stdby)
16 (SID = gisc)
18 (UR=A)
19 )
20 )
8.为备库创建服务器参数文件spfile
create spfile from pfile='/home/oracle/dg/initgisc.ora' ;
9.启动备库到nomount状态
startup nomount;
10.rman连接主备库,并执行同步
a0:确保主备库防火墙开通了oralce 1521端口,否则执行主备同步时会出现以下错误:
RMAN-: ===========================================================
RMAN-: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-: ===========================================================
RMAN-: failure of Duplicate Db command at // ::
RMAN-: aborting duplication of target database
RMAN-: error occurred in stored script Memory Script
RMAN-: failure of backup command on ORA_DISK_1 channel at // ::
ORA-: Cannot connect to the remote database server
ORA-: ORA-: TNS:destination host unreachable
ORA-: Cannot connect to the remote database server
a1:主备都要重启监听和数据库?
a.连接主备库
rman target sys/*****@GISC88 auxiliary sys/****@GISC87
b.执行主备同步
DUPLICATE TARGET DATABASE
FOR STANDBY
FROM ACTIVE DATABASE
DORECOVER
NOFILENAMECHECK;
11. 启动归档日志应用进程
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
四.配置broker
1.确认主备库log_archive_dest_2设置为空,如果不为空设置为空
show parameter log_archive_dest_2;
alter system set log_archive_dest_2='';
2.在主备库开启dg_broker_start
ALTER SYSTEM SET dg_broker_start=true;
3.连接主库配置broker
a.dgmgrl连接主库
dgmgrl sys/****@GISC88
b.创建配置,指定主库
CREATE CONFIGURATION dg_config AS PRIMARY DATABASE IS gisc CONNECT IDENTIFIER IS gisc88;
c.添加备库
ADD DATABASE gisc_stdby AS CONNECT IDENTIFIER IS gisc87 MAINTAINED AS PHYSICAL;
d.使配置生效
ENABLE CONFIGURATION;
e.查看主备库状态
DGMGRL> SHOW CONFIGURATION; Configuration - dg_config Protection Mode: MaxPerformance
Members:
gisc - Primary database
gisc_stdby - Physical standby database Fast-Start Failover: DISABLED Configuration Status:
SUCCESS (status updated 32 seconds ago) DGMGRL> SHOW DATABASE GISC; Database - gisc Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
gisc Database Status:
SUCCESS DGMGRL> SHOW DATABASE gisc_stdby; Database - gisc_stdby Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 1 second ago)
Apply Lag: 0 seconds (computed 1 second ago)
Average Apply Rate: 39.00 KByte/s
Real Time Query: ON
Instance(s):
gisc Database Status:
SUCCESS
五.主库中确认主备库重做日志传输和应用情况
SQL> SELECT CLIENT_PROCESS, PROCESS, THREAD#, SEQUENCE#, STATUS FROM
2 V$MANAGED_STANDBY WHERE CLIENT_PROCESS='LGWR' OR PROCESS='MRP0'; CLIENT_P PROCESS THREAD# SEQUENCE# STATUS
-------- --------- ---------- ---------- ------------
N/A MRP0 1 326 APPLYING_LOG
LGWR RFS 1 326 IDLE
六.DGMGRL中正常运行时的主备切换SWITCHOVER
a.主库切到87
DGMGRL>SWITCHOVER TO gisc_stdby;
b.主库切回到88
DGMGRL>SWITCHOVER TO gisc;
七.DGMGRL中主库故障时的主备切换FAILOVER
假设主库故障,需切换备库为主库。DGMGRL连接到备库进行如下操作:
a.切换备库为主库
DGMGRL>FAILOVER TO gisc_stdby;
b.原主库故障恢复后,重做其状态,使其为备库,该操作需在闪回数据库开启的状态下进行。
DGMGRL>REINSTATE DATABASE gisc;
c.如果闪回数据库没有开启,原主数据库故障恢复后,要恢复其为备库,需按以下步骤重做
c1. Cleanup the old instance,可把以下代码写成bash脚本。
rm -Rf $ORACLE_BASE/oradata/$ORACLE_SID/*
rm -Rf $ORACLE_BASE/fast_recovery_area/$ORACLE_SID
rm -Rf $ORACLE_BASE/fast_recovery_area/$ORACLE_SID_stdby
rm -Rf $ORACLE_BASE/admin/$ORACLE_SID
rm $ORACLE_HOME/dbs/spfile*.ora
rm $ORACLE_HOME/dbs/init*.ora mkdir -p $ORACLE_BASE/fast_recovery_area/$ORACLE_SID
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump
mkdir -p $ORACLE_BASE/oradata/$ORACLE_SID/pdbseed
mkdir -p $ORACLE_BASE/oradata/$ORACLE_SID/pdb1
c2. Connect to RMAN.
$ rman TARGET sys/***@gisc_stby AUXILIARY sys/***@gisc
c3.Duplicate the database.
DUPLICATE TARGET DATABASE
FOR STANDBY
FROM ACTIVE DATABASE
DORECOVER
NOFILENAMECHECK;
c4. Connect to DGMDRL on the current primary.
$ dgmgrl sys/***@gisc_stby
c5. Enable the new standby.
DGMGRL> ENABLE DATABASE gisc;
其他:
1.oralce服务器查看错误号命令:oerr ora 错误号,如下所示:
[oracle@gisc-db1 data_guard]$ oerr ora
, , "log %s needed for crash recovery of instance %s (thread %s)"
// *Cause: A log cannot be dropped or cleared until the thread's checkpoint
// has advanced out of the log.
// *Action: If the database is not open, then open it. Crash recovery will
// advance the checkpoint. If the database is open force a global
// checkpoint. If the log is corrupted so that the database cannot
// be opened, it may be necessary to do incomplete recovery until
// cancel at this log.
主要参考:
1.Data Guard Physical Standby Setup Using the Data Guard Broker in Oracle Database 12c Release 1
3.Data Guard Command-Line Interface Reference
4.ORA-01624: log 3 needed for crash recovery of instance orcl (thread 1)问题解决
5.ORA-01078: failure in processing system parameters 问题的解决方法(oracle 11g)
6.ORA-16714: the value of property ArchiveLagTarget is inconsistent with the database setting的解决方法
7.RMAN active cloning in oracle 12C
8.Oracle Silent Mode, Part 3: Cloning Software and Databases
9.oracle数据库DB_NAME、DBID、DB_UNIQUE_NAME等的区别
Oracle physical dataguard with broker部署的更多相关文章
- Oracle Grid control 11g及Active DataGuard 11g安装部署
Oracle Grid control 11g及Active DataGuard 11g安装部署(一) 原贴 http://blog.csdn.net/lichangzai/article/detai ...
- Oracle 10gR2 Dataguard搭建(非duplicate方式)
Oracle 10gR2 Dataguard搭建(非duplicate方式) 我的实验环境: 源生产库(主库): IP地址:192.168.1.30 Oracle 10.2.0.5 单实例 新DG库( ...
- Oracle 11g Dataguard参数详解
https://www.jb51.net/article/52269.htm注:本文译自<Oracle Data Guard 11g Handbook> Page 78 – Page 88 ...
- Oracle RAC 11g DG Broker配置和测试
Oracle RAC 11g DG Broker配置和测试 之前在<RHEL6.4 + Oracle 11g DG测试环境快速搭建参考>已经简单说过. 本篇在实验环境中实际配置 环境: R ...
- Oracle 11g dataguard check RTA(real time apply)
Oracle 11g dataguard check RTA(real time apply) 2017年8月24日 16:38 环境:oracle 11.2.0.1 OEL 5.8 注:以下操作都在 ...
- oracle 19c dataguard aws ORA-03186报错
环境说明 在亚马逊云AWS上面安装了一套oracle 19c dataguard,linux centos 7.7的操作系统,开始时同步正常,实时应用redolog,一会儿之后就不行了.报错如下: o ...
- Oracle 10g dataguard broker 配置
环境: OS:rhel6.3_64bit DB:Oracle10gR2 ————————————————————————dataguard broker配置—————————————————————— ...
- Oracle 11g DataGuard搭建(一) - 单节点到单节点
(一)DataGuard概要 DataGuard中文称为”数据卫士“,提供了数据库高可用性.数据保护和灾难恢复的功能.DataGuard通过建立primary数据库和standby数据库来确立参照关系 ...
- Oracle 11g Dataguard 配置,维护与详解 (ADG)
一.前言: 本手册主要记录如何配置,还介绍了配置原因,以及注意要点,已经主备切换,以及故障转移等重要操作步骤,我希望这个文章可以作为进行dataguard配置的一个参考手册. 二.前提 1.主库是归档 ...
随机推荐
- 云盘+Git GUI实现云盘文件版本号控制
以下介绍操作细节 1.先下载Git GUI 下载地址:http://msysgit.github.io/ 再下载百度云网盘 下载地址:http://pan.baidu.com 接下来就是安 ...
- UVA 12333 大数,字典树
题意:给一个数字,看他最小是第几个菲波那切数列的前缀. 分析: 大数模板就是吊哦. 将菲波那切数列前500个数字放到字典树上.注意插入的时候不能像普通一样,只在尾节点处标记,而是一路标记下去. #in ...
- this作用域详解
大家在使用Javascript的时候经常被this这个家伙搞得晕头转向的.在Javascript中它却显得古灵精怪的,因为它不是固定不变的,而是随着它的执行环境的改变而改变.在Javascript中t ...
- (第四场)F Beautiful Garden
题目: F Beautiful Garden 题目描述 There's a beautiful garden whose size is n x m in Chiaki's house. The ga ...
- 2018.11.14 hibernate中的查询优化---关联级别查询
查询优化------关联级别查询 集合策略 在Mapper映射文件中添加属性 测试数据 lazy:true 延时加载数据 fetch:select 单表查询 控制台显示输出 结论:单表查询,使用到在加 ...
- Hibernate多表查询连接操作
SQL多表操作分类; 1.交叉连接:select*from t_customer cross Join t_order; 2.显示内连接: select*from t_customer c inner ...
- AngularJS web应用程序
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...
- 纯JS拖动案例
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- html基础用法(上)
html的定义: html超文本标记语言,标准通用标记语言下的一个应用. “超文本”就是指页面内可以包含图片,链接,甚至音乐,程序等非文字语言. 超文本标记语言的结构包括“头”部分(head),和“主 ...
- spring(二)-反射、动态代理
主要是对上一篇文章中涉及到的点做补充,欢迎指正! 1. java反射知识-Spring IOC 依赖注入 Java反射机制主要提供了以下功能: 在运行时判断任意一个对象所属的类:在运行时构造任意一个 ...