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                                                                      \
-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                                                                 \
-nationalCharacterSet AL16UTF16                                                     \
-nodelist vm-oradb1-N1,vm-oradb1-N2                                                 \
-redoLogFileSize                                                                 \
-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 = ))
    )
    (CONNECT_DATA =
        (SERVER = DEDICATED)
        (SERVICE_NAME = albin)
    )
)

tns_albindg =
(DESCRIPTION =
    (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = ))
    )
    (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//grid)
      (SID_NAME = albin1)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = albindg_DGMGRL)
      (ORACLE_HOME = /oracle/app//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  pages
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 grid@vm-ora-N1:/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 oracle@vm-ora-N1:/home/oracle/stdby.ora

7.主库上创建standby redo logfile

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

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

  ('+DATA') size 100M;
  ('+DATA') size 100M;
  ('+DATA') size 100M; 

  ( ( ('+DATA') size 100M;
  ( ( ('+DATA','+DATA') size 100M; 

  ('+DATA') size 100M;
  ('+DATA') size 100M;
  ('+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=
*.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=
*.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=
albin2.instance_number=
albin2.thread=
albin1.thread=
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=
*.pga_aggregate_target=
*.sga_target=
*.processes=
*.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;

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

  1. Oracle 12c RAC 静默安装文档

    参考文档: https://docs.oracle.com/en/database/oracle/oracle-database/12.2/cwlin/index.html https://docs. ...

  2. ORACLE 12c RAC的常用管理命令

    ORACLE 12c RAC的常用管理命令 一.查询 1.RAC查询 1.1.查询节点 [grid@swnode1 ~]$ su - grid [grid@swnode1 ~]$ /u01/app/1 ...

  3. 安装oracle 12c RAC遇到的一些问题

    (1) 安装grid软件,停止在38%很长时间不动,日志显示正常   解决方法: 由于是虚拟机安装,设置的内存为600M,关闭虚拟机,把内存调成1GB,问题解决~在38%Linking RMAN Ut ...

  4. Oracle 12C RAC的optimizer_adaptive_features造成数据插入超时

    问题分析 使用10046事件追踪方式,直接生成上传时的数据库事件日志进行分析,发现主要区别在于以下两条sql语句在每次长时间上传时都有出现,并且执行用户不是上传用户,而是数据库SYS用户. ***** ...

  5. Upgrade Oracle Database 12c Release 2(12.2) RAC on RHEL7.3 with RU

    Upgrade Oracle Database 12c Release 2(12.2) RAC on RHEL7.3 -- [ RU: 26610291 (GRID INFRASTRUCTURE RE ...

  6. Data Guard Physical Standby - RAC Primary to RAC Standby 使用第二个网络 (Doc ID 1349977.1)

    Data Guard Physical Standby - RAC Primary to RAC Standby using a second network (Doc ID 1349977.1) A ...

  7. oracle 11g r2 使用rman进行迁移rac到rac

    源端服务器主机名 rac05 rac06公共IP地址(eth0) 10.15.8.15 10.15.8.16 虚拟IP地址(eth0) 10.15.8.17 10.15.8.18私有IP地址(eth1 ...

  8. 浅析Oracle 12c中Data Guard新特性

    浅析Oracle 12c中Data Guard新特性   写在前面 无论是做Oracle运维的小伙伴还是老伙伴,想必对Oracle数据库的数据级灾备核心技术—Data Guard是再熟悉不过了!这项从 ...

  9. Data Guard:Oracle 12c –新增和更新的功能 (Doc ID 1558256.1)

    Data Guard: Oracle 12c – New and updated Features (Doc ID 1558256.1) APPLIES TO: Oracle Database - E ...

随机推荐

  1. 在WPF中实现平滑滚动

    WPF实现滚动条还是比较方便的,只要在控件外围加上ScrollViewer即可,但美中不足的是:滚动的时候没有动画效果.在滚动的时候添加过渡动画能给我们的软件增色不少,例如Office 2013的滚动 ...

  2. Liunx下配置网络

    1.首先查看一下自己的网络 ifconfig 我查看之后发现....没有eth0 ok,现在去 /etc/sysconfig/network-scripts 目录中查看是否有 ifcfg-et0 文件 ...

  3. 利用LOCK机制来定位前缀劫持者

    一.文章信息 作者:Tongqing Qiu, Lusheng Ji, Dan Pei等 单位:佐治亚理工学院.美国电话电报公司实验室.康奈尔大学等 来源:Conference on Usenix S ...

  4. php命令行生成项目结构

    ghostinit.php <?php class ghostinit{ static $v = 'ghost version is 1.1'; static function init(){ ...

  5. Codeforces833A

    A. The Meaningless Game time limit per test:1 second memory limit per test:256 megabytes input:stand ...

  6. 在pycharm中进行ORM操作

    打开manage.py, 复制 import..... if.......os.....  导入django,开启django, 导入app中的models  orm操作 import os if _ ...

  7. eclipse搭建hibernate环境

    一.打开eclipse,help=>Install New Software 输入:http://download.jboss.org/jbosstools/updates/stable/kep ...

  8. Loadrunner 脚本开发-利用web_custom_request函数进行接口测试

    脚本开发-利用web_custom_request函数进行接口测试 by:授客 QQ:1033553122 一.POST + JSON格式参数 例: web_custom_request(" ...

  9. chromium os系统编译与环境搭建

    官方网址:http://www.chromium.org/chromium-os chromium os是google自2009年开启的项目,是一款开源的电脑操作系统,用于开发chromium/chr ...

  10. KeyPress 和KeyDown 、KeUp之间的区别

    前几天,在写完一个功能模块上线测试的时候,出现了一个诡异的问题.input 框在输入查询内容之后,按回车键居然有两种不同的表现形式(input 框没有绑定键盘事件),谷歌和火狐功能正常,但IE在按了回 ...