Oracle 11g R2 Dataguard configuration step by step

Wesley13
• 阅读 698

Oracle 11g R2 Dataguard configuration step by step

Date: March 17, 2016 Author: Shripal Singh (DBA)

Note:- Oracle Database RDBMS software installed with one database on the PRIMARY server and on STANDBY server installed only RDBMS software without any Database. Following below details:

Primary:

IP Address: 192.168.1.10
DB_NAME=db11g
DB_UNIQUE_NAME=db11g

Standby:

IP Address: 192.168.1.20
DB_NAME=db11g
DB_UNIQUE_NAME=std

Required parameters:

DB_NAME                                             – Must be same on primary and on all standby
DB_UNIQUE_NAME                             – Must be different on primary and all standby
LOG_ARCHIVE_CONFIG             – This parameter includes db_unique_name which are the part of Dataguard configuration
LOG_ARCHIVE_DEST_n                     – Define local and remote archive log file location
LOG_ARCHIVE_DEST_STATE_n – Define state of archiving (ENABLE or DIFER)
REMOTE_LOGIN_PASSWORDFILE    – Must be in EXCLUSIVE mode
FAL_SERVER                                        – Use for archivelog gap resolution (required only in physical standby server)
DB_FILE_NAME_CONVERT                 – Required when directory structure is different datafile
LOG_FILE_NAME_CONVERT               – Required when directory structure is different logfile
STANDBY_FILE_MANAGEMENT          – Keep auto to create file automatically on standby

Perform following steps on primary database:

Note:- Make sure primary database is runing in archivelog mode

Check your database mode using following command

SQL> select log_mode from v$database; OR SQL> archive log list

If your database is not runing in archivelog mode use following command to change to archive mode.

SQL> SHU IMMEDIATE; SQL> STARTUP MOUNT; SQL> ALTER DATABASE ARCHIVELOG; SQL> ALTER DATABASE OPEN;

Now your Database is runing in archivelog mode.

Note: – Make sure database is in force logging mode.

SQL> SELECT FORCE_LOGGING FROM V$DATABASE;

If not then following below command

SQL> ALTER DATABASE FORCE LOGGING;

Now verify DB_NAME and DB_UNIQUE_NAME of primary database

SQL> show parameter db_name SQL> show parameter db_unique_name

Now Make DB_UNIQUE_NAME to be part of dataguard. (std service we will create soon)

SQL> alter system set log_archive_config=’DG_CONFIG=(db11g,std)’;

(db11g primary service name & std standby service name)

Then create service using “netmgr” command.

SQL> host $netmgr –> service add for std (+) –> net service name std –> hostname standby machine ip –> service name std –> save

Now start listener

$lsnrctl start

Set archivelog destinations

SQL> alter system set log_archive_dest_2=’service=std **Valid_for=(online_logfiles, primary_role) db_unique_name=std’;

SQL>alter system set log_archive_dest_state_2=enable;**

Set remote login password to exclusive

SQL> alter system set remote_login_passwordfile=exclusive scope=spfile; SQL> show parameter remote_login

Set fail server and file name convert parameter in case if directory structure is different in primary and standby database.

SQL> ALTER SYSTEM SET FAL_SERVER=std; SQL> ALTER SYSTEM SET DB_FILE_NAME_CONVERT=’std’,’db11g’ scope=spfile; SQL> ALTER SYSTEM SET LOG_FILES_NAME_CONVERT=’std’,’db11g’ scope=spfile; SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;

Now tack the backup primary database using RMAN

$rman target=/ RMAN> BACKUP DATABASE PLUS ARCHIVELOG;

Now create standby controlfile and pfile

SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS ‘/u01/stdcontrol.ctl’; SQL> CREATE PFILE=’/u01/initstd.ora’ from spfile;

Now edit your pfile

$vi /u01/initstd.ora

Note:- YOUR PFILE PARAMETER LOCK LIKE THIS.

