Oracle 12C Data Gurad RAC TO RAC

Oracle 12C RAC TO RAC Data Guard on RHEL7

0.环境说明

  primary db physical standby
操作系统 rhel7 x86_64 rhel7 x86_64
数据库版本 12.2.0.1 12.2.0.1
IP 10.150.10.134/136 10.150.10.139/141
主机名称 vm-oradb1-N1/N2 vm-oradb2-N1/N2
数据库名称 albin albin
db_unique_name albin albindg
实例名称 albin1/albin2 albin1/albin2
tnsnames tns_albin tns_albindg
dg监听 lsnr_dg:1625 lsnr_dg:1625

1. 创建primary容器库

1)dbca建库

dbca -ignorePreReqs -ignorePrereqFailure -silent -createDatabase                    -gdbName albin                                                                      -sid albin                                                                          -templateName General_Purpose.dbc                                                   -characterSet AL32UTF8                                                              -createAsContainerDatabase true                                                     -numberOfPDBs 1                                                                     -pdbName tmpdb                                                                      -pdbAdminPassword oraP#ssw0rd                                                       -pdbOptions JSERVER:true,XML:true,CATJAVA:true,CONTEXT:true,ORDIM:true              -useLocalUndoForPDBs true                                                           \-databaseConfigType RAC                                                             -databaseType MULTIPURPOSE                                                          -datafileDestination +DATA                                                          -datafileJarLocation /oracle/app/oracle/product/12.2/db_1/assistants/dbca/templates -emConfiguration NONE                                                               -enableArchive false                                                                -memoryMgmtType AUTO_SGA                                                            -memoryPercentage 20                                                                -nationalCharacterSet AL16UTF16                                                     -nodelist vm-oradb1-N1,vm-oradb1-N2                                                 -redoLogFileSize 100                                                                -storageType ASM                                                                    -sysPassword oraP#ssw0rd                                                            -systemPassword oraP#ssw0rd                                                         -useOMF true                                                                        -recoveryAreaDestination NONE

2. 配置Oracle Net和监听

1)tnsnames配置(主备)

su - oracle
vi $(orabasehome)/network/admin/tnsnames.ora
tns_albin =
(DESCRIPTION =
    (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 10.150.10.135)(PORT = 1625))
    )
    (CONNECT_DATA =
        (SERVER = DEDICATED)
        (SERVICE_NAME = albin)
    )
)

tns_albindg =
(DESCRIPTION =
    (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 10.150.10.140)(PORT = 1625))
    )
    (CONNECT_DATA =
        (SERVER = DEDICATED)
        (SERVICE_NAME = albindg)
        (UR = A)
    )
)

2)配置监听

-- 主备添加dg监听器su - grid
srvctl add listener -listener LSNR_DG -endpoints "TCP:1625"
srvctl start listener -listener LSNR_DG
-- 备库添加静态监听
vi $(orabasehome)/network/admin/listener.ora
SID_LIST_LSNR_DG =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = albindg)
      (ORACLE_HOME = /oracle/app/12.2.0/grid)
      (SID_NAME = albin1)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = albindg_DGMGRL)
      (ORACLE_HOME = /oracle/app/12.2.0/grid)
      (SID_NAME = albin1)
    )
  )注:其它节点实例按实际情况修改标红处内容

3. 密码文件配置

1)查看密码文件路径

$ srvctl config database -d albin
Database unique name: albin
Database name: albin
Oracle home: /oracle/app/oracle/product/12.2/db_1
Oracle user: oracle
Spfile: +DATA/ALBIN/PARAMETERFILE/spfile.1328.982582089
Password file: +DATA/ALBIN/PASSWORD/pwdalbin.1312.982581307
Domain:
Start options: open

2)复制密码文件到备端服务器

拷贝密码文件到文件系统并传到备端服务器
方案1:
su - oracle
sqlplus "/ as sysdba"
create or replace directory source_dir as ‘+data/albin/password‘;
create or replace directory dest_dir as ‘/tmp‘;

set lines 168 pages 99
col DIRECTORY_NAME for a32
col owner for a18
col DIRECTORY_PATH for a80
select owner, DIRECTORY_NAME, DIRECTORY_PATH,ORIGIN_CON_ID from dba_directories;

