Requirements: Create a new standby RAC library in the same environment, that is, the same disk group as the primary RAC.
Description: The production environment is generally not recommended for this configuration of DG, because the storage plane is the same disk group, the actual significance of disaster preparedness. I'm here to use as a read-write separation.
Basic information:
Db_name:jyzhao
Primary RAC Db_unique_name:jyzhao
Standby RAC DB_UNIQUE_NAME:JYZHAODG
Standby RAC INSTANCE_NAME:JYZHAODG1, JYZHAODG2
Version: GI 11.2.0.4 + DB 11.2.0.4
Chapter I preparatory work
- 1.1 ASM Storage
- 1.2 Configuring Tnsnames.ora
- 1.3 Password file
Chapter II Source Database backup
Chapter III Parameter files
- 3.1 Modifying the main library parameter file
- 3.2 Modifying standby RAC parameters
- 3.3 Creating a standby SPFile in ASM
- 3.4 Standby RAC Boots to Nomount
Fourth. Rman Recovery control File
Fifth. Rman Recovery Database
Sixth. Prepare the library to open the log application
Seventh chapter Create standby log
Eighth. Checking Resource status
Chapter I preparatory work 1.1 ASM storage
Confirm that the RAC standby storage is within the same ASM disk group as the RAC Primary (PS: Disaster preparedness effect is not obvious), create a RAC Standby storage directory (based on db_unique_name)
mkdir +DATA/JYZHAODGmkdir +FRA/JYZHAODG
1.2 Configuring Tnsnames.ora
CD $ORACLE _home/network/admin/
Cat Tnsnames.ora
Add connection information for the master repository (all nodes):
JYZHAO = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oradb-scan)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = jyzhao) ) )jyzhaodg = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oradb-scan)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = jyzhaodg) ) )
1.3 Password file
Node 1:
export ORACLE_SID=jyzhaodg1密码文件;cd $ORACLE_HOME/dbsorapwd file=orapwjyzhaodg1 password=oracle entries=5或者直接copy之前的密码文件,然后mv重命名:cp orapwjyzhao1 orapwjyzhaodg1
Node 2:
export ORACLE_SID=jyzhaodg2密码文件;cd $ORACLE_HOME/dbsorapwd file=orapwjyzhaodg2 password=oracle entries=5或者直接copy之前的密码文件,然后mv重命名:cp orapwjyzhao2 orapwjyzhaodg2
Finally test the connectivity available
sqlplus sys/[email protected] as sysdbasqlplus sys/[email protected] as sysdba
Chapter II Source Database backup
VI backup.sh
The backup script is as follows:
rman target / <<EOFrun {allocate channel c1 device type disk;allocate channel c2 device type disk;backup as compressed backupset database filesperset 1 format ‘/u01/orabak/salehrdb_%d_%T_%s.bak‘;backup current controlfile format ‘/u01/orabak/control.bak‘;release channel c1;release channel c2;}EOF
Perform backup tasks in the background:
nohup sh backup.sh &
Note: If you use the backup as Copy database format scheme, you can save time by not having to back up to disk and then recovering.
Backup as copy scheme back-up script backupcp.sh content is as follows:
rman target / <<EOFrun {allocate channel c1 device type disk;allocate channel c2 device type disk;backup as copy database format ‘+DATA/JYZHAODG/DATAFILE/%u.dbf‘;release channel c1;release channel c2;}EOF
Note: In this way, the path contains directories that need to be created manually.
mkdir +DATA/JYZHAODG/DATAFILE
Chapter III parameter file 3.1 modifying the main library parameter file
Confirm the current environment Oracle_sid:
echo $ORACLE_SIDexport ORACLE_SID=jyzhao1
Create pfile based on the SPFile file:
Create pfile= '/tmp/pfile.ora ' from SPFile;
Primary RAC Add parameter
--为不停止primary RAC,所以尽可能动态修改参数:show parameter log_archive_configshow parameter db_file_name_convertshow parameter log_file_name_convertshow parameter fal_clientshow parameter fal_servershow parameter log_archive_dest_3alter system set log_archive_config=‘dg_config=(jyzhao,jyzhaodg)‘;alter system set db_file_name_convert=‘+DATA/jyzhaodg‘,‘+DATA/jyzhao‘ scope=spfile;alter system set log_file_name_convert=‘+DATA/jyzhaodg‘,‘+DATA/jyzhao‘ scope=spfile;alter system set fal_client=‘jyzhao‘;alter system set fal_server=‘jyzhaodg‘;alter system set log_archive_dest_3=‘service=jyzhaodg valid_for=(online_logfiles,primary_role) db_unique_name=jyzhaodg‘;--暂时defer传输链路,防止此时主库告警生成相关错误SQL> alter system set log_archive_dest_state_3=defer;
3.2 Modifying standby RAC parameters
Modify the repository's parameter files according to the parameter files that were exported before the main library:
Cp/tmp/pfile.ora/tmp/pfile_std.ora
Vi/tmp/pfile_std.ora
*._high_priority_processes= ' lms* ' *.audit_file_dest= '/u01/app/oracle/admin/jyzhaodg/adump ' *.audit_trail= ' db ' *. Cluster_database=true*.compatible= ' 11.2.0.4.0 ' *.control_files= ' +data/jyzhaodg/controlfile/ current.260.931878631 ', ' +fra/jyzhaodg/controlfile/current.256.931878631 ' *.db_block_size=8192*.db_create_file_ dest= ' +data ' *.db_domain= ' *.db_name= ' Jyzhao ' *.db_recovery_file_dest= ' +fra ' *.db_recovery_file_dest_size= 4621074432*.diagnostic_dest= '/u01/app/oracle ' *.dispatchers= ' (protocol=tcp) (SERVICE=JYZHAOXDB) ' jyzhaodg2.instance_number=2jyzhaodg1.instance_number=1*.log_archive_format= '%t_%s_%r.dbf ' *.memory_target= 313286272*.open_cursors=300*.processes=150*.remote_listener= ' oradb-scan:1521 ' *.remote_login_passwordfile= ' Exclusive ' jyzhaodg2.thread=2jyzhaodg1.thread=1jyzhaodg2.undo_tablespace= ' UNDOTBS2 ' jyzhaodg1.undo_tablespace= ' UNDOTBS1 ' #adddb_unique_name = ' jyzhaodg ' log_archive_config= ' dg_config= (JYZHAO,JYZHAODG) ' #db_unique_namedb_file_ Name_convert= ' +data/jyzhao ', ' +DATA/JYZHAODG ' Log_file_name_convert= ' +data/jyzhao ', ' +data/jyzhaodg ' standby_file_management=autofal_client= ' jyzhaodg ' #tnsnames. orafal_server= ' Jyzhao ' #salehrdblog_archive_dest_3 = ' Service=jyzhao valid_for= (online_logfiles,primary_role) db_unique_name= Jyzhao '
The main focus is to pay attention to the content behind #add.
3.3 Creating a standby SPFile in ASM
Create the standby SPFile in ASM and determine the parameter file contents of each node to point to the SPFile on the disk.
Node 1:
echo $ORACLE_SIDexport ORACLE_SID=jyzhaodg1create spfile=‘+DATA/jyzhaodg/spfilejyzhaodg.ora‘ from pfile=‘/tmp/pfile_std.ora‘;-- cat initjyzhaodg1.ora SPFILE=‘+DATA/jyzhaodg/spfilejyzhaodg.ora‘
Node 2:
echo $ORACLE_SIDexport ORACLE_SID=jyzhaodg2cat initjyzhaodg2.ora SPFILE=‘+DATA/jyzhaodg/spfilejyzhaodg.ora‘
Create adump directory (all nodes)
mkdir -p /u01/app/oracle/admin/jyzhaodg/adump
3.4 Standby RAC Boots to Nomount
Node 1:
echo $ORACLE_SIDexport ORACLE_SID=jyzhaodg1startup nomount
Node 2:
echo $ORACLE_SIDexport ORACLE_SID=jyzhaodg2startup nomount
Fourth. Rman Recovery control File
Create the control file used by the standby on the primary RAC:
echo $ORACLE_SIDexport ORACLE_SID=jyzhao1SQL> alter database create standby controlfile as ‘/tmp/control01.ctlbak‘;
Restore the control file on node 1 of the standby RAC and boot to mount:
echo $ORACLE_SIDexport ORACLE_SID=jyzhaodg1restore controlfile from ‘/tmp/control01.ctlbak‘;alter database mount;crosscheck backupset;--如果是之前copy到磁盘组的备份没加载到控制文件中,可以手动catalogcatalog start with ‘+data/jyzhaodg/DATAFILE‘;--同样,如果是之前的备份集没加载到控制文件中,一样手动catalogcatalog start with ‘/u01/orabak/‘;
Check that the file paths for the standby record are as expected at this point:
Sql> select name from V$datafile; NAME--------------------------------------------------------------------------------+data/jyzhaodg/datafile/ system.256.931878537+data/jyzhaodg/datafile/sysaux.257.931878537+data/jyzhaodg/datafile/undotbs1.258.931878537 +data/jyzhaodg/datafile/users.259.931878537+data/jyzhaodg/datafile/undotbs2.264.931878827+data/jyzhaodg/ datafile/dbs_d_jingyu.268.9375151736 rows selected. Sql> Select member from V$logfile; MEMBER--------------------------------------------------------------------------------+data/jyzhaodg/onlinelog /group_2.262.931878637+fra/jyzhao/onlinelog/group_2.258.931878639+data/jyzhaodg/onlinelog/group_ 1.261.931878635+fra/jyzhao/onlinelog/group_1.257.931878637+data/jyzhaodg/onlinelog/group_3.265.931879021+fra/ jyzhao/onlinelog/group_3.259.931879023+data/jyzhaodg/onlinelog/group_4.266.931879027+fra/jyzhao/onlinelog/ group_4.260.9318790298 rows selected. Sql> select name from V$tempfile; NAME--------------------------------------------------------------------------------+data/jyzhaodg/tempfile/temp.263.931878661sql> select name from V$controlfile; NAME--------------------------------------------------------------------------------+data/jyzhaodg/controlfile /current.288.937645851+fra/jyzhaodg/controlfile/current.275.937645851
The
found that the log file has a path that does not meet the expectations, and is remediated:
Sql> Show parameter Convertname TYPE VALUE------------------------------------- ----------------------------------------Db_file_name_convert string +data/jyzhao, +data/jyzhaodglog_ File_name_convert string +data/jyzhao, +data/jyzhaodgsql> alter system set log_file_name_convert= ' + Data/jyzhao ', ' +data/jyzhaodg ', ' +fra/jyzhao ', ' +fra/jyzhaodg ' scope=spfile; sql> shutdown immediate;ora-01109:database not opendatabase dismounted. ORACLE instance shut down. Sql> Startup Mount;oracle instance started. Total System Global area 313159680 bytesfixed size 2252824 bytesvariable size 222302184 byte Sdatabase buffers 83886080 Bytesredo buffers 4718592 bytesdatabase mounted. Sql> Select member from V$logfile; MEMBER--------------------------------------------------------------------------------+data/jyzhaodg/onlinelog /group_2.262.931878637+fra/jyzhaodg/onlinelog/group_2.258.931878639+data/jyzhaodg/onlinelog/group_1.261.931878635+fra/jyzhaodg/onlinelog/group_ 1.257.931878637+data/jyzhaodg/onlinelog/group_3.265.931879021+fra/jyzhaodg/onlinelog/group_3.259.931879023+ data/jyzhaodg/onlinelog/group_4.266.931879027+fra/jyzhaodg/onlinelog/group_4.260.9318790298 rows selected.
Fifth. Rman Recovery Database
Standby RAC Node 1:
Determine the ORACLE_SID variable:
echo $ORACLE_SIDexport ORACLE_SID=jyzhaodg1
A. If you are using restore from backup set
VI restore.sh
rman target / <<EOF! > db_restore.logrun {allocate channel d1 type disk;allocate channel d2 type disk;restore database;release channel d1;release channel d2;}exit;EOF!
Nohup SH restore.sh &
B. If you are using the copy-to-disk group directly
Direct switch database to copy.
RMAN> switch database to copy;using target database control file instead of recovery catalogdatafile 1 switched to datafile copy "+DATA/jyzhaodg/datafile/0eru6m4s.dbf"datafile 2 switched to datafile copy "+DATA/jyzhaodg/datafile/0fru6m4s.dbf"datafile 3 switched to datafile copy "+DATA/jyzhaodg/datafile/0hru6meo.dbf"datafile 4 switched to datafile copy "+DATA/jyzhaodg/datafile/0iru6mg5.dbf"datafile 5 switched to datafile copy "+DATA/jyzhaodg/datafile/0jru6mg6.dbf"datafile 6 switched to datafile copy "+DATA/jyzhaodg/datafile/0gru6men.dbf"
Sixth. Prepare the library to open the log application
Confirm that the log Transport link for the primary RAC is open:
echo $ORACLE_SIDexport ORACLE_SID=jyzhao1SQL> alter system set log_archive_dest_state_3=enable;
Standby RAC Node 1 opens the log app in the Mount state:
echo $ORACLE_SIDexport ORACLE_SID=jyzhaodg1SQL> alter database recover managed standby database disconnect from session;
Seventh chapter Create standby log
To stop the standby application:
SQL> alter database recover managed standby database cancel;
To view log information:
Sql> select * from V$log; group# thread# sequence# BYTES BLOCKSIZE members ARC STATUS first_change# first_time next_change# Next_time----------------------------------------------------------------------------------------------------- ---------------------------1 1 52428800 2 YES current 2450934 03-mar-17 2.8147E+14 2 1 0 52428800 2 YES UNUSED 2440706 03-mar-17 2450934 03-mar-17 3 2 0 52428800 2 YES unuse D 2440817 03-mar-17 2450939 03-mar-17 4 2 36 52428800 512 2 YES current 2450939 03-mar-17 2.8147e+14sql> Col member for a70sql> select group#, type, ME Mber from V$logfile; group# TYPE MEMBER---------------------------------------------------------------------------------------2 online +data/jyzhaodg/onlinelog/group_2.298.937648563 2 online +fra/jyzhaodg/online log/group_2.278.937648565 1 Online +data/jyzhaodg/onlinelog/group_1.297.937648559 1 online +fra/jyzhaodg /onlinelog/group_1.279.937648561 3 online +data/jyzhaodg/onlinelog/group_3.299.937648567 3 online +FRA/j yzhaodg/onlinelog/group_3.389.937648569 4 online +data/jyzhaodg/onlinelog/group_4.300.937648573 4 online +fra/jyzhaodg/onlinelog/group_4.390.9376485738 rows selected.
According to the inspection results, add standby logfile to the database reasonably:
alter database add standby logfile thread 1 group 11 (‘+DATA‘,‘+FRA‘) size 52428800;alter database add standby logfile thread 1 group 12 (‘+DATA‘,‘+FRA‘) size 52428800;alter database add standby logfile thread 1 group 13 (‘+DATA‘,‘+FRA‘) size 52428800;alter database add standby logfile thread 2 group 21 (‘+DATA‘,‘+FRA‘) size 52428800;alter database add standby logfile thread 2 group 22 (‘+DATA‘,‘+FRA‘) size 52428800;alter database add standby logfile thread 2 group 23 (‘+DATA‘,‘+FRA‘) size 52428800;
After you add it again, view:
Sql> Select group#, type, member from V$logfile; group# TYPE MEMBER---------------------------------------------------------------------------------------2 O NLINE +data/jyzhaodg/onlinelog/group_2.298.937648563 2 ONLINE +fra/jyzhaodg/onlinelog/group_2.278.937648565 1 online +data/jyzhaodg/onlinelog/group_1.297.937648559 1 online +fra/jyzhaodg/onlinelog/group_1.279.9376485 3 online +data/jyzhaodg/onlinelog/group_3.299.937648567 3 online +fra/jyzhaodg/onlinelog/group_3.389. 937648569 4 online +data/jyzhaodg/onlinelog/group_4.300.937648573 4 online +fra/jyzhaodg/onlinelog/group _4.390.937648573 STANDBY +data/jyzhaodg/onlinelog/group_11.301.937648773 STANDBY +fra/jyzhaodg/onlinel og/group_11.391.937648775 STANDBY +data/jyzhaodg/onlinelog/group_12.302.937648777 group# TYPE MEMBER------ ---- ------- ----------------------------------------------------------------------STANDBY +fra/jyzhaodg/onlinelog/group_12.392.937648779 STANDBY +data/jyzhaodg/onlinelog/group_13.303.93764877 9 STANDBY +fra/jyzhaodg/onlinelog/group_13.393.937648781 STANDBY +data/jyzhaodg/onlinelog/group_21.304 .937648783 STANDBY +fra/jyzhaodg/onlinelog/group_21.394.937648783 STANDBY +data/jyzhaodg/onlinelog/gro up_22.305.937648785 STANDBY +fra/jyzhaodg/onlinelog/group_22.395.937648787 STANDBY +data/jyzhaodg/onli nelog/group_23.306.937648787 STANDBY +fra/jyzhaodg/onlinelog/group_23.396.93764878920 rows selected.
Continue to open the standby application, determine the recovery completion log no error message after canceling the log application, open the database, turn on ADG:
alter database recover managed standby database disconnect from session;alter database recover managed standby database cancel; alter database open;alter database recover managed standby database using current logfile disconnect from session;
To view the DG Sync Status:
Sql> SELECT Open_mode, Database_role, Switchover_status, force_logging, Dataguard_broker, GUARD_STATUS from V$ DATABASE; Open_mode database_role switchover_status for Dataguar guard_s----------------------------------------- ---------------------------------READ only with the APPLY physical STANDBY not allowed NO DISABLED nonesql> SE T lines 1000sql> select * from V$dataguard_stats;name VALUE UNIT time_computed Datum_time---------------------- ---------- ---------------------------------------------------------------- ------------------------------ ------- -----------------------------------------------------Transport Lag +00 00:09:37 Day (2) to second (0) interval 03/03/2017 10:03:20 03/03/2017 10:03:13apply Lag +00 00:09: 2 to second (0) interval 03/03/2017 10:03:20 03/0 3/2017 10:03:13apply Finish Time Day (2) to Second (3) interval 03/03/2017 10:03:20estimated startup time 40 Second 03/03/2017 10:03:20--can archive the current log on primary RAC Analog business switching archive:sql> SELECT Open_mod E, Database_role, Switchover_status, force_logging, Dataguard_broker, guard_status from V$database; Open_mode database_role switchover_status for Dataguar guard_s----------------------------------------- ---------------------------------READ WRITE PRIMARY to STANDBY NO DISABLED nonesql> al ter system archive Log current; System altered.--View DG Synchronization status on standby RAC again:sql> r 1* select * FROM V$dataguard_statsname VAL Ue UNIT time_computed Datum_time--- ----------------------------- ---------------------------------------------------------------- ------------------ ------------------------------------------------------------------------Transport lag +00 00:00:00 Day (2) to second (0) interval 03/03/2017 10:04:45 03/03/2017 10:04:44apply Lag +00 00:00:00 Day (2) to Secon d (0) interval 03/03/2017 10:04:45 03/03/2017 10:04:44apply finish time Day (2) to second (3) interval 03/03/2017 10:04:45estimated startup time Second 03/03/2017 10:04:45
At this point, the creation of the RAC Standby library in the same environment has been completed.
Eighth. Checking Resource status
We can also add RAC standby to the CRS resource:
[[email protected] ~]$ srvctl add database -d jyzhaodg -o $ORACLE_HOME -i jyzhaodg1 -n jyzhao[[email protected] ~]$ srvctl add instance -d jyzhaodg -i jyzhaodg1 -n oradb23[[email protected] ~]$ srvctl add instance -d jyzhaodg -i jyzhaodg2 -n oradb24--启动数据库[[email protected] ~]$ srvctl start database -d salehrdg--查看资源状态:[[email protected] ~]$ crsctl stat res -t
Summary: The same environment to build standby RAC, the most important thing to note is to be careful, before the operation to ensure that their operation is the correct ORACLE_SID, the path of the library must be repeatedly confirmed and correct operation.
New standby RAC Library in the same environment