oracle DG搭建

Oracle DG 搭建
1、 环境
OS IP hostname db_name DB_UNIQUE_NAME
主库 RHEL 5.4 192.168.12.20 edgzrip1.oracle.com PROD1 PROD1
备库 RHEL 5.4 192.168.12.30 edgzrip2.oracle.com PROD1 DG

2、 设置主库开启归档
SQL> alter database archivelog;
Database altered.
3、 设置主库开启强制记录日志
SQL> alter database force logging;
Database altered.
4、 查询主库归档模式及日志强制记录
SQL> select log_mode,force_logging from v$database;
LOG_MODE FOR
------------ ---
ARCHIVELOG YES
5、 添加standby log
SQL> alter database add standby logfile group 4 ‘/u01/app/oracle/oradata/PROD1/standby04.log‘ size 50m;

Database altered.

SQL> alter database add standby logfile group 5 ‘/u01/app/oracle/oradata/PROD1/standby05.log‘ size 50m;

Database altered.

SQL> alter database add standby logfile group 6 ‘/u01/app/oracle/oradata/PROD1/standby06.log‘ size 50m;

Database altered.

SQL> alter database add standby logfile group 7 ‘/u01/app/oracle/oradata/PROD1/standby07.log‘ size 50m;

Database altered.
6、 主库创建pfile
SQL> create pfile from spfile;
File created.
7、 传送pfile到备库
[[email protected] dbs]# scp initPROD1.ora edgzrip2:/u01/app/oracle/product/11.2.0/db_1/dbs/initDG.ora
[email protected]‘s password:
initPROD1.ora
8、 修改spfile
在spfile追加以下参数
DB_UNIQUE_NAME=PROD1
LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(PROD1,DG)‘
LOG_ARCHIVE_DEST_1=‘LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=PROD1‘
LOG_ARCHIVE_DEST_2= ‘SERVICE=DG ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=DG‘
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
FAL_SERVER=DG
DB_FILE_NAME_CONVERT=‘/u01/app/oracle/oradata/DG‘,‘/u01/app/oracle/oradata/PROD1‘
LOG_FILE_NAME_CONVERT=‘/u01/app/oracle/oradata/DG‘,‘/u01/app/oracle/oradata/PROD1‘
STANDBY_FILE_MANAGEMENT=AUTO
9、 使用新的spfile启动主库,并创建新的spfile
Startup pfile=’/u01/app/oracle/product/11.2.0/db_1/dbs/initPROD1.ora’
Create spfile from pfile;
10、 传送密码文件orapwPROD1到备库
[[email protected] dbs]# scp orapwPROD1 edgzrip2:/u01/app/oracle/product/11.2.0/db_1/dbs/ orapwDG

11、 修改备库参数文件initDG.ora
追加以下参数:
DB_UNIQUE_NAME=DG
LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(DG,PROD1)‘
LOG_ARCHIVE_DEST_1=‘LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=DG‘
LOG_ARCHIVE_DEST_2= ‘SERVICE=PROD1 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PROD1‘
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
FAL_SERVER=PROD1
DB_FILE_NAME_CONVERT=‘/u01/app/oracle/oradata/PROD1‘,‘/u01/app/oracle/oradata/DG‘
LOG_FILE_NAME_CONVERT=‘/u01/app/oracle/oradata/PROD1‘,‘/u01/app/oracle/oradata/DG‘
STANDBY_FILE_MANAGEMENT=AUTO
12、 在备库创建相应目录
Mkdir –p /u01/app/oracle/oradata/DG
Mkdir –p /u01/app/oracle/fast_recovery_area/DG
Mkdir –p /u01/app/oracle/admin/DG/{a,dp}dump
13、 使用备库pfile创建spfile,并启动到nomount状态
[[email protected] ~]$ sqlplus / as sysdba
Create spfile from pfile;
Startup nomount
14、 配置主库备库网络
主库listener.ora:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = PROD1.us.oracle.com)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = PROD1)
)
)

LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip1.oracle.com)(PORT = 1521))
)

ADR_BASE_LISTENER = /u01/app/oracle

主库tnsnames.ora:
PROD1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip1.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = PROD1.us.oracle.com)
)
)

DG =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip2.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = DG.us.oracle.com)
)
)

备库listener.ora:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = DG.us.oracle.com)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = DG)
)
)

备库tnsnames.ora:
PROD1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip1.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = PROD1.us.oracle.com)
)
)

DG =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip2.oracle.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = DG.us.oracle.com)
)
)

测试主备库网络:
启动主备库监听:lsnrctl start
主库:
[[email protected] admin]$ tnsping prod1

TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 26-AUG-2019 19:52:18

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

Used parameter files:

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip1.oracle.com)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = PROD1.us.oracle.com)))
OK (10 msec)
[[email protected] admin]$ tnsping dg

TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 26-AUG-2019 19:52:25

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

Used parameter files:

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip2.oracle.com)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = DG.us.oracle.com)))
OK (0 msec)

备库:
[[email protected] admin]$ tnsping prod1

TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 26-AUG-2019 19:55:22

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

Used parameter files:

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip1.oracle.com)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = PROD1.us.oracle.com)))
OK (10 msec)
[[email protected] admin]$ tnsping dg

TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 26-AUG-2019 19:55:26

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

Used parameter files:

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = edgzrip2.oracle.com)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = DG.us.oracle.com)))
OK (10 msec)
确认主备库网络无问题
15、 备库登录rman
[[email protected] admin]$ rman target sys/[email protected] auxiliary sys/[email protected]

Recovery Manager: Release 11.2.0.3.0 - Production on Mon Aug 26 19:56:30 2019

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

connected to target database: PROD1 (DBID=2202819890)
connected to auxiliary database: PROD1 (started)

RMAN>
16、 执行duplicate
RMAN> duplicate target database for standby from active database nofilenamecheck dorecovery;
17、 Duplicate完成后,在备库启用实时日志应用
SQL> alter database recover managed standby database using current logfile disconnect from session;

原文地址:https://www.cnblogs.com/orcl-2018/p/11415227.html

时间: 2024-10-16 14:48:36

oracle DG搭建的相关文章

linux下oracle11G DG搭建(四):后续验证操作

环境 名称 主库 备库 主机名 bjsrv shsrv 软件版本 RedHat Enterprise5.5.Oracle 11g 11.2.0.1 RedHat Enterprise5.5.Oracle 11g 11.2.0.1 主库下 $ tail -f /u01/app/oracle/diag/rdbms/bjdb/TestDB12/trace/alert_TestDB12.log 对于DG,一定要打开告警日志. 备库下 $ tail -f/u01/app/oracle/diag/rdbms

linux下oracle11G DG搭建(三):围绕备库搭建操作

环境 名称 主库 备库 主机名 bjsrv shsrv 软件版本 RedHat Enterprise5.5.Oracle 11g 11.2.0.1 RedHat Enterprise5.5.Oracle 11g 11.2.0.1 三.围绕备库操作: 1.备库-修改初始化参数文件 $cd$ORACLE_HOME/dbs $df -h $vi initshdb.ora 修改简要说明: *.audit_file_dest='/u01/app/oracle/admin/sh/adump' //审计文件存

linux下oracle11G DG搭建(二):围绕主库搭建操作

环境 名称 主库 备库 主机名 bjsrv shsrv 软件版本 RedHat Enterprise5.5.Oracle 11g 11.2.0.1 RedHat Enterprise5.5.Oracle 11g 11.2.0.1 二.围绕主库操作: 1.主库-修改初始化参数 SQL> show parameter spfile; NAME                 TYPE        VALUE ------------------------------------ --------

linux下oracle11G DG搭建(一):环境准备

linux下oracle11G  DG搭建(一):环境准备 环境 名称 主库 备库 主机名 bjsrv shsrv 软件版本 RedHat Enterprise5.5.Oracle 11g 11.2.0.1 RedHat Enterprise5.5.Oracle 11g 11.2.0.1 一.环境准备: 1.vbox 导入虚拟机镜像(已安装oracle.已建库) 1.导入虚拟机(主库-北京,以下简称bj) 2.导入虚拟机(备库-上海,以下简称sh) 3.主库.备库分别添加一块磁盘 为主库和备库分

linux下oracle11G DG搭建(四):兴许验证操作

环境 名称 主库 备库 主机名 bjsrv shsrv 软件版本号 RedHat Enterprise5.5.Oracle 11g 11.2.0.1 RedHat Enterprise5.5.Oracle 11g 11.2.0.1 主库下 $ tail -f /u01/app/oracle/diag/rdbms/bjdb/TestDB12/trace/alert_TestDB12.log 对于DG.一定要打开告警日志. 备库下 $ tail -f/u01/app/oracle/diag/rdbm

DG搭建方式区分

DG搭建三种方式: 一.异机恢复,restore database,recover database 二. duplicate target database for standby from active database; 三. duplicate target database for standby 区别: 对主库的影响: 异机恢复,使用主库传输过来的备份,手工搭建物理DG,影响最小,安全系数最高,三种方式对比操作复杂   --手动挡 duplicate from active data

记一次DG搭建过程中ORA-09925: Unable to createaudit trail file 错误

今天做Oracle DG  编写initorcl的时候,修改完以后,sqlplus就不能再登陆,一直报 ERROR: ORA-09925: Unable to createaudit trail file Linux Error: 2: No such file ordirectory Additional information:9925 ORA-01075: you are currentlylogged on 一直找不到原因,后来在网上偶然找到个帖子说了这样一个情况,试了下,果然有效 [o

Oracle DG之--构建Physical Standby

Oracle DG之--构建Physical Standby 系统环境: 操作系统: RedHat EL4 Oracle:    Oracle 10.2.0.1.0                                   从以上图中所示:主库为bj(db_unique_name),备库为sh. 案例分析:  本案例采用RMAN Duplicate方式建立standby database. 一.配置主备库初始化参数 主库的初始化参数:initbj.ora [[email protect

nginx整合php+lua+oracle环境搭建

nginx整合php+lua+oracle环境搭建 标签: nginxluaoraclephplinux 2014-09-25 10:39 1473人阅读 评论(0) 收藏 举报 分类: 技术(70) 版权声明:本文为博主原创文章,未经博主允许不得转载. *执行 yum update 为了得到一个最新的系统 *执行 rpm -ivh oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm oracle-instantclient12.1-de