RHEL6.4 + Oracle 11g DG测试环境快速搭建参考
环境现状:
primary | standby | |
主机 | JY-DB | JY-DBS |
db_name | jyzhao | jyzhao |
db_unique_name | jyzhao | jyzhao_s |
instance_name | jyzhao | jyzhao_s |
存储 | +DATA1 | +DATA1 |
归档 |
/u01/app/oracle/product/11.2.0/db_1/dbs/arch
|
/u01/app/oracle/product/11.2.0/db_1/dbs/arch
|
DGMGRL | jyzhao_dgmgrl | jyzhao_s_dgmgrl |
GRID_HOME |
/u01/app/11.2.0/grid
|
/u01/app/11.2.0/grid
|
ORACLE_HOME |
/u01/app/oracle/product/11.2.0/db_1
|
/u01/app/oracle/product/11.2.0/db_1
|
- 2.1 primary database 配置
- 2.2 机器B:standby数据库配置
- 2.3 机器A操作 duplicate数据库到机器B
- 2.4 B机器 srvctl add数据库jyzhao_s
一、前期准备
1.1. A机器打包拷贝/u01/app到B机器(包含了grid和oracle软件安装目录)
# tar -zcvf app.tar.gz app # scp app.tar.gz 192.168.99.160:/u01/
root@192.168.99.160's password:
app.tar.gz 100% 3564MB 54.8MB/s 01:05
B机器解压,解压前确保第二步操作已完成。 # pwd
/u01
[root@JY-DBS u01]# ls
app.tar.gz lost+found
[root@JY-DBS u01]# tar -zxvf app.tar.gz
解压完成后,检查权限是正确的
# ls -lh
total 3.5G
drwxrwxr-x. 7 oracle oinstall 4.0K Mar 13 14:47 app
-rw-r--r--. 1 root root 3.5G Mar 15 22:28 app.tar.gz
1.2. B机器配置用户,系统参数,安装依赖包,用户环境变量,ASM磁盘
root用户执行脚本
# /u01/app/oraInventory/orainstRoot.sh
# /u01/app/11.2.0/grid/root.sh
# /u01/app/11.2.0/grid/perl/bin/perl -I/u01/app/11.2.0/grid/perl/lib -I/u01/app/11.2.0/grid/crs/install /u01/app/11.2.0/grid/crs/install/roothas.pl 配置has
需要建立asm磁盘组 环境变量:
vi $ORACLE_HOME/dbs/init+ASM.ora *.asm_diskstring='/dev/mapper/ora*'
*.asm_power_limit=1
*.diagnostic_dest='/u01/app/grid'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='EXCLUSIVE' $ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Mon Mar 16 10:51:02 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORA-01078: failure in processing system parameters
ORA-29701: unable to connect to Cluster Synchronization Service $ crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ons
OFFLINE OFFLINE jy-dbs
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
1 OFFLINE OFFLINE
ora.diskmon
1 OFFLINE OFFLINE
ora.evmd
1 ONLINE ONLINE jy-dbs
$ crsctl start resource ora.cssd
CRS-2672: Attempting to start 'ora.cssd' on 'jy-dbs'
CRS-2672: Attempting to start 'ora.diskmon' on 'jy-dbs'
CRS-2676: Start of 'ora.diskmon' on 'jy-dbs' succeeded
CRS-2676: Start of 'ora.cssd' on 'jy-dbs' succeeded
$ crsctl status res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ons
OFFLINE OFFLINE jy-dbs
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
1 ONLINE ONLINE jy-dbs
ora.diskmon
1 OFFLINE OFFLINE
ora.evmd
1 ONLINE ONLINE jy-dbs $ sqlplus / as sysasm SQL*Plus: Release 11.2.0.4.0 Production on Mon Mar 16 10:55:39 2015 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> startup
ASM instance started Total System Global Area 1135747072 bytes
Fixed Size 2260728 bytes
Variable Size 1108320520 bytes
ASM Cache 25165824 bytes
ORA-15110: no diskgroups mounted SQL> select status from v$instance;
STATUS
------------------------
STARTED col description for a35
col process for a35
set linesize 120
select sid, serial#, process, name, description from v$session join v$bgprocess using(paddr); col path for a45
col name for a30
select group_number, disk_number, mount_status, name, path from v$asm_disk order by group_number, disk_number;
GROUP_NUMBER DISK_NUMBER MOUNT_STATUS NAME PATH
------------ ----------- -------------- ------------------------------ ---------------------------------------------
0 0 CLOSED /dev/mapper/ora_vg-lv_asm3
0 1 CLOSED /dev/mapper/ora_vg-lv_asm2
0 2 CLOSED /dev/mapper/ora_vg-lv_asm1 查看A机器的磁盘组信息:
select group_number, name, type, total_mb, free_mb from v$asm_diskgroup
GROUP_NUMBER NAME TYPE TOTAL_MB FREE_MB
------------ ------------------------------------------------------------ ------------ ---------- ----------
1 DATA1 EXTERN 30708 29017 B机器创建ASM磁盘组DATA1:
select group_number, name, type, total_mb, free_mb from v$asm_diskgroup;
no rows selected CREATE DISKGROUP data1 EXTERNAL REDUNDANCY DISK '/dev/mapper/ora*';
Diskgroup created. select group_number, name, type, total_mb, free_mb from v$asm_diskgroup; GROUP_NUMBER NAME TYPE TOTAL_MB FREE_MB
------------ ------------------------------------------------------------ ------------ ---------- ----------
1 DATA1 EXTERN 30708 30654
至此,准备工作结束。
二、DG部署配置
2.1 primary database 配置
确保将数据库的force_logging打开,设置为归档模式,数据库闪回打开 SQL> select name from v$datafile; NAME
--------------------------------------------------------------------------------
+DATA1/jyzhao/datafile/system.256.874084601
+DATA1/jyzhao/datafile/sysaux.257.874084601
+DATA1/jyzhao/datafile/undotbs1.258.874084601
+DATA1/jyzhao/datafile/users.259.874084601 SQL> select force_logging from v$database;
FOR
---
NO SQL> alter database force logging;
Database altered. SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down. SQL> startup mount
ORACLE instance started.
Total System Global Area 1620115456 bytes
Fixed Size 2253704 bytes
Variable Size 1006636152 bytes
Database Buffers 603979776 bytes
Redo Buffers 7245824 bytes
Database mounted.
SQL> alter database archivelog;
Database altered. SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-38706: Cannot turn on FLASHBACK DATABASE logging.
ORA-38709: Recovery Area is not enabled. SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/product/11.2.0/db_1/dbs/arch
Oldest online log sequence 12
Next log sequence to archive 14
Current log sequence 14 $ mkdir -p /u01/app/oracle/product/11.2.0/db_1/dbs/arch SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-38706: Cannot turn on FLASHBACK DATABASE logging.
ORA-38709: Recovery Area is not enabled. SQL> show parameter db_recover
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string
db_recovery_file_dest_size big integer 0
SQL> alter system set db_recovery_file_dest_size=5G;
System altered. SQL> alter system set db_recovery_file_dest='/u01/app/oracle/product/11.2.0/db_1/dbs/arch';
System altered. SQL> select status from v$instance;
STATUS
------------
MOUNTED
SQL> alter database flashback on;
Database altered.
按之前的规划设置数据库的参数
alter system set db_unique_name='jyzhao' scope=spfile;
alter system set log_archive_config='DG_CONFIG=(jyzhao,jyzhao_s)' scope=spfile; alter system set log_archive_dest_='LOCATION=/u01/app/oracle/product/11.2.0/db_1/dbs/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=jyzhao' scope=spfile;
alter system set log_archive_dest_='SERVICE=jyzhao_s ASYNC LGWR VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=jyzhao_s' scope=spfile; alter system set log_archive_format='arch_%r_%t_%s.arc' scope=spfile;
alter system set fal_server=jyzhao_s scope=spfile;
alter system set fal_client=jyzhao scope=spfile;
alter system set standby_file_management=AUTO;
alter database add standby logfile group size 50M;
alter database add standby logfile group size 50M;
alter database add standby logfile group size 50M;
alter database add standby logfile group size 50M; rm /u01/app/oracle/product/11.2./db_/dbs/orapwjyzhao
orapwd file=$ORACLE_HOME/dbs/orapwjyzhao password=oracle entries= ignorecase=Y
grid用户配置监听
--listener.ora
DGL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = JY-DB)(PORT = 1521))
) SID_LIST_DGL =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = jyzhao)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = jyzhao)
)
(SID_DESC =
(GLOBAL_DBNAME = jyzhao_dgmgrl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = jyzhao)
)
) ADR_BASE_DGL = /u01/app/grid
oracle用户配置tnsnames.ora
--tnsnames.ora
JYZHAO =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = JY-DB)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jyzhao )
)
)
JYZHAO_S =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = JY-DBS)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jyzhao_s)
)
)
grid用户重启监听:
lsnrctl stop dgl
lsnrctl start dgl
oracle用户测试连接:
sqlplus sys/oracle@jyzhao as sysdba
sqlplus sys/oracle@JY-DB/jyzhao_dgmgrl as sysdba
sqlplus sys/oracle@JY-DB/jyzhao as sysdba
SQL> show parameter audi
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_file_dest string /u01/app/oracle/admin/jyzhao/a
dump
重启primary
shutdown immediate
startup
2.2 机器B:standby数据库配置
--listener.ora
DGL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = JY-DBS)(PORT = 1521))
) SID_LIST_DGL =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = jyzhao_s)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = jyzhao_s)
)
(SID_DESC =
(GLOBAL_DBNAME = jyzhao_s_dgmgrl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = jyzhao_s)
)
) ADR_BASE_DGL = /u01/app/grid
grid用户启动监听
$ lsnrctl start dgl
oracle用户配置tnsnames.ora
--tnsnames.ora
JYZHAO =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = JY-DB)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jyzhao )
)
)
JYZHAO_S =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = JY-DBS)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jyzhao_s)
)
)
echo "db_name=jyzhao" >> $ORACLE_HOME/dbs/initjyzhao_s.ora
echo $ORACLE_SID
sqlplus / as sysdba
startup nomount
oracle用户测试连接 :
sqlplus sys/oracle@jyzhao as sysdba
sqlplus sys/oracle@jyzhao_s as sysdba
sqlplus sys/oracle@JY-DBS/jyzhao_s_dgmgrl as sysdba
sqlplus sys/oracle@JY-DBS/jyzhao_s as sysdba
2.3 机器A操作 duplicate数据库到机器B
验证到机器B可以登录
$ sqlplus sys/oracle@jyzhao_s as sysdba
vi duplicate_dg.sql
duplicate target database
for standby
from active database
DORECOVER
spfile
set db_unique_name='jyzhao_s'
set log_archive_dest_1='location=/u01/app/oracle/product/11.2.0/db_1/dbs/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=jyzhao_s'
set log_archive_dest_2='SERVICE=jyzhao ASYNC LGWR
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=jyzhao'
set standby_file_management='AUTO'
set fal_server='jyzhao'
set fal_client='jyzhao_s'
set control_files='+DATA1'
set memory_target='0'
set sga_target='600M';
[oracle@JY-DB ~]$ rman target / auxiliary sys/oracle@jyzhaos cmdfile=duplicate_standby.sql
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Mar 16 23:21:37 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: JYZHAO (DBID=2463175424)
connected to auxiliary database: JYZHAO (not mounted)
RMAN> duplicate target database
2> for standby
3> from active database
4> DORECOVER
5> spfile
6> set db_unique_name='jyzhao_s'
7> set log_archive_dest_1='location=/u01/app/oracle/product/11.2.0/db_1/dbs/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
8> DB_UNIQUE_NAME=jyzhao_s'
9> set log_archive_dest_2='SERVICE=MACDBN ASYNC LGWR
10> VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=jyzhao'
11> set standby_file_management='AUTO'
12> set fal_server='jyzhao'
13> set fal_client='jyzhao_s'
14> set control_files='+DATA1'
15> set memory_target='0'
16> set sga_target='600M';
17>
Starting Duplicate Db at 16-MAR-15
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=111 device type=DISK
……
Recovery Manager complete.
[oracle@JY-DB ~]$
2.4 B机器 srvctl add数据库jyzhao_s
srvctl add database -d jyzhao_s -o /u01/app/oracle/product/11.2.0/db_1 -p +DATA1/JYZHAO_S/spfilejyzhao_s.ora -n jyzhao -i jyzhao_s srvctl modify database -d jyzhao_s -r PHYSICAL_STANDBY
三、DG切换测试
3.1 手动switchover
select OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS, FORCE_LOGGING, DATAGUARD_BROKER, GUARD_STATUS from v$database;
alter database commit to switchover to physical standby;
2.备库切换成primary,启动到open
select OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS, FORCE_LOGGING, DATAGUARD_BROKER, GUARD_STATUS from v$database;
alter database commit to switchover to primary;
3.新的备库执行日志应用
alter database recover managed standby database using current logfile disconnect from session;
3.2 Data Guard Broker 快速switchover
SQL> show parameter dg_broker_start
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dg_broker_start boolean FALSE
SQL> alter system set dg_broker_start = true;
System altered.
SQL> show parameter dg_broker_start
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dg_broker_start boolean TRUE
配置dgmgrl
create CONFIGURATION jydb as primary database is jyzhao CONNECT IDENTIFIER IS jyzhao; add database jyzhao_s as CONNECT IDENTIFIER IS jyzhao_s MAINTAINED AS PHYSICAL; enable configuration; show configuration; switchover to jyzhao_s; switchover to jyzhao; show database verbose jydb
References
- Oracle® Data Guard Broker 11g Release 2 (11.2)
- Oracle® Data Guard Concepts and Administration 11g Release 2 (11.2)
- http://t.askmaclean.com/thread-2530-1-1.html
RHEL6.4 + Oracle 11g DG测试环境快速搭建参考的更多相关文章
- VMware搭建Oracle 11g RAC测试环境 For Linux
环境如下: Linux操作系统:Centos 6.5 64bit (这个版本的redhat 6内核等OS在安装grid最后执行root.sh时会出现crs-4124,是oracle11.2.0.1的b ...
- Oracle 11g DG手工switchover切换标准化流程
Oracle 11g DG手工switchover切换标准化流程 环境:RHEL 6.5 + Oracle GI 11.2.0.4 + Oracle DB 11.2.0.4 Primary RAC(2 ...
- Java Web 开发环境快速搭建
Java Web 开发环境快速搭建 在因某种原因更换开发设备后,可依据此文快速搭建开发环境,恢复工作环境. Java开发环境: Windows 10 (64-bit) Oralce JDK Eclip ...
- 【Linux】测试环境如何搭建?
[Linux]测试环境如何搭建? (该文档所在我的百度网盘位置: ) 通常面试会问到会不会搭建测试环境?到底啥是测试环境搭建呢,其实测试环境没有想像的那么高大上,弄个 tomcat,把测试的 war ...
- Python+selenium测试环境成功搭建,简单控制浏览器(firefox)接下来,继续学习其他浏览器上的测试环境搭建;学习Python语言,利用Python语言来写测试用例。加油!!!
Python+selenium测试环境成功搭建,简单控制浏览器(firefox)接下来,继续学习其他浏览器上的测试环境搭建:学习Python语言,利用Python语言来写测试用例.加油!!!
- selenium + python + firefox 测试环境的搭建与配置
对于做UI自动化,如果是纯编写一段自动化测试程序,那么后续的维护成本会较高.这种情况下,借助 selenium 这款自动化系测试工具,辅助于自己编写部分脚本,将是个不错的选择.selenium 本身支 ...
- 关于基于python2.7的unity自动化测试框架GAutomator测试环境的搭建(源码网盘下载地址:https://pan.baidu.com/s/1c2TXwtU)
关于基于python 2.7的unity自动化测试框架GAutomator测试环境的搭建 百度云盘链接(思维图学习资料):https://pan.baidu.com/s/1dFWExMD 准备工作(具 ...
- Oracle 11g DG配置简明版
环境: 主库A机:在线生产环境,RHEL 6.4 + Oracle 11.2.0.3 备库B机:新增备机,RHEL 6.4 需求: 对生产环境最小影响前提下配置DG备库. 目录: 一.B机安装相同版本 ...
- vSphere在RedHat6.0上搭建Oracle 11g R2 RAC环境
一.前期准备工作 1.1 为方便操作,装完系统后我们先安装Vmware Tools: 1.1.1.安装工具 在VMware的菜单栏上选择"虚拟机/安装虚拟机工具(VM/Install VMw ...
随机推荐
- Vue.js 和 MVVM 小细节
MVVM 是Model-View-ViewModel 的缩写,它是一种基于前端开发的架构模式,其核心是提供对View 和 ViewModel 的双向数据绑定,这使得ViewModel 的状态改变可以自 ...
- C++中的事件分发
本文意在展现一个C++实现的通用事件分发系统,能够灵活的处理各种事件.对于事件处理函数的注册,希望既能注册到普通函数,注册到事件处理类,也能注册到任意类的成员函数.这样在游戏客户端的逻辑处理中,可以非 ...
- C语言 · 最大值与最小值计算
输入11个整数,计算它们的最大值和最小值. 样例输入 0 1 2 3 4 5 6 7 8 9 10 样例输出 10 0 #include<stdio.h> int main(){ ]; ...
- TODO:Laravel增加验证码
TODO:Laravel增加验证码1. 先聊聊验证码是什么,有什么作用?验证码(CAPTCHA)是"Completely Automated Public Turing test to te ...
- JavaScript动画-磁性吸附
▓▓▓▓▓▓ 大致介绍 磁性吸附是以模拟拖拽为基础添加一个拖拽时范围的限定而来的一个效果,如果对模拟拖拽有疑问的同学请移步模拟拖拽. 源代码.效果:点这里 ▓▓▓▓▓▓ 范围限定(可视区) 先来看一个 ...
- dagger2系列之依赖方式dependencies、包含方式(从属方式)SubComponent
本篇是实战文章,从代码的角度分析这两种方式.本文参考自下列文章: http://www.jianshu.com/p/1d42d2e6f4a5 http://www.jianshu.com/p/94d4 ...
- myeclipse 内存不够用报错PermGen space 和 An internal error has occurred.
最近项目中又增加了新的模块,项目的代码又多了不少.运行的时候总是报如下错误 Exception in thread "http-apr-80-exec-6" java.lang.O ...
- VPN连接常见错误汇总
提示远程服务器没有响应. 这种情况有两种情况,一种是远程服务器出现故障.另一种是自己的电脑出现问题,具体原因我还没有找到,但是可以肯定的是注册表除了问题,一个终极的解决办法就是把注册表替换了.先将HK ...
- 山寨Unity3D?搜狐畅游的免费开源游戏引擎Genesis-3D
在CSDN上看到了<搜狐畅游发布3D游戏引擎Genesis-3D 基于MIT协议开源>(http://www.csdn.net/article/2013-11-21/2817585-cha ...
- 2015微软MVP全球峰会见闻
2015.10.31-2015.11.8 一周的时间完成微软MVP全球峰会旅程,这一周在不断的倒时差,行程安排非常的紧张,还好和大家请假了没有更新微信公众号,今天开始继续更新微信公众号,开始新的旅程, ...