begin
  dbms_file_transfer.copy_file( source_directory_object => ‘source_dir‘,
  source_file_name => ‘pwdalbin.1312.982581307‘,
  destination_directory_object => ‘dest_dir‘,
  destination_file_name => ‘orapwalbin‘);
end;
/
SQL> host ls -l /tmp/orapwalbin

方案2:
su - grid
asmcmd
cd data/albin/password
cp pwdalbin.1312.982581307 /tmp/orapwalbin

-- 备端服务器节点 
scp /tmp/orapwalbin [email protected]:/tmp/orapwalbinsu  - gridasmcmd -exec "cp /tmp/orapwalbin +data/albindg/password/orapwalbin"

4. 主库开启force logging 和归档

SQL> alter database force logging;
alter system set log_archive_format=‘%t_%s_%r.arc‘ scope=spfile sid=‘*‘;
alter system set db_recovery_file_dest_size=‘102400M‘ scope=spfile sid=‘*‘;
alter system set db_recovery_file_dest=‘+data‘ scope=spfile sid=‘*‘;
alter system set db_file_name_convert=‘+data/albindg‘,‘+data/albin‘ scope=spfile sid=‘*‘;
alter system set log_file_name_convert=‘+data/albindg/onlinelog‘,‘+data/albin/onlinelog‘ scope=spfile sid=‘*‘;
create pfile=‘/home/oracle/albin20180816.ora‘ from spfile;

srvctl stop database -db albin
srvctl start instance -db albin -i albin1 -o mount
sqlplus "/ as sysdba"
alter database archivelog;
alter database flashback on;
srvctl stop instance -db albin -i albin1
srvctl start database -db albin

5. 主库配置dg参数

alter system set db_block_checking=FULL scope=both sid=‘*‘;
alter system set db_block_checksum=FULL scope=both sid=‘*‘;
alter system set db_lost_write_protect=TYPICAL scope=both sid=‘*‘;
alter system set standby_db_preserve_states=ALL scope=spfile sid=‘*‘;

alter system set log_archive_config=‘DG_CONFIG=(albin,albindg)‘ scope=both sid=‘*‘;
alter system set log_archive_dest_1=‘location=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=albin‘ scope=both sid=‘*‘;
alter system set log_archive_dest_2=‘SERVICE=tns_albindg LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=albindg‘ scope=both sid=‘*‘;

alter system set fal_server=tns_albindg scope=both sid=‘*‘;
alter system set fal_client=tns_albin scope=both sid=‘*‘;
alter system set standby_file_management=AUTO scope=both sid=‘*‘;

6. 创建pfile给备库使用

sqlplus "/ as sysdba"
create pfile=‘/home/oracle/stdby.ora‘  from spfile;host scp /home/oracle/stdby.ora [email protected]:/home/oracle/stdby.ora

7.主库上创建standby redo logfile

