Assumptions
- You have two servers (physical or VMs) with an operating system and Oracle installed on them. In this case I've used Oracle Linux 7.6 and Oracle Database 19c.
- The primary server (ol7-19-dg1.locadomain) has a running instance.
- The standby server (ol7-19-dg2.locadomain) has a software only installation.
- There is nothing blocking communication between the machines over the listener ports. If you are using the default 1521 port, node 1 should be able to communicate to node 2 on 1521 and node 2 should be able communicate with node 1 on 1521. Check network and local firewalls are not blocking the communication.
Primary Server Setup
Logging
Check that the primary database is in archivelog mode.
select log_mode from v$database; LOG_MODE ------------ NOARCHIVELOG SQL>
If it is noarchivelog mode, switch is to archivelog mode.
shutdown immediate; startup mount; alter database archivelog; alter database open;
Enabled forced logging by issuing the following command.
alter database force logging; -- Make sure at least one logfile is present. alter system switch logfile;
Create standby redo logs on the primary database (in case of switchovers). The standby redo logs should be at least as big as the largest online redo log and there should be one extra group per thread compared the online redo logs. In my case, the following standby redo logs must be created on both servers.
-- If Oracle Managed Files (OMF) is used. alter database add standby logfile thread 1 group 10 size 50m; alter database add standby logfile thread 1 group 11 size 50m; alter database add standby logfile thread 1 group 12 size 50m; alter database add standby logfile thread 1 group 13 size 50m; -- If Oracle Managed Files (OMF) is not used. alter database add standby logfile thread 1 group 10 ('/u01/oradata/cdb1/standby_redo01.log') size 50m; alter database add standby logfile thread 1 group 11 ('/u01/oradata/cdb1/standby_redo02.log') size 50m; alter database add standby logfile thread 1 group 12 ('/u01/oradata/cdb1/standby_redo03.log') size 50m; alter database add standby logfile thread 1 group 13 ('/u01/oradata/cdb1/standby_redo04.log') size 50m;
If you want to use flashback database, enable it on the primary now, so it will be enabled on the standby also. It's very useful as you will see below.
alter database flashback on;
Initialization Parameters
Check the setting for the DB_NAME
and DB_UNIQUE_NAME
parameters. In this case they are both set to "cdb1" on the primary database.
SQL> show parameter db_name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_name string cdb1 SQL> show parameter db_unique_name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_unique_name string cdb1 SQL>
The DB_NAME
of the standby database will be the same as that of the primary, but it must have a different DB_UNIQUE_NAME
value. For this example, the standby database will have the value "cdb1_stby".
Make sure the STANDBY_FILE_MANAGEMENT
parameter is set.
alter system set standby_file_management=auto;
Service Setup
Entries for the primary and standby databases are needed in the "$ORACLE_HOME/network/admin/tnsnames.ora" files on both servers. You can create these using the Network Configuration Utility (netca) or manually. The following entries were used during this setup. Notice the use of the SID
, rather than the SERVICE_NAME
in the entries. This is important as the broker will need to connect to the databases when they are down, so the services will not be present.
cdb1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = ol7-19-dg1)(PORT = 1521)) ) (CONNECT_DATA = (SID = cdb1) ) ) cdb1_stby = (DESCRIPTION =