std.__db_cache_size=318767104 std.__java_pool_size=4194304 std.__large_pool_size=4194304 std.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment std.__pga_aggregate_target=335544320 std.__sga_target=503316480 std.__shared_io_pool_size=0 std.__shared_pool_size=159383552 std.__streams_pool_size=4194304 *.audit_file_dest='/u01/app/oracle/admin/std/adump' *.audit_trail='db' *.compatible='11.2.0.0.0' *.control_files='/u01/app/oracle/oradata/std/control01.ctl','/u01/app/oracle/fast_recovery_area/std/control02.ctl' *.db_block_size=8192 *.db_domain='' *.db_file_name_convert='db11g','std' *.db_name='db11g' *.db_unique_name='std' *.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area' *.db_recovery_file_dest_size=4322230272 *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=db11gXDB)' *.fal_server='DB11G' *.log_archive_config='DG_CONFIG=(db11g,std)' *.log_archive_dest_2='SERVICE=db11g VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=db11g' *.log_archive_dest_state_2='ENABLE' *.log_file_name_convert='db11g','std' *.memory_target=836763648 *.open_cursors=300 *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.standby_file_management='AUTO' *.undo_tablespace='UNDOTBS1'

Save this file then create some directories on standby machine

$mkdir -p /u01/app/oracle/admin/std/adump $mkdir -p /u01/app/oracle/oradata/std $mkdir -p /u01/app/oracle/fast_recovery_area/std

After creating appropriate directory on physical standby and copy backupset, archivelog, pfile, standby controlfile and password file to physical standby database.

#scp /u01/stdcontrol.ctl oracle@192.168.1.20:/u01/app/oracle/oradata/std/control01.ctl #scp /u01/stdcontrol.ctl oracle@192.168.1.20:/u01/app/oracle/fast_recovery_area/std /control02.ctl

Transfer archivelog and backups

#scp –r /u01/app/oracle/fast_recovery_area/DB11G oracle@192.168.1.20:/u01/app/oracle/fast_recovery_area/

Copy Parameter file

#scp /u01/initstd.ora oracle@192.168.1.20:/u01/initstd.ora

Transfer remote login password file

#scp /u01/app/oracle/product/11.2.0.4/db_1/dbs/orapwdb11g oracle@192.168.1.20:/u01/app/oracle/product/11.2.0.4/db_1/dbs/orapwstd

On physical standby server

$export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1

make tns service using below command

$netmgr =>service naming + add new Net service name (db11g) Host name (server ip) Service name (db11g) Test your connection then finish Add one more service for standby server + add new Net service name (std) Host name (standby ip) Service name (std) Then finish

Then save click on file => save network configuration

start listner

$lsnrctl start

Now update /etc/oratab file on standby machine

**$vi /etc/oratab  (add below line in end of file) 

Std:/u01/app/oracle/product/11.2.0.4/db_1:N**

Restore backup on standby machine

$export ORACLE_SID=std $sqlplus / as sysdba Sql> create spfile from pfile=’/u01/initstd.ora’;

Now exit from SQL prompt and login with RMAN then restore backup

Sql> exit

$rman target=/ RMAN>startup mount RMAN> restore database; RMAN> exit

Note:- After finishing restore database we need to create standby redo log file on standby server, and it should be one extra either then online redo log file.

$sqlplus / as sysdab SQL> alter database add standby logfile (‘/u01/app/oracle/oradata/std/standby_redo01.log’) size 50m; SQL> alter database add standby logfile (‘/u01/app/oracle/oradata/std/standby_redo02.log’) size 50m; SQL> alter database add standby logfile (‘/u01/app/oracle/oradata/std/standby_redo03.log’) size 50m; SQL> alter database add standby logfile (‘/u01/app/oracle/oradata/std/standby_redo04.log’) size 50m;

Note:- we have needed to add four redo log files because we have three online redo log file.

