【测试】手工搭建DG

前言:(一)准备工作:

1.数据库要处于归档模式;

2.监听参数:local_listener 默认值为空--1521

3.关闭闪回(可能会触发数据库的bug,备库不能开闪回)

4.如果有外部表,外部表要删除。

(二)环境描述:

192.168.206.3    主库    ORA11GR2

192.168.206.4    备库    PROD

一,将数据库处于归档模式:

SYS@ORA11GR2>startup mount;
ORACLE instance started.

Total System Global Area  830930944 bytes
Fixed Size                  2257800 bytes
Variable Size             536874104 bytes
Database Buffers          285212672 bytes
Redo Buffers                6586368 bytes
Database mounted.
SYS@ORA11GR2>archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch
Oldest online log sequence     2
Current log sequence           4

SYS@ORA11GR2>alter database archivelog;

Database altered.

SYS@ORA11GR2>archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch
Oldest online log sequence     3
Next log sequence to archive   5
Current log sequence           5

二,验证监听:local_listener 默认值为空--1521

SYS@ORA11GR2>show parameter local_listener;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string

三,关闪回(可能会触发数据库bug,备库不能开闪回)

SYS@ORA11GR2>select flashback_on from v$database;

FLASHBACK_ON
------------------
NO

四,修改参数:

在vi initORA1GR2.ora中加入:

DB_NAME=ORA11GR2
DB_UNIQUE_NAME=ORA11GR2
LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(ORA11GR2,PROD)‘
LOG_ARCHIVE_DEST_1=
 ‘LOCATION=/u01/arch1/ORA11GR2/
  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
  DB_UNIQUE_NAME=ORA11GR2‘
LOG_ARCHIVE_DEST_2=
 ‘SERVICE=PROD ASYNC
  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
  DB_UNIQUE_NAME=PROD‘
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=30
FAL_SERVER=PROD
DB_FILE_NAME_CONVERT=‘PROD‘,‘ORA11GR2‘
LOG_FILE_NAME_CONVERT=
 ‘/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch/PROD/‘,‘/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch/ORA11GR2/‘
STANDBY_FILE_MANAGEMENT=AUTO

五,开启force logging

SYS@ORA11GR2>select FORCE_LOGGING from v$database;

FOR
---
NO

SYS@ORA11GR2>alter database force logging;

Database altered.

六,查看日志文件及大小,并增加standby logfile:

SYS@ORA11GR2>select group#,bytes /1024/1024 M from v$log;

    GROUP#          M
---------- ----------
         1         50
         2         50
         3         50

SYS@ORA11GR2>select GROUP#,MEMBER from v$logfile;

    GROUP# MEMBER
---------- --------------------------------------------------
         3 /u01/app/oracle/oradata/ORA11GR2/redo03.log
         2 /u01/app/oracle/oradata/ORA11GR2/redo02.log
         1 /u01/app/oracle/oradata/ORA11GR2/redo01.log

增加日志文件:
SYS@ORA11GR2>alter database add standby logfile group 4 (‘/u01/app/oracle/oradata/ORA11GR2/redo401_std.log‘,‘/u01/app/oracle/oradata/ORA11GR2/redo402_std.log‘) size 50M;

Database altered.

SYS@ORA11GR2>c/4/5
  1* alter database add standby logfile group 5 (‘/u01/app/oracle/oradata/ORA11GR2/redo401_std.log‘,‘/u01/app/oracle/oradata/ORA11GR2/redo402_std.log‘) size 50M
SYS@ORA11GR2>c/4/5
  1* alter database add standby logfile group 5 (‘/u01/app/oracle/oradata/ORA11GR2/redo501_std.log‘,‘/u01/app/oracle/oradata/ORA11GR2/redo402_std.log‘) size 50M
SYS@ORA11GR2>c/4/5
  1* alter database add standby logfile group 5 (‘/u01/app/oracle/oradata/ORA11GR2/redo501_std.log‘,‘/u01/app/oracle/oradata/ORA11GR2/redo502_std.log‘) size 50M
SYS@ORA11GR2>/

Database altered.

SYS@ORA11GR2>c/5/6
  1* alter database add standby logfile group 6 (‘/u01/app/oracle/oradata/ORA11GR2/redo501_std.log‘,‘/u01/app/oracle/oradata/ORA11GR2/redo502_std.log‘) size 50M
