Oracle HA 之 基于活动数据库复制配置oracle 11.2 dataguard
规划:
主库:db_name=dbking db_unique_name=dbkingpri
备库:db_name=dbking db_unique_name=dbkingstd
1、修改dbking库为归档模式
2、修改dbking库为force logging模式
修改后结果如下:
SQL> select name,open_mode,log_mode,force_logging from v$database;
NAME OPEN_MODE LOG_MODE FORCE_LOG
--------------------------- ------------------------------------------------------------ ------------------------------------ ---------
DBKING READ WRITE ARCHIVELOG YES
3、配置tnsnames.ora文件
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
DBKINGPRI =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.40)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dbking)
)
)
DBKINGSTD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.41)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dbking)
)
)
4、设置备库静态监听模式
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.41)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = dbking)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = dbking)
)
)
ADR_BASE_LISTENER = /u01/app/oracle
5、创建主库slf文件:
SQL> alter database add standby logfile '/u01/app/oracle/oradata/dbking/srdo01.log' size 52428800;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/dbking/srdo02.log' size 52428800;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/dbking/srdo03.log' size 52428800;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/dbking/srdo04.log' size 52428800;
Database altered.
SQL> select member from v$logfile;
MEMBER
------------------------------------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/oradata/dbking/redo03.log
/u01/app/oracle/oradata/dbking/redo02.log
/u01/app/oracle/oradata/dbking/redo01.log
/u01/app/oracle/oradata/dbking/srdo01.log
/u01/app/oracle/oradata/dbking/srdo02.log
/u01/app/oracle/oradata/dbking/srdo03.log
/u01/app/oracle/oradata/dbking/srdo04.log
7 rows selected.
SQL>
6、主库配置参数
SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
db_name string dbking
SQL> alter system set db_unique_name=dbkingpri scope=spfile;
System altered.
SQL> alter system set log_archive_config='dg_config=(dbkingpri,dbkingstd)';
System altered.
SQL> alter system set standby_file_management=auto;
System altered.
SQL> alter system set fal_client=dbkingstd;
System altered.
SQL> alter system set fal_server=dbkingpri;
System altered.
SQL> alter system set log_archive_dest_2='service=dbkingstd lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=dbkingstd';
System altered.
7、准备备库密码文件
[oracle@kaifai dbs]$ scp 192.168.100.40:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwdbking .
8、准备备库参数文件
[oracle@kaifai dbs]$ cat initdbing.ora
db_name=dbking
db_unique_name=dbkingstd
9、启动备库到nomount状态
[oracle@kaifai dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Fri Jul 8 14:10:49 2016
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 263090176 bytes
Fixed Size 2252256 bytes
Variable Size 205521440 bytes
Database Buffers 50331648 bytes
Redo Buffers 4984832 bytes
SQL>
10、rman连接主备库
[oracle@kaifai admin]$ rman target sys/oracle@dbkingpri auxiliary sys/oracle@dbkingstd
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Jul 8 14:16:02 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: DBKING (DBID=3207597140)
connected to auxiliary database: DBKING (not mounted)
RMAN>
11、创建相应目录
$mkdir -p /data/oradata/dbking
[oracle@kaifai admin]$ pwd
/u01/app/oracle/admin
[oracle@kaifai admin]$ mkdir dbking
[oracle@kaifai admin]$ cd dbking/
[oracle@kaifai dbking]$ mkdir adump
[oracle@kaifai dbking]$ mkdir cdump
[oracle@kaifai dbking]$ mkdir dpdump
12、以下脚本复制数据库
run{
duplicate target database
for standby
from active database
spfile
set db_unique_name='dbkingstd'
set log_file_name_convert '/u01/app/oracle/oradata/dbking/','/data/oradata/dbking/'
set db_file_name_convert '/u01/app/oracle/oradata/dbking/','/data/oradata/dbking/'
set control_files='/data/oradata/dbking/control.ctl'
set log_archive_dest_2='service=dbkingpri lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=dbkingpri'
set fal_client='dbkingstd'
set fal_server='dbkingpri'
;
}
13、启动应用
alter database recover managed standby database disconnect from session;
14、测试
create tablespace efmis datafile '/u01/app/oracle/oradata/dbking/efmis01.dbf' size 200m;
15、active dataguard
1)查看当前备库运行状态
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
------------------------------------------------ ------------------------------------
dbking MOUNTED
2)进入到只读状态
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database open;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
------------------------------------------------------------
READ ONLY
3)启动应用日志
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
------------------------------------------------------------
READ ONLY WITH APPLY
备库以只读方式应用日志。
4)测试:
略
16、修改主库为最大保护模式:
1)查看当前主库运行模式
SQL> select db_unique_name,protection_mode,protection_level from v$database;
DB_UNIQUE_NAME PROTECTION_MODE PROTECTION_LEVEL
------------------------------ ------------------------------------------------------------ -------------------------------------
DBKINGPRI MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE
2)设置主库为最大保护模式
SQL> alter database set standby database to maximize protection;
alter database set standby database to maximize protection
*
ERROR at line 1:
ORA-01126: database must be mounted in this instance and not open in any instance
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2257352 bytes
Variable Size 499125816 bytes
Database Buffers 276824064 bytes
Redo Buffers 6791168 bytes
Database mounted.
SQL> alter database set standby database to maximize protection;
Database altered.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 10000
Session ID: 191 Serial number: 3
3)修改log_archive_dest_2参数
SQL>alter system set log_archive_dest_2='service=dbkingstd lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=dbkingstd';
SQL> conn / as sysdba
Connected.
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database recover managed standby database using current logfile disconnect;
Database altered.
现在已经是最大保护模式。
[oracle@kaifai ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Jul 12 11:15:30 2016
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown immediate
ORA-01154: database busy. Open, close, mount, and dismount not allowed now
SQL>
说明:最大保护模式下,备库不能先于主库关闭。如果只有一个最大保护模式的备库,则不能直接转换成快照数据库。
17、快照standby:首先关闭mrp进程,并且不能在只读及事实恢复的情况下进行转换。
1)更改主库为最大性能模式
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2257352 bytes
Variable Size 499125816 bytes
Database Buffers 276824064 bytes
Redo Buffers 6791168 bytes
Database mounted.
SQL> alter database set standby database to maximize performance;
Database altered.
SQL> alter database open;
Database altered.
2)备库在只读恢复模式,不能进行转换
SQL> select open_mode from v$database;
OPEN_MODE
------------------------------------------------------------
READ ONLY WITH APPLY
SQL> alter database convert to snapshot standby;
alter database convert to snapshot standby
*
ERROR at line 1:
ORA-38784: Cannot create restore point 'SNAPSHOT_STANDBY_REQUIRED_07/12/2016
16:24:52'.
ORA-01153: an incompatible media recovery is active
3)关闭数据库,启动到mount状态,进行转换,然后再次关闭数据库,启动数据库至open状态:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2257352 bytes
Variable Size 515903032 bytes
Database Buffers 260046848 bytes
Redo Buffers 6791168 bytes
Database mounted.
SQL> select open_mode from v$database;
OPEN_MODE
------------------------------------------------------------
MOUNTED
SQL> alter database convert to snapshot standby;
Database altered.
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2257352 bytes
Variable Size 515903032 bytes
Database Buffers 260046848 bytes
Redo Buffers 6791168 bytes
Database mounted.
Database opened.
SQL> select open_mode from v$database;
OPEN_MODE
------------------------------------------------------------
READ WRITE
SQL>
4)备库开始可以对外提供读写模式了,主库创建用户及生成测试表:
SQL> create user t2 identified by oracle account unlock;
User created.
SQL> grant dba to t2;
Grant succeeded.
SQL> create table t2.emp as select * from scott.emp;
Table created.
5)备库查询步骤4创建的测试用户及表,查不到结果
SQL> conn t2/oracle
ERROR:
ORA-01017: invalid username/password; logon denied
Warning: You are no longer connected to ORACLE.
SQL> conn / as sysdba
Connected.
SQL> select * from t2.emp;
select * from t2.emp
*
ERROR at line 1:
ORA-00942: table or view does not exist
6)测试备库读写功能
SQL> create user t3 identified by oracle account unlock;
User created.
SQL> grant dba to t3;
Grant succeeded.
SQL> create table t3.emp as select * from scott.emp;
Table created.
18、snapshot standby数据库转换回物理数据库
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2257352 bytes
Variable Size 515903032 bytes
Database Buffers 260046848 bytes
Redo Buffers 6791168 bytes
Database mounted.
SQL> alter database convert to physical standby;
Database altered.
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 784998400 bytes
Fixed Size 2257352 bytes
Variable Size 515903032 bytes
Database Buffers 260046848 bytes
Redo Buffers 6791168 bytes
Database mounted.
Database opened.
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL> conn t2/oracle
Connected.
SQL> select * from emp;
.......
14 rows selected.
SQL> conn t3/oracle
ERROR:
ORA-01017: invalid username/password; logon denied
Warning: You are no longer connected to ORACLE.
SQL>
Oracle HA 之 基于活动数据库复制配置oracle 11.2 dataguard的更多相关文章
- Oracle SQL developer 连接 MySQL 数据库安装配置
1. 下载 JDBC driver for MySQL 下载链接: https://dev.mysql.com/downloads/connector/j/ 下载成功后,解压缩,得到 mysql jd ...
- Oracle数据迁移之rman活动数据库复制
1.设置主库为归档模式 SQL> shutdown immediate SQL> startup mount SQL> alter database archivelog; SQL& ...
- 基于RMAN从活动数据库异机克隆(rman duplicate from active DB)
Oracle 11g RMAN能够实现基于活动数据库进行异机克隆,从而省去需要先备份再ftp到辅助服务器的过程.这一切可以全部交给Oracle来搞定.在克隆期间,Oracle会读取Target DB的 ...
- Oracle LISTENER 主机名修改为IP地址后LISTENER无法监听到实例 oracle监听错误与hosts文件配置
为什么listener.ora文件里面HOST后面到底应该输入IP地址还是主机名.我的经验告诉我,这边最好使用主机名.很多的时候,一个机器绑定的不只一个IP地址,如HOST后面是IP地址,那么ORAC ...
- Oracle数据库11g基于rehl6.5的配置与安装
REDHAT6.5安装oracle11.2.4 ORACLE11G R2官档网址: http://docs.oracle.com/cd/E11882_01/install.112/e24326/toc ...
- Linux下oracle11gR2系统安装到数据库建立配置及最后oracle的dmp文件导入一站式操作记录
简介 之前也在linux下安装过oralce,可每次都是迷迷糊糊的,因为大脑一片空白,网上随便看见一个文档就直接复制,最后搞了乱七八糟,虽然装上了,却乱得很,现在记录下来,希望能给其他网上朋友遇到问题 ...
- 聚焦 SQL 数据库活动异地复制
Tobias Ternstrom US-DS-PM 首席部门项目经理 本文作为一系列业务连续性和灾难恢复文章的开篇,概述了业务连续性的各种场景,然后重点介绍 SQL 数据库高级服务级别提供的活动异地 ...
- 配置ORACLE 客户端连接到数据库
--================================= -- 配置ORACLE 客户端连接到数据库 --================================= Oracle ...
- Oracle GoldenGate配置异构数据库数据传输(oracle到sqlserer)的dml操作(带pump进程)
实验环境:os01:Red Hat Enterprise Linux Server release 5.1 (32位)db01:oracle 10.2.0.1.0 os02:Windows 7 (32 ...
随机推荐
- java---EL与ONGL的区别
EL表达式: >>单纯在jsp页面中出现,是在四个作用域中取值,page,request,session,application.>>如果在struts环境中,它除了有在上面的 ...
- ffmpeg 编解码详细过程
ffmpeg编解码详细过程 bobbypollo 转:ffmpeg编解码详细过程 原文地址:ffmpeg编解码详细过程(转)作者:心在飞翔原文出处: http://www.360doc.com ...
- 资深投资人全力反击: VC增值平台从来就不是一坨狗屎
编者注: 本文来自海外著名科技博客VentureBeat, 英文原文出自Kyle Lacy之手 ,中文版由天地会珠海分舵进行编译. 文章主要是针对前几天德国VC Christian Claussen的 ...
- 针对后台列表table拖拽比较实用的jquery拖动排序
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&qu ...
- float类型如何转换为string类型
在一些很大的float类型的地方会用科学记数法表示,这个时候如果想完整记录下来,还是得转字符串,这里书写一个float类型转string类型的方法 <?php function float_to ...
- jQuery 选择器实例
语法 描述 $(this) 当前 HTML 元素 $("p") 所有 <p> 元素 $("p.intro") 所有 class="intr ...
- 安装autoit libary失败问题解决
运行环境:win7-32,python2.7安装遇到的问题:
- ActiveMQ伪集群部署
本文借鉴http://www.cnblogs.com/guozhen/p/5984915.html,在此基础上进行了完善,使之成为一个完整版的伪分布式部署说明,在此记录一下! 一.本文目的 介绍如何在 ...
- PL/SQL编程1-基础
编写第一个存储过程 create or replace procedure test_pro1 is begin ','zydev'); end; / 查看错误 show error 执行存储过程 e ...
- Java——我的概念
1.多态:(1)父类变量引用子类对象;(2)该引用只能调用父类中定义的方法和变量;(3)如果子类中重写了父类中的一个方法,那么在调用这个方法的时候,将会调用子类中的这个方法;(动态连接.动态调用)