码迷,mamicode.com
首页 > 数据库 > 详细

Oracle 12C Data Gurad RAC TO RAC

时间:2018-08-17 20:09:38      阅读:642      评论:0      收藏:0      [点我收藏+]

标签:height   seo   param   created   memory   isp   asm   int   direct   

 

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 grid@vm-ora-N1:/tmp/orapwalbin
su - grid
asmcmd -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号

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;

 

Oracle 12C Data Gurad RAC TO RAC

标签:height   seo   param   created   memory   isp   asm   int   direct   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!