SYS@ORA11GR2>c/5/6
  1* alter database add standby logfile group 6 (‘/u01/app/oracle/oradata/ORA11GR2/redo601_std.log‘,‘/u01/app/oracle/oradata/ORA11GR2/redo502_std.log‘) size 50M
SYS@ORA11GR2>c/5/6
  1* alter database add standby logfile group 6 (‘/u01/app/oracle/oradata/ORA11GR2/redo601_std.log‘,‘/u01/app/oracle/oradata/ORA11GR2/redo602_std.log‘) size 50M
SYS@ORA11GR2>/

Database altered.

SYS@ORA11GR2>c/6/7
  1* alter database add standby logfile group 7 (‘/u01/app/oracle/oradata/ORA11GR2/redo601_std.log‘,‘/u01/app/oracle/oradata/ORA11GR2/redo602_std.log‘) size 50M
SYS@ORA11GR2>c/6/7
  1* alter database add standby logfile group 7 (‘/u01/app/oracle/oradata/ORA11GR2/redo701_std.log‘,‘/u01/app/oracle/oradata/ORA11GR2/redo602_std.log‘) size 50M
SYS@ORA11GR2>c/6/7
  1* alter database add standby logfile group 7 (‘/u01/app/oracle/oradata/ORA11GR2/redo701_std.log‘,‘/u01/app/oracle/oradata/ORA11GR2/redo702_std.log‘) size 50M
SYS@ORA11GR2>/

Database altered.

SYS@ORA11GR2>select GROUP#,MEMBER from v$logfile;

    GROUP# MEMBER
---------- --------------------------------------------------
         3 /u01/app/oracle/oradata/ORA11GR2/redo03.log
         2 /u01/app/oracle/oradata/ORA11GR2/redo02.log
         1 /u01/app/oracle/oradata/ORA11GR2/redo01.log
         4 /u01/app/oracle/oradata/ORA11GR2/redo401_std.log
         4 /u01/app/oracle/oradata/ORA11GR2/redo402_std.log
         5 /u01/app/oracle/oradata/ORA11GR2/redo501_std.log
         5 /u01/app/oracle/oradata/ORA11GR2/redo502_std.log
         6 /u01/app/oracle/oradata/ORA11GR2/redo601_std.log
         6 /u01/app/oracle/oradata/ORA11GR2/redo602_std.log
         7 /u01/app/oracle/oradata/ORA11GR2/redo701_std.log
         7 /u01/app/oracle/oradata/ORA11GR2/redo702_std.log

11 rows selected.

七,将主库参数文件和口令文件传给备库:

[[email protected] dbs]$ scp initPROD.ora orapwPROD 192.168.206.4:/u01/app/oracle/product/11.2.0/dbhome_1/dbs
oracle@192.168.206.4‘s password:
initPROD.ora                                                                                                                          100% 1559     1.5KB/s   00:00
orapwPROD                                                                                                                             100% 1536     1.5KB/s   00:00   

八,修改备库的参数文件:

[[email protected] dbs]$ ls
hc_ORA11GR2.dat  init.ora  initPROD.ora  lkORA11GR2  orapwORA11GR2  orapwPROD  spfileORA11GR2.ora
[[email protected] dbs]$ vi initPROD.ora 【加入】

DB_NAME=ORA11GR2
DB_UNIQUE_NAME=PROD
LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(PROD,ORA11GR2)‘
LOG_ARCHIVE_DEST_1=
 ‘LOCATION=/u01/arch1/PROD/
  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
  DB_UNIQUE_NAME=PROD‘
LOG_ARCHIVE_DEST_2=
 ‘SERVICE=ORA11GR2 ASYNC
  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
  DB_UNIQUE_NAME=ORA11GR2‘
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=30
FAL_SERVER=ORA11GR2
DB_FILE_NAME_CONVERT=‘ORA11GR2‘,‘PROD‘
LOG_FILE_NAME_CONVERT=
 ‘/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch/ORA11GR2/‘,‘/u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch/PROD/‘
STANDBY_FILE_MANAGEMENT=AUTO

九,创建参数中涉及到的目录:

[[email protected] dbs]$ mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch/ORA11GR2/
[[email protected] dbs]$ mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch/PROD/
[[email protected] dbs]$ mkdir -p /u01/arch1/PROD/
[[email protected] dbs]$ mkdir -p /u01/app/oracle/oradata/PROD/
[[email protected] dbs]$ mkdir -p /u01/app/oracle/admin/PROD/adump

此时将备库起到nomount:
SQL> startup nomount
ORACLE instance started.

