Oracle12C 单实例dataguard配置

Oracle用户环境变量配置:

ORACLE_BASE=/orcl/app/oracle

ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1

ORACLE_SID=orcl

export ORACLE_BASE ORACLE_HOME ORACLE_SID

PATH=$ORACLE_HOME/bin:$PATH

export PATH

export NLS_LANG=american_america.AL32UTF8

主库:

1. 将primary数据库设置为force logging模式

select force_logging from v$database;

alter database force logging;

2. 创建密码文件(如果没有)

orapwd file=$ORACLE_HOME/dbs/orapworcl password=syspassword entries=30;

3. 将主库至于归档模式

shutdown immediate;

startup mount;

alter database archivelog;

alter database open;

4. disabled selinux

cat /etc/selinux/config | grep 'SELINUX'

5. 配置standby redo log

select GROUP#,BYTES/1024/1024 size_M,STATUS,ARCHIVED from v$log;  # 查询当前日志组大小

alter database add standby logfile group 4 ('/orcl/app/oracle/oradata/orcl/standbyrd01.log') size 200M;

alter database add standby logfile group 5 ('/orcl/app/oracle/oradata/orcl/standbyrd02.log') size 200M;

alter database add standby logfile group 6 ('/orcl/app/oracle/oradata/orcl/standbyrd03.log') size 200M;

alter database add standby logfile group 7 ('/orcl/app/oracle/oradata/orcl/standbyrd04.log') size 200M;

alter database drop standby logfile group 4;  # 删除

select group#,thread#,sequence#,archived,status from v$standby_log;  # 验证

6. 生成控制文件

alter database create standby controlfile as '/orcl/app/oracle/oradata/orcl/orcldg01.ctl';

7. 生成初始化参数文件

create pfile from spfile;

vi $ORACLE_HOME/dbs/initorcl.ora(添加以下内容)

*.log_file_name_convert='/orcl/app/oracle/oradata/orcl/','/orcl/app/oracle/oradata/orcl/'

*.db_unique_name='orcl1'

*.fal_client='orcl1'

*.fal_server='orcldg'

*.log_archive_config='DG_CONFIG=(orcl1,orcldg)'

*.log_archive_dest_1='LOCATION=/orcl/app/oracle/oradata/orcl/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl1'

*.log_archive_dest_2='SERVICE=orcldg LGWR ASYNC VALID_FOR=(ALL_LOGFILES,PRIMARY_ROLES) DB_UNIQUE_NAME=orcldg'

*.log_archive_dest_state_1='ENABLE'

*.log_archive_dest_state_2='ENABLE'

*.standby_file_management='AUTO'

*.remote_login_passwordfile='EXCLUSIVE'

*.log_archive_format=%t_%s_%r.arc

create spfile from pfile='initorcl.ora'

8. 修改listener.ora文件

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = nginx01)(PORT = 1521))

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

)

)

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = orcl)

(SID_NAME = orcl)

)

)

ADR_BASE_LISTENER=/orcl/app/oracle

9. 修改tnsnames.ora文件

ORCL =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = nginx01)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = orcl)

)

)

ORCLDG =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = nginx01-dg)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = orcldg)

)

)

10. shutdown immediate

11. 传输控制文件、初始化参数文件、监听文件、密码文件到备机

cd /orcl/app/oracle/product/12.2.0/db_1/network/admin

scp listener.ora nginx01-dg:/orcl/app/oracle/product/12.2.0/db_1/network/admin

scp tnsnames.ora nginx01-dg:/orcl/app/oracle/product/12.2.0/db_1/network/admin

scp sqlnet.ora nginx01-dg:/orcl/app/oracle/product/12.2.0/db_1/network/admin

cd /orcl/app/oracle/oradata/orcl

scp orcldg01.ctl nginx01-dg:/orcl/app/oracle/oradata/orcl/

cd /orcl/app/oracle/product/12.2.0/db_1/dbs

scp initorcl.ora nginx01-dg:/orcl/app/oracle/product/12.2.0/db_1/dbs/initorcl.ora

scp orapworcl nginx01-dg:/orcl/app/oracle/product/12.2.0/db_1/dbs/orapworcl

12. 在主库上RMAN备份恢复到standby:

1. 主库启动到mount状态,备库启动到nomount状态

2. rman target sys/[email protected] auxiliary sys/[email protected]

3. duplicate target database for standby nofilenamecheck from active database;  # 主备机目录一致使用nofilenamecheck参数

备库:

1. disabled selinux

cat /etc/selinux/config | grep 'SELINUX'

2. 创建目录

mkdir -p /orcl/app/oracle/oradata/orcl/

mkdir -p /orcl/app/oracle/admin/orcl/adump

3. 修改主库传过来的初始化参数文件initorcl.ora文件

*.control_files='/orcl/app/oracle/oradata/orcl/orcldg01.ctl','/orcl/app/oracle/oradata/orcl/orcldg02.ctl'

*.log_file_name_convert='/orcl/app/oracle/oradata/orcl/','/orcl/app/oracle/oradata/orcl/'

*.db_unique_name='orcldg'

*.fal_client='orcldg'

*.fal_server='orcl1'

*.log_archive_config='DG_CONFIG=(orcl1,orcldg)'

*.log_archive_dest_1='LOCATION=/orcl/app/oracle/oradata/orcl/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcldg'