Now check your log members and you can confirm using this command

SQL> select member from v$logfile  where type=’STANDBY’; SQL> select member from v$logfile;

Note:- Now we need to create same online redolog files on PRIMARY machine also in case you planing switch the role so if your primary become STANDBY then you need to have STANDBY redolog files.

So now going on PRIMARY server and add redolog files.

SQL> alter database add standby logfile (‘/u01/app/oracle/oradata/db11g/standby_redo01.log’) size 50m; SQL> alter database add standby logfile (‘/u01/app/oracle/oradata/db11g/standby_redo02.log’) size 50m; SQL> alter database add standby logfile (‘/u01/app/oracle/oradata/db11g/standby_redo03.log’) size 50m; SQL> alter database add standby logfile (‘/u01/app/oracle/oradata/db11g/standby_redo04.log’) size 50m;

Now CHECK….

SQL> select member from v$logfile  where type=’STANDBY’;

Now start redo apply process on standby

Note: before applying redolog files, open alert logfile on different terminal

On standby machine

SQL> alter database recover managed standby database disconnect from session;

Run below command and check current redo sequence number

On primary server

SQL> select sequence#,first_time,next_time from v$archived_log order by sequence#;

Now switch the log file using following command and check it’s applying on standby server or not.

SQL> alter system switch logfile;

Then check what your current sequence number on PRIMARY machine is

SQL> select sequence#,first_time,next_time from v$archived_log order by sequence#;

Then going on STANDBY machine and check redo are going on standby machine or not.

STANDBY:-

SQL> select sequence#,first_time,next_time,applied from v$archived_log order by sequence#;

Now going on PRIMARY machine and run switch logfile command one more time.

SQL> alter system switch logfile;

Now check DB mode and protection mode run below command on both machines

SQL> desc v$database SQL> select name,open_mode,database_role,db_unique_name,protection_mode from v$database;

Now your Dataguard configuration is completed:

Steps to configure read only STANDBY

On STANDBY machine

Now I’m going to convert physical standby database into read only standby database.

In this case what happen your database will be in read only mode. Let me show you how to convert physical standby server into read only mode.

So what you do actually

SQL>Shu immediate SQL>startup mount; SQL>alter database open read only;

After running these all commands your database will be open in read only mode.

Check…

SQL> select name,open_mode,database_role,db_unique_name,protection_mode from v$database; SQL> select * from scott.emp;   (now you able to read your database)

Now login on PRIMARY machine and run switch log file command

SQL>alter system switch logfile;

On STANDBY check redo applying or not

SQL> select sequence#,first_time,next_time,applied from v$archived_log order by sequence#;

**Note:-**You can see redo files but it’s not applied

So if you’re standby database in read only mode then redo are not applying.

If you want to bring back to physical standby following below steps

SQL> shu immediate SQL> startup mount SQL> alter database recover managed standby database disconnect from session;

After that check redo applying or not

So this is your physical standby database in read only mode,

But in oracle 11g have new feature ACTIVE DATAGUARD.

How to configure ACTIVE DATAGUARD

In ACTIVE DATAGUARD feature we can open standby database in read only mode and also can apply log files.

Steps almost same like read only standby database

SQL>shu immediate SQL>startup mount; SQL>alter database open read only; SQL>alter database recover managed standby database disconnect from session;

Now you can check open mode

 SQL> select name,open_mode,database_role,db_unique_name,protection_mode from v$database;

And check redo apply

SQL> select sequence#,first_time,next_time,applied from v$archived_log order by sequence#;

Enjoy Oracle 11g R2 Dataguard configuration step by step

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
5个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
3年前
Android蓝牙连接汽车OBD设备
//设备连接public class BluetoothConnect implements Runnable {    private static final UUID CONNECT_UUID  UUID.fromString("0000110100001000800000805F9B34FB");
Stella981 Stella981
3年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
11个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这