Total System Global Area  830930944 bytes
Fixed Size                  2257800 bytes
Variable Size             536874104 bytes
Database Buffers          285212672 bytes
Redo Buffers                6586368 bytes

十,配置网络监听:

①主库:
[[email protected] admin]$ vi listener.ora 

# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = host03)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

SID_LIST_LISTENER=
   (SID_LIST=
       (SID_DESC=
          (GLOBAL_DBNAME=ORA11GR2)
          (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
         (SID_NAME=ORA11GR2)
         )
        )

②主库客户端监听:
[[email protected] admin]$ vi tnsnames.ora

PROD=
    (DESCRIPTION=
       (ADDRESS=(PROTOCOL = TCP)(HOST = 192.168.206.4)(PORT = 1521)
          (CONNECT_DATA=
     (SERVER=DEDICATED)
     (SERVICE_NAME=PROD)
    )
  )
)
③备库监听:
[[email protected] admin]$ vi listener.ora 

# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = host04)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

SID_LIST_LISTENER=
   (SID_LIST=
       (SID_DESC=
          (GLOBAL_DBNAME=PROD)
          (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
         (SID_NAME=PROD)
         )
        )
④备库客户端监听:
[[email protected] admin]$ vi tnsnames.ora

ORA11GR2=
  (DESCRIPTION=
     (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.206.3)(PORT=1521))
    (CONNECT_DATA=
     (SERVER=DEDICATED)
     (SERVICE_NAME=ORA11GR2)
    )
  )
查看主库监听状态:
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host03)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                20-OCT-2016 00:52:32
Uptime                    0 days 0 hr. 1 min. 3 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/host03/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host03)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "ORA11GR2" has 2 instance(s).
  Instance "ORA11GR2", status UNKNOWN, has 1 handler(s) for this service...
  Instance "ORA11GR2", status READY, has 1 handler(s) for this service...
Service "ORA11GR2XDB" has 1 instance(s).
  Instance "ORA11GR2", status READY, has 1 handler(s) for this service...
The command completed successfully

查看备库监听状态:
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host04)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                20-OCT-2016 00:53:12
Uptime                    0 days 0 hr. 0 min. 29 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/host04/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host04)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "PROD" has 1 instance(s).
  Instance "PROD", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

主库验证客户端监听:
[[email protected] admin]$ tnsping PROD

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 20-OCT-2016 01:04:16

Copyright (c) 1997, 2013, Oracle.  All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.206.4)(PORT=1521)) (CONNECT_DATA= (SERVER=DEDICATED) (SERVICE_NAME=PROD)))
OK (10 msec)
[[email protected] admin]$ sqlplus sys/oracle@PROD as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Oct 20 01:04:33 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

SYS@PROD>
备库验证客户端监听:
[[email protected] admin]$ tnsping ORA11GR2

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 20-OCT-2016 00:57:38

Copyright (c) 1997, 2013, Oracle.  All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.206.3)(PORT=1521)) (CONNECT_DATA= (SERVER=DEDICATED) (SERVICE_NAME=ORA11GR2)))
OK (50 msec)
[[email protected] admin]$ sqlplus sys/oracle@ORA11GR2 as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Oct 20 01:01:18 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

十一,复制主库生成备库:

[[email protected] dbs]$ rman target / auxiliary sys/oracle@PROD

Recovery Manager: Release 11.2.0.4.0 - Production on Thu Oct 20 01:07:15 2016

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORA11GR2 (DBID=242173609)
connected to auxiliary database: ORA11GR2 (not mounted)

RMAN> duplicate target database for standby from active database;
时间: 2024-10-06 10:18:44

【测试】手工搭建DG的相关文章

Spring TestContext测试框架搭建

同样是测试,JUnit和Spring TestContext相比,Spring TestContext优势如下: 1.Spring TestContext可以手动设置测试事务回滚,不破坏数据现场 2.在测试类中不用手动装配bean,只要一个@Autowired即可自动装配 ----------------分割线--------------------------- 本文记录web project和java project如何使用TestContext测试框架,首先介绍web project 现总

[软件测试]Linux环境中简单清爽的Google Test (GTest)测试环境搭建(初级使用)

本文将介绍单元测试工具google test(GTEST)在linux操作系统中测试环境的搭建方法.本文属于google test使用的基础教程.在linux中使用google test之前,需要对如下知识有一些了解: (1)C/C++编程方法 (2)makefile的编写 (3)linux命令行操作 (4)GTEST背景知识:它是用来干什么的?它用什么语言编写的?它的一些基本语法?等等 以上知识不需要做到熟能生巧,只要达到入门级别,使用GTEST不会费任何力气,毕竟GTEST也不是一个高门槛的

