赞
踩
Oracle12c rac-dg搭建
一、 开启RAC的forcelogging(已开)
SQL> alter database force logging;
修改RAC初始化参数文件(根据实际情况修改)
SQL> alter system setlog_archive_config='DG_CONFIG=(eisoo,eisoos)';
SQL> alter system set log_archive_dest_2='SERVICE=eisoos ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)DB_UNIQUE_NAME=eisoos' scope=spfile;
SQL> alter system setlog_archive_dest_state_1=ENABLE;
SQL> alter system set log_archive_dest_state_2=ENABLE;
SQL> alter system set fal_server=eisoos;
SQL> alter system setdb_file_name_convert='eisoos','eisoo' scope=spfile;
SQL> alter system set db_file_name_convert='/data/oradata/eisoos','+DATA/EISOO/DATAFILE'scope=spfile; //如果备库没有使用asm,红色为备库数据文件目录
SQL> alter system setlog_file_name_convert='eisoos','eisoo'scope=spfile;
SQL> alter system setlog_file_name_convert='/data/oradata/eisoos','+DATA/EISOO/ONLINELOG'scope=spfile;//如果备库没有使用asm
SQL> alter system set standby_file_management='AUTO';
SQL> alter system setlog_archive_max_processes=30;
注:红色字为备库相关信息
开启归档模式(已做)
创建standby logfile(先查看是否已创建)
查看是否有
selectgroup#,thread#,sequence#,archived,status from v$standby_log;
查看当前如日之大小
SQL> select thread#,group#,bytes/1024/1024/1024from v$log;
THREAD# GROUP# BYTES/1024/1024
---------- ---------- ---------------
1 1 50
1 2 50
2 3 50
2 4 50
新建多个和当前日志大小的standby logfile
SQL> alter database add standby logfilethread 2 group 4 size 4G;
SQL> alter database add standby logfilethread 2 group 5 size 4G;
SQL> alter database add standby logfilethread 2 group 6 size 4G;
SQL> alter database add standby logfilethread 2 group 7 size 4G;
SQL> alter database add standby logfilethread 2 group 8 size 50M;
SQL> alter database add standby logfilethread 2 group 9 size 50M;
SQL> selectthread#,group#,bytes/1024/1024 from v$standby_log;
THREAD# GROUP# BYTES/1024/1024
---------- ---------- ---------------
1 10 50
1 11 50
1 12 50
2 13 50
2 14 50
2 15 50
创建备库参数文件
SQL> show parameter spfile;
NAME TYPE VALUE
----------------------------------------------- ------------------------------
spfile string +DATA/EISOO/PARAMETERFILE/spfile.281.923255053
SQL> create pfile='/tmp/initeisoos.ora'from spfile='+DATA/EISOO/PARAMETERFILE/spfile.281.923255053';
[oracle@rac1 tmp]$ scp initeisoos.ora192.168.180.48:$ORACLE_HOME/dbs
//将参数文件传至备库dbs目录下
修改参数文件
单机未使用asm:
*.audit_file_dest='/u01/app/oracle/admin/eisoos/adump'
*.audit_trail='db'
*.compatible='12.1.0.2.0'
*.control_files='/data/oradata/eisoos/control01.ctl'#RestoreControlfile
*.db_block_size=8192
*.db_create_file_dest='/data/oradata/eisoos'
*.db_domain=''
*.db_file_name_convert='+DATA/EISOO/DATAFILE','/data/oradata/eisoos','+DATA/EISOO/TEMPFILE','/data/oradata/eisoos'
*.db_name='eisoo'
*.db_unique_name='eisoos'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=eisoosXDB)'
*.fal_server='EISOOS'
*.log_archive_config='DG_CONFIG=(eisoo,eisoos)'
*.log_archive_dest_1='LOCATION=/data/oradata/eisoos/archivelog'
*.log_archive_dest_2='SERVICE=eisoo ASYNCVALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=eisoo'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=30
*.log_file_name_convert='+DATA/EISOO/ONLINELOG','/data/oradata/eisoos'
*.open_cursors=300
*.pga_aggregate_target=453m //需要根据实际情况修改
*.processes=300 //需要根据实际情况修改
*.remote_login_passwordfile='exclusive'
*.sga_target=1361m //需要根据实际情况修改
*.standby_file_management='AUTO'
eisoos.undo_tablespace='UNDOTBS1'
注:绿色字为主库相关信息
启动到 nomout状态
SQL> startup nomount pfile='/u01/app/oracle/product/12.1.0/db_1/dbs/initeisoos.ora';
ORACLE instance started.
Total System Global Area 1442840576 bytes
Fixed Size 2924448 bytes
Variable Size 486539360 bytes
Database Buffers 939524096 bytes
Redo Buffers 13852672 bytes
SQL>
SQL>ALTER SYSTEM SETSEC_CASE_SENSITIVE_LOGON=false;
备注:SEC_CASE_SENSITIVE_LOGON参数是决定密码文件是否可以在本地创建,否则只能从主库拷贝到备库。默认值是“true”,
在本地创建密码文件
创建和rac 的sys的密码相同的密码文件
ocrl:/u01/app/oracle/product/12.1.0/db_1/dbs@oracle1>orapwdfile=orapweisoos password=oracle entries=10 ignorecase=y force=y
配置监听文件,保证primary和standby能够互连
备库:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.180.41)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = eisoos)
(ORACLE_HOME = /u01/app/oracle/product/12.1.0/db_1)
(SID_NAME = eisoos)
)
)
主库和备库是tnsname.ora 配置如下:
eisoo =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.180.51)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = eisoo)
)
)
eisoos =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.180.41)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = eisoos)
)
)
主备分别验证:
[oracle@rac1 ~]$ sqlplus sys/oracle@eisooas sysdba
[oracle@rac1 ~]$ sqlplus sys/oracle@eisoosas sysdba
[oracle@rac2 ~]$ sqlplus sys/oracle@eisooas sysdba
[oracle@rac2 ~]$ sqlplus sys/oracle@eisoosas sysdba
备份恢复数据
eisoos:/home/oracle@oracle1>rman targetsys/oracle@eisoo auxiliary sys/oracle@eisoos
Recovery Manager: Release 12.1.0.2.0 -Production on Mon Sep 26 16:50:42 2016
Copyright (c) 1982, 2014, Oracle and/or itsaffiliates. All rights reserved.
connected to target database: EISOO(DBID=3774196505)
connected to auxiliary database: EISOO (notmounted)
RMAN> duplicate target database forstandby from active database;
Starting Duplicate Db at 2016/09/2616:52:12
开启实时同步
SQL> alter database recover managedstandby database using current logfile disconnect from session;
验证:
1)
SQL> select dest_name,error fromv$archive_dest;//通过查看archive_log_dest_2列是否有error报错,如果有报错,则需要先根据报错内容解决问题
2)
查询主库最大归档序号和备库最大归档序号
select max(sequence#) from v$archived_log;
然后在主库切换日志:alter system switch logfile;
再次查询备库最大归档序号,一致即归档同步成功。
主库:
SQL> select max(sequence#) fromv$archived_log;
MAX(SEQUENCE#)
--------------
133
SQL> alter system switch logfile;
System altered.
SQL> select max(sequence#) fromv$archived_log;
MAX(SEQUENCE#)
--------------
134
SQL>
备库:
SQL> select max(sequence#) fromv$archived_log;
MAX(SEQUENCE#)
--------------
134
SQL>
3)
主库验证
SQL>select SEQUENCE#, FIRST_TIME,NEXT_TIME, APPLIED, ARCHIVED from V$ARCHIVED_LOG;
备库验证
SQL>select SEQUENCE#, FIRST_TIME,NEXT_TIME, APPLIED, ARCHIVED from V$ARCHIVED_LOG;
备注:观察主备库日志是否同步,如一致则表示日志CDP同步正常。
注意点:
如果sqlplus报用户名 密码错误,用orapw file=orapwORACLE,来创建密码文件
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。