*.log_archive_dest_2='SERVICE=orcl1 LGWR ASYNC VALID_FOR=(ALL_LOGFILES,PRIMARY_ROLES) DB_UNIQUE_NAME=orcl1'

*.log_archive_dest_state_1='ENABLE'

*.log_archive_dest_state_2='ENABLE'

*.standby_file_management='AUTO'

*.log_archive_format=%t_%s_%r.arc

*.remote_login_passwordfile='EXCLUSIVE

4. listener.ora和tnsnames.ora文件不用做任何修改

5. 启动(rman备份恢复完成后)

alter database mount standby database;

alter database open read only;

alter database recover managed standby database disconnect from session;

alter database set standby database to maximize availability;

6. 查询验证

select switchover_status,open_mode,database_role,db_unique_name,protection_mode,protection_level from v$database;

select SEQUENCE#,FIRST_TIME,NEXT_TIME ,APPLIED from v$archived_log order by 1;

select max(sequence#) from v$log;

7. 关机

alter database recover managed standby database cancel;

shutdown immediate;

原文地址:http://blog.51cto.com/daibaiyang119/2072073

时间: 2024-11-02 14:51:52

Oracle12C 单实例dataguard配置的相关文章

Oracle11g 搭建单实例DataGuard (转载)

原文:http://blog.itpub.net/29324876/viewspace-1246133/ 环境:主备库都为单实例并且数据库SID相同 OS:red hat 6.5 Oracle:11.2.0.4.3 主库操作 1. 开启归档模式   创建归档目录 [[email protected] ~]# mkdir -p /u01/archivelog [[email protected] ~]# chown -R oracle:oinstall /u01/archivelog [[emai

mysql单实例安装配置指南

1.操作系统:CentOS 2.数据库: mysql-5.1.73.tar.gz 3.任务:单实例安装配置指南 提示:下载数据库有两种方式:一种是官网,另一种途径是国内镜象网站:国内镜象下载资源的速度比官网要快,例如,我们这次下载的就是国内搜狐镜象: http://mirrors.sohu.com/mysql/MySQL-5.1/ http://mirrors.sohu.com/ 整个安装过程: [[email protected] tools]#wget http://mirrors.sohu

oracle单实例绑定多个服务

背景: 项目前期是在一台服务器建立了两个实例,客户端配置两个连接,现在需要把两个实例整合其中一个实例中去,要求不更改客户端的配置. 例如 整合前有test,standby2两个实例 整合后只有standby2这个实例 之前在RAC上用srvctl配置过,还没有在单实例上配置,现在具体操作整理如下: 1.创建服务 exec dbms_service.create_service('test','test'); select t.name,t.NETWORK_NAME  from v$service

Oracle Data Guard 单实例到单实例配置(物理standby)

接上一篇oracle dataguard概念篇,现在进行下详细的配置,此次配置的是单实例到单实例,也就是说主库和备库都是基于文件系统的单实例. 主机环境:Red Hat Enterprise Linux Server release 6.3 Rdbms版本:11.2.0.3 其他详细信息如下所示: 需要注意的是,两边的/etc/hosts文件保证都包含对方的ip对应关系 oracle安装的目录是相同的 编辑/etc/hosts,分别添加以下内容 192.168.1.241 db1 192.168

oracle单实例通过dataguard 迁移到RAC

One instance primary to RAC standbyDataGuard Configuration: Primary standby Clusterware Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit 11g R2 Grid Infrastructure (11.2.0.4) Cluster Nodes Cltrac1 Srvrac1,srvrac2 DB_UNIQUE_NAME Test1

搭建Oracle 11G单实例Active DataGuard

Oracle 11G单实例ActiveDataGuard 1.基础环境准备 1.1基础环境说明: 操作系统:RHEL 5.5 64bit 数据库版本:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit 1.2数据库服务名称及目录说明: 主库 备库 IP地址 192.168.4.157 192.168.4.158 主机名称 primary01 standby01 db_name testdb testdb db_uni

CENTOS6.6上搭建单实例ORACLE12C

本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn 摘要: 自己在centos6.6上搭建的单实例oracle12c 由于搭建过程有些不好写,所以图片偏多 *由于截图不规则导致排版有点乱,已经安装过来了,有些截图不能回头截图了,见谅 oracle软件与linux 认证版本 检查硬件要求(Check Hardware Requirements) Check CPU grep "model name" /pro

使用dataguard将单实例数据库转换为rac数据库

我们经常将oracle rac数据库通过dataguard容灾到一个单实例数据库中,当生产库出现故障后可以将生产库切换到dg服务器上.而当生产库rac修复完成后,我们同样可以通过dg将数据回切到生产库中. 此次测试将单实例数据库通过dg转换为rac数据库,这个单实例是刚创建的,并不是由rac通过dg生成的. 在做dg之前需要安装完成grid,不需要创建数据库实例.在日志应用的时候必须只能是一个实例应用. 具体环境如下: 单实例库: 数据库版本:11.2.0.4.0 sid:suq db_uniq

Linux平台oracle 11g单实例 安装部署配置 快速参考

1.重建主机的Oracle用户 组 统一规范 uid gid 以保证共享存储挂接或其他需求的权限规范 userdel -r oracle groupadd -g 500 oinstall groupadd -g 501 dba useradd -g oinstall -G dba -u 500 oracle #id oracle uid=500(oracle) gid=500(oinstall) 组=500(oinstall),501(dba) 2.安装好Oracle 需要的rpm包.安装rpm