对物理备库创建备重做日志文件,查询主库的联机重做日志文件,备重做日志文件的大小应该与主库联机重做日志文件的大小相同,备重做日志文件组的数量应该比主库联机重做日志文件组多一组,计算公式为(maximum # of logfiles +1) * maximum # of threads (实际:standby_redo_logs = 主库日志组+1,成员数量一致)

注意:RAC数据库,在创建重做日志文件时需要指定thread号

alter database add standby logfile thread 1 group 11 (‘+DATA‘) size 100M;
alter database add standby logfile thread 1 group 12 (‘+DATA‘) size 100M;
alter database add standby logfile thread 1 group 13 (‘+DATA‘) size 100M; 

or alter database add standby logfile thread 1 group 11 (‘+DATA‘) size 100M,group 12 (‘+DATA‘) size 100M,group 13 (‘+DATA‘) size 100M;
alter database add standby logfile thread 1 group 11 (‘+DATA‘,‘+DATA‘) size 100M,group 12 (‘+DATA‘,‘+DATA‘) size 100M,group 13 (‘+DATA‘,‘+DATA‘) size 100M; 

alter database add standby logfile thread 2 group 21 (‘+DATA‘) size 100M;
alter database add standby logfile thread 2 group 22 (‘+DATA‘) size 100M;
alter database add standby logfile thread 2 group 23 (‘+DATA‘) size 100M; 

8. 编辑备库pfile并修改参数配置

vi stdby.ora

*.audit_file_dest=‘/oracle/app/oracle/admin/albin/adump‘
*.audit_trail=‘db‘
*.cluster_database=true
*.compatible=‘12.2.0‘
*.control_files=‘+DATA/ALBINDG/CONTROLFILE/current.1317.982581509‘
*.db_block_checking=‘FULL‘
*.db_block_checksum=‘FULL‘
*.db_block_size=8192
*.db_create_file_dest=‘+DATA‘
*.db_file_name_convert=‘+data/albin‘,‘+data/albindg‘
*.db_lost_write_protect=‘TYPICAL‘
*.db_name=‘albin‘
*.db_unique_name=‘albindg‘
*.db_recovery_file_dest=‘+DATA‘
*.db_recovery_file_dest_size=107374182400
*.diagnostic_dest=‘/oracle/app/oracle‘
*.dispatchers=‘‘
*.enable_pluggable_database=true
*.fal_client=‘TNS_ALBIN‘
*.fal_server=‘TNS_ALBINDG‘
family:dw_helper.instance_mode=‘read-only‘
albin1.instance_number=1
albin2.instance_number=2
albin2.thread=2
albin1.thread=1
albin2.undo_tablespace=‘UNDOTBS2‘
albin1.undo_tablespace=‘UNDOTBS1‘
*.local_listener=‘-oraagent-dummy-‘
*.log_archive_config=‘DG_CONFIG=(albin,albindg)‘
*.log_archive_dest_1=‘LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=albindg‘
*.log_archive_dest_2=‘SERVICE=tns_albin LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=albin‘
*.log_archive_format=‘%t_%s_%r.arc‘
*.log_file_name_convert=‘+data/albin/onlinelog‘,‘+data/albindg/onlinelog‘
*.nls_language=‘AMERICAN‘
*.nls_territory=‘AMERICA‘
*.open_cursors=300
*.pga_aggregate_target=838860800
*.sga_target=2499805184
*.processes=640
*.remote_login_passwordfile=‘exclusive‘
*.standby_db_preserve_states=‘ALL‘
*.standby_file_management=‘AUTO‘

9. 备库创建目录结构

mkdir -p $(orabase)/admin/albin/{adump,dpdump,pfile,xdb_wallet}

10. 备库启动nomount

export ORACLE_SID=albin1
sqlplus "/ as sysdba"
create spfile=‘+data‘ from pfile=‘/home/oracle/stdby.ora‘;
startup nomount;

-- 获取spfile路径名称
su - grid
asmcmd spget

11. rman duplicate 初始化备库

rman target sys/oraP#ssw0rd@tns_albin auxiliary sys/oraP#ssw0rd@tns_albindg nocatalog
run{
    allocate channel c1 device type disk;
    allocate channel c2 device type disk;
    allocate channel c3 device type disk;
    allocate channel c4 device type disk;
    allocate auxiliary channel aux1 device type disk;
    allocate auxiliary channel aux2 device type disk;
    allocate auxiliary channel aux3 device type disk;
    allocate auxiliary channel aux4 device type disk;
    duplicate target database for standby from active database nofilenamecheck;
}

12. 备库注册数据库实例服务

srvctl add database -db albindg -oraclehome /oracle/app/oracle/product/12.2/db_1 -dbtype RAC -spfile ‘+DATA/ALBIN/PARAMETERFILE/<根据步骤10结果补充>‘ -role physical_standby -startoption open -stopoption immediate -dbname albin -policy automatic -diskgroup DATA

srvctl add instance -db albindg -instance albin1 -n vm-ora-N1
srvctl add instance -db albindg -instance albin2 -n vm-ora-N2

13. 备库执行实时重做应用(其中一个节点实例执行)

sqlplus "/ as sysdba"
alter database recover managed standby database using current logfile disconnect from session;
-- alter database recover managed standby database parallel 8 using current logfile disconnect from session; 

-- 关闭实时应用
alter database recover managed standby database cancel;

原文地址:https://www.cnblogs.com/wandering-mind/p/9494928.html

时间: 2024-11-07 21:58:48

Oracle 12C Data Gurad RAC TO RAC的相关文章

Oracle 12c Data Guard 搭建手册

Oracle 12c 的DataGuard 是在CDB 级别进行的,所以我们的配置都是从CDB角度出发. 测试里主备库的数据库CDB名称相同. 1  环境说明 OS Version: [[email protected] etc]# cat /etc/oracle-release Oracle Linux Server release 6.3 [[email protected] etc]# uname -r 2.6.39-200.29.3.el6uek.x86_64 DB Version: S

How to deploy Oracle 12c Release 2 Grid and RAC Database on RHEL 7.x

https://www.dell.com/support/article/uk/en/ukbsdt1/how16671/how-to-deploy-oracle-12c-release-2-grid-and-rac-database-on-rhel-7-x?lang=zh 原文地址:https://www.cnblogs.com/weikui/p/12004105.html

Oracle 12c Data Guard 纯小白部署手册

子公司需要搭建数据仓库,并且新建ADG作为主从,硬件设备Dell R730机器:192.168.1.11 dwjrdb --主库 192.168.1.12 dwjrstdyd --备库--数据库软件:linuxx64_12201_database.zip--数据库补丁包:p27105253_122010_Linux-x86-64.zip--Opatch升级包:p6880880_122010_Linux-x86-64.zip--目录规划为/u01存放归档日志,数据文件等,目录6.6TB空间 一.数

ORACLE 12C R2 RAC实战首发

大家都知道ORACLE database 12cR2当前正式版并没有发布,当前网上所发布的但是ORACLE database 12cR2技术文档,大多是理论型的从ORACLE OWW会议上,及该会议流露出来的PPT上所摘抄下来,重新组织而发布的文档,对于实战应用操作文档,则较少甚至很难找到. 但是,子衿技术团队已经提前拿到了ORACLE database12cR2的Beta版,已经完全具备了实战应用操作条件,所以有了<ORACLE 12C R2 RAC实战首发>一文". 实战的第一步

Oracle 12c RAC 集群使用 GNS 实现 SCAN

注:本文谢绝转载! 1   说明 在前面的Blog中,讲过RAC 中SCAN 的配置有三种方式: (1) /etc/hosts (2) DNS (3) GNS 具体链接如下: Oracle RAC 集群 SCAN 说明 http://blog.csdn.net/tianlesoftware/article/details/42712979 Oracle 12c RAC 集群使用DNS 实现 SCAN http://blog.csdn.net/tianlesoftware/article/deta

Oracle 12c RAC 替换 OCR 磁盘组操作步骤

注:本文谢绝转载! 为方便以后的测试,整了一套新的测试环境,600G PCIe 闪存卡+8核CPU+16G内存.  把整个虚拟机从我的电脑上直接copy 过去,网络什么都没问题,但是RAC 的共享设备是重新添加的. 这样之前旧的数据都不存在. 所以用脚本直接重建了OCR和Voting Disk,RAC 启动,没有问题,但是磁盘组出现错乱,Dave 有强迫症的倾向,所以重新重新添加了一个磁盘组.  把OCR 和 voting disk 都替换到新创建的OCR 磁盘组了. 所以以下所有的操作,只为一

Oracle 12c RAC 集群使用DNS 实现 SCAN

注:本文谢绝转载! 1   说明 关于RAC 集群的SCAN 特性说明参考: Oracle RAC 集群 SCAN 说明 http://blog.csdn.net/tianlesoftware/article/details/42712979 本文描述Oracle 12c RAC 集群使用DNS 实现SCAN. DNS 的配置工作,就是分配SCAN IP地址,并映射到一个域名上. SCAN IP最多有3个,我的环境,只有2个节点,这个也没关系,我照样弄3个SCANIP. 当前IP规划: [[em

Oracle 12c RAC安装PSU(12.1.0.2.161018)

一.准备工作 1,数据库环境 操作系统版本   : Redhat 6.8 x64   数据库版本     : Oracle 12.1.0.2 x64 RAC    Grid           : 12.1.0.2     Oracle database: 12.1.0.2 2,准备内容 GI PSU : p24412235_121020_Linux-x86-64.zip   OPatch : p6880880_122010_Linux-x86-64.zip    DB PSU : p24006

ORACLE 12C 三节点 RAC 安装报错 [INS-32025]

测试安装三节点Oracle 12C RAC,笔记本配置双核I5 16g内存,每台虚机分配4G 内存. 在数据库软件安装过程中,主实例异常重启,重新安装数据库软件,但是遇到报错.报错如下: [INS-32025] The chosen installation conflicts with software already installed in the given oracle home. 处理方法如下: 1.修改inventory文件 [[email protected] ContentsX