Appium Android测试环境搭建 for Mac

Appium Android测试环境搭建 涉及的资源,工具都很多 ,从网上各种资料查找,整合一下资源,针对小白级别. 1.Appium安装: 转载自:http://www.cnblogs.com/oscarxie/p/3894559.html. 2.Mac配置Android环境变量: 转载自:http://www.jianshu.com/p/84f3baf1682c 3.Mac安装Android模拟器genymotion: 转载自:http://blog.csdn.net/l_215851356

测试环境搭建

软?件?测?试?环?境?的?搭?建 http://wenku.baidu.com/link?url=5SC-IFbVxfdiZzr4uJYrBVI543iMDzeWcWK9upvs_tsYkUYcsAU5j145jQDP_fZCtCA1Tz6XWDWx3FyxBPALNP2a4EUHOVic4nb2uQFxv-e 软件测试,测试环境搭建需要考虑哪些方面? http://zhidao.baidu.com/link?url=oBDiBjh9jTyo3g_ZSvZP67iFrbimu9aH-VinLF

【转1】Appium 1.6.3 在Xcode 8, iOS 10.2(模拟器)测试环境搭建 经验总结

Appium 1.6.3 在Xcode 8, iOS 10.2(模拟器)测试环境搭建 经验总结 关于 Appium 1.6.3 在Xcode 8, 10.2 的iOS模拟器上的问题很多,本人也差点放弃,最终成功运行,确实不容易,故此写篇文章,供大家参考,让大家少走弯路.一. 安装Appium(1) 先安装node-js,然后通过node-js命令安装 Appium     在https://nodejs.org/en/download/ 下载 macOS Installer (.pkg) 安装,

【转2】Appium 1.6.3 在Xcode 8 (真机)测试环境搭建 经验总结

Appium 1.6.3 在Xcode 8 (真机)测试环境搭建经验总结 关于 Appium 1.6.3 在Xcode 8, 1真机上环境搭建问题更多,写此文章,供大家参考,让大家少走弯路. 在开始iOS真机测试之前,请大家务必 将 Appium 1.6.3 + xcode 8 在iOS模拟器上的环境搭建OK,请参见我的上一篇博文:Appium 1.6.3在Xcode 8, iOS 10.2(模拟器)测试环境搭建经验总结 如果iOS模拟器上的环境OK,再来真机上搭建,要不然 你还是放弃吧. 进入

Hadoop单机Hadoop测试环境搭建

Hadoop单机Hadoop测试环境搭建: 1. 安装jdk,并配置环境变量,配置ssh免密码登录 2. 下载安装包hadoop-2.7.3.tar.gz 3. 配置/etc/hosts 127.0.0.1 YARN001 4. 解压缩hadoop-2.7.3.tar.gtz到/home/zhangzhenghai/cluster目录下 5. 配置etc/hadoop/hadoop-env.sh 配置JAVA_HOME环境变量 export JAVA_HOME=/home/zhangzhengh

Andriod SDK和Loadrunner的HTTP协议测试环境搭建

Andriod SDK和Loadrunner的HTTP协议测试环境搭建 1.Andriod SDK安装 1.1 安装JDK(不累述) 1.2 配置环境变量 配置JDK的系统变量环境,我们需要设置三个系统变量,分别是JAVA_HOME,Path和CLASSPATH.下面是这三个变量的设置防范. JAVA_HOME 先设置这个系统变量名称,变量值为JDK在你电脑上的安装路径:C:\Program Files\Java\jdk1.8.0_20.创建好后则可以利用%JAVA_HOME%作为JDK安装目录

自动化测试-东航B2C网站测试框架搭建

还是周末闲来无事做了一个我们公司电商产品-东航官网的自动化测试框架,发布到公司测试环境后获得好评. 现在把框架内容补齐做个阶段性的基线吧. 总体 1 现在框架运用到的技术: Selenium SpringMVC Hibernate Logback 2 主要接口的定位:以主流程的页面为接口,对其进行实现 3 异常处理机制:多种策略并存克服不稳定的测试环境 4 定时任务机制:采用Spring的提供的定时器进行cron配置 5 邮件系统:采用Spring和JavaX的邮件系统 6 测试数据持久化:入库