The role of Data Gurad is not much said. Here, we will talk about the building steps of physical standby.
There are roughly three ways to create a standby Database
Method 1: Use rman to generate standby. (use rman's duplice method for direct creation without first backing up)
Method 2: It is generated using rman restore. (Use rman to back up the master database, and then create it using rman restore)
Method 3: generate with cp (after the master database is closed, copy the control file, password file, and data file to the location of the slave database)
I mainly use duplice here. I don't need to talk about the advantages. Suppose T is on your database, which method will you choose?
The Oracle test version is 11 GB;
1. Set the environment variables for the master and slave databases and create related directories.
Master database:
Su-oracle
-- Archive log storage directory
-- Put the example in/u01/app/oracle/archivelog/xcldb
Mkdir-p $ ORACLE_BASE/archivelog/$ ORACLE_SID
Note the following two parameters for environment variables:
ORACLE_SID = xcldb
ORACLE_UNQNAME = xcldb
Slave database:
Su-oracle
-- Generate related directories. Pay attention to the permissions. For the other 11 GB, there are several directories for 10 Gb.
Mkdir-p $ ORACLE_BASE/admin/$ ORACLE_SID/{adump, bdump, cdump, dpdump, udump, pfile}
-- Database directory
Mkdir-p $ ORACLE_BASE/oradata/$ ORACLE_SID
-- Flashback
Mkdir-p $ ORACLE_BASE/flash_recovery_area/$ ORACLE_SID
-- Archive log storage directory
Mkdir-p $ ORACLE_BASE/archivelog/$ ORACLE_SID
Note the following two parameters for environment variables:
ORACLE_SID = xcldbdg
ORACLE_UNQNAME = xcldbdg
2. Set the database to archive
-- View the current mode
Archive log list
-- Set the path for archiving logs. Multiple identical logs can be generated and saved in multiple locations to prevent loss.
-- If this parameter is not set, it is set to $ ORACLE_HOME/dbs by default.
Alter system set log_archive_dest_1 = 'location =/u01/app/oracle/archivelog/xcldb ';
Shutdown immediate
Startup mount
Alter database archivelog;
Archive log list;
3. Set force logging to force log Mode
Alter database force logging
Select force_logging from v $ database;
-- Cancel this mode: alter database no force logging;
-- Manually switch logs to generate archived logs
Alter system switch logfile -- three executions
Select name from v $ archived_log;
-- View existing Log Files
Select * from v $ logfile;
4. Create a Standby redo log
Recommended formula for creating quantity:
Standby redo log group formula> = (number of log groups per instance + 1) * number of instances
(Maximum number of logfiles for each thread + 1) * maximum number of threads
-- Find the largest group #, because group # cannot be repeated.
Select max (group #) from v $ log;
-- The group number and file size can be viewed in these two queries. The default value of 11g is 52428800.
Select group #, bytes from v $ LOG;
Select group #, bytes from v $ STANDBY_LOG;
-- Note that the size is the same. I'm a test and I don't care about the size.
Alter database add standby logfile thread 1 group 11'/u01/app/oracle/oradata/xcldb/redo11.log 'size 50 m;
Alter database add standby logfile thread 1 group 12'/u01/app/oracle/oradata/xcldb/redo12.log 'size 50 m;
Alter database add standby logfile thread 1 group 13 '/u01/app/oracle/oradata/xcldb/redo13.log' size 50 m;
Alter database add standby logfile thread 1 group 14'/u01/app/oracle/oradata/xcldb/redo14.log 'size 50 m;
Note:
When adding standby logfile, if thread 1 is a single instance database, but it is a RAC database,
Add related Standby logs for each instance;
In addition, you can use the following command to create an OMF-managed system:
Alter database add standby logfile thread 1 group 11 size 500 m;
Verification results:
Col member format a50
Select group #, type, member from v $ logfile where type = 'standby ';
References:
Important configuration parameters of Oracle Data Guard
Configure Oracle 11g Data Guard based on the same host
Explore Oracle 11g elastic uard
Oracle Data Guard (RAC + DG) archive deletion policies and scripts
Role conversion for Oracle Data Guard
FAL gap in Oracle Data Guard logs
Oracle 11g Data Guard Error 16143 Heartbeat failed to connect to standby