Creating Logical Standby Database
Page 1 of of 16
1
INTRODUCTION INTRODUCTION ........................... ......................................... ............................ ............................ ............................ ............................ ............................ ............................ ............................ ............................ ..................2 ....2
2
ASSUMPTIONS ............................ .......................................... ............................ ............................ ............................ ............................ ............................ ............................ ............................ ........................... ....................3 .......3
3
CREATING LOGICAL STANDBY FROM COLD BACKUP............. BACKUP........................... ............................ ............................ ............................ ............................ ................3 ..3
4
5
6
3.1
PREPARING
3.2
CREATING LOGICAL STANDBY DATABASE .......................... ........................................ ............................ ............................ ............................ ............................ ............................ ................5 ..5
THE
PRIMARY DATABASE .......................... ........................................ ............................ ............................ ............................ ............................ ............................ .......................3 .........3
CREATING LOGICAL STANDBY FROM HOT BACKUP ........................... ......................................... ............................ ............................ ............................ ..................8 ....8 4.1
PREPARING
4.2
CREATING LOGICAL STANDBY DATABASE .......................... ........................................ ............................ ............................ ............................ ............................ ............................ ................9 ..9
THE
PRIMARY DATABASE .......................... ........................................ ............................ ............................ ............................ ............................ ............................ .......................8 .........8
VERIFY LOGICAL STANDBY DATABASE................... DATABASE................................. ............................ ............................ ............................ ............................ ............................ .....................14 .......14 5.1
IDENTIFY
5.2
ARCHIVING THE CURRENT LOG ............................ .......................................... ............................ ............................ ............................ ............................ ............................ ............................ ................14 ..14
5.3
VERIFY THAT THE NEW ARCHIVED LOGS ARE RECEIVED ............................ .......................................... ............................ ........................... ........................... ...................14 .....14
5.4
VERIFY THAT THE NEW ARCHIVED LOGS ARE APPLIED ............................ .......................................... ............................ ............................ ............................ .....................14 .......14
5.5
CHECK THE OVERALL PROCESS OF LOG APPLY SERVICES ............................ .......................................... ............................ ............................ ............................ ................14 ..14
THE
EXISTING ARCHIVED
REDO LOGS ........................... ......................................... ............................ ............................ ........................... ........................... ...................14 .....14
TROUBLESHOOTING TROUBLESHOOTING ........................... ......................................... ............................ ............................ ............................ ............................ ............................ ............................ ............................ .....................15 .......15 6.1
ERROR ORA-01152 AND ORA-01110 WHEN STARTING THE LOGICAL STANDBY DATABASE ...............................15
6.2
WHEN LOGS ARE NOT GETTING SHIFTED TO THE LOGICAL STANDBY LOCATION............................. ........................................... ....................15 ......15
6.3
WHEN LOGS ARE NOT GETTING APPLIED ........................... ......................................... ............................ ............................ ............................ ............................ ................... ..... ...........15
6.4
IF LOGS ARE NOT GETTING APPLIED AFTER SHUTTING DOWN AND RESTARTING THE LOGICAL
STANDBY
DATABASE .......................... ........................................ ............................ ............................ ............................ ............................ ............................ ............................ ............................ ............................ ............................ .....................16 .......16 7
CONCLUSION CONCLUSION ........................... ......................................... ............................ ............................ ............................ ............................ ............................ ............................ ............................ ............................ .....................16 .......16
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Creating Logical Standby Database
Page 2 of of 16
Creating Logical Standby Database (using cold backup and hot backup) 1
INTRODUCTION
A Data Guard configuration can consists of one production database and up to nine standby databases. Standby databases are the most effective disaster recovery solution for an Oracle database. A standby database can also be used to remedy problems caused by user errors, data corruption, and other operational difficulties. A standby database can be either a physical standby database or a logical standby database: •
•
Physical standby database - Provides a physically identical copy of the primary database, with ondisk database structures that are identical to the primary database on a block-for-block basis. Logical standby database - Contains the same logical information as the production database, although the physical organization and structure of the data can be different. The redo logs received from the primary database are transformed into SQL statements and then applied into the database.
This allows users to access a logical standby database for queries and reporting purposes at any time. Thus, a logical standby database can be used concurrently for data protection and reporting. This white paper lists down the steps which can be followed to create a logical standby database (by taking either a cold backup or a hot backup). Following all of these steps in the order as written down should result in a clean creation of Logical Standby Database.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Creating Logical Standby Database
2
Page 3 of of 16
ASSUMPTIONS
This white paper assumes that the Primary database is created and is already running. It also assumes that the initialization parameters are specified in server parameter file (SPFILE).
3
Creating Logical Standby from Cold Backup 3.1 Preparing the Primary Database Before creating the logical database, some tasks will have to be performed and the primary database will have to be prepared for the Data Guard setup. The steps for preparing the Primary Database for Logical Standby Database creation are given below: 1. Enable Forced Logging for the Primary Database mode using the following SQL SQL> ALTER DATABASE FORCE LOGGING;
2. Bring the Primary Database Database in ARCHIVELOG mode and set LOG_PARALLELISM. Steps: Set the init.ora parameters – LOG_ARCHIVE_START=TRUE LOG_PARALLELISM=1 SQL> SQL> SQL> SQL>
SHUTDOWN IMMEDIATE STARTUP PFILE=
CREATE SPFILE FROM PFILE=’’; ALTER SYSTEM SET LOG_ARCHIVE_DEST_1=’LOCATION=/opt/oracle/oradata/MYORA MANDATORY’ SCOPE=BOTH;
3. Check for unsupported Data type and Tables Some of the database objects like LONG, user-defined types etc. are not supported in logical standby databases. Use the following Query to check if any of these unsupported data types exists in the primary database. To get the list of schema and table names those are not supported by logical standby databaseSQL> 2>
SELECT DISTINCT OWNER, TABLENAME FROM DBA_LOGSTDBY_UNSUPPORTED ORDER BY OWNER, TABLE_NAME;
To view the column name and data type for one of the tables listed in the previous querySQL>
SELECT COLUMN_NAME, DATA_TYPE FROM DBA_LOGSTDBY_UNSUPPORTED
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Creating Logical Standby Database
Page 4 of of 16
Oracle Corporation recommends that there should be a primary key or a unique index to tables on the primary database, whenever appropriate and possible, to ensure that SQL apply operations can efficiently apply data updates to the logical standby database. Use the following query to display a list of tables that SQL apply operations might not be able to uniquely identify:
SQL> SELECT OWNER, TABLE_NAME,BAD_COLUMN FROM DBA_LOGSTDBY_NOT_UNIQUE 2> WHERE TABLE_NAME NOT IN 3> (SELECT TABLE_NAME FROM DBA_LOGSTDBY_UNSUPPORTED);
5. Enable Supplemental Logging Supplemental logging must be enabled on the primary database before creating the logical standby database. Because Oracle only logs the columns that were modified, this is not always sufficient to uniquely identify the row that changed and additional (supplemental) information must be put into the redo log. The supplemental information that is added to the redo logs helps log apply services to correctly identify and maintain tables in the logical standby database. To check whether supplemental logging is enabled: SQL> SELECT SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI 2> FROM V$DATABASE; SUP SUP --- --NO NO
The NO values indicate that supplemental logging is not enabled on the primary database. To enable supplemental Logging: SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY, UNIQUE INDEX) 2> COLUMNS;
Switch to a new log file to ensure that the redo logs do not contain both supplemental log data and nonsupplemental log data. SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;
Verify Supplemental Logging SQL> SELECT SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI 2> FROM V$DATABASE;
SUP SUP --- ---YES YES
6. Create an Alternate Tablespace
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Creating Logical Standby Database
Page 5 of of 16
SQL> EXECUTE DBMS_LOGMNR_D.SET_TABLESPACE('logmnrts');
3.2 Creating Logical Standby Database This section lists down the tasks that need to be performed to create the Logical Standby database from a cold backup. 1. Take a cold backup backup of the Primary database database To take a cold backup of the Primary database, first • • •
Find out the location of all the data files and the log files. Shutdown the database using shutdown immediate/normal/transactional im mediate/normal/transactional Copy all the data files and log files to the backup location. Cp /opt/oracle/oradata/MYORA/system01.dbf /backup/MYORA/cold/
2. Startup the the Database and create a backup copy of the Control file. SQL> STARTUP MOUNT SQL> ALTER DATABASE BACKUP CONTROLFILE TO 2> /backup/MYORA/cold/MYORA_backup.ctl;
3. Build the LogMiner dictionary. On the primary database, enable restricted session mode to reduce the likelihood of users or applications performing any DML or DDL operations. SQL> SQL> SQL> SQL>
ALTER SYSTEM ENABLE RESTRICTED SESSION; ALTER DATABASE OPEN; EXECUTE DBMS_LOGSTDBY.BUILD; ALTER SYSTEM DISABLE RESTRICTED SESSION;
4. Starting point for building the logical standby standby database database To obtain a starting point for building the logical standby database, query the V$ARCHIVED_LOG view, identify the latest archived redo log, and record its name for use later in the creation process. The query below will give the latest archive redo log. SQL> SQL> 2> 3>
ALTER SYSTEM ARCHIVE LOG CURRENT; SELECT NAME FROM V$ARCHIVED_LOG WHERE (SEQUENCE#=(SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG WHERE DICTIONARY_BEGIN = 'YES' AND STANDBY_DEST= 'NO'));
NAME ----------------------------------------/opt/oracle/ARC/MYORA/arc0004.001
Note: Remember to record the name of the archi ved redo log for use later in the creation process.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Creating Logical Standby Database
Page 6 of of 16
Use an operating system copy utility to copy the following binary files from the primary database site to the standby site: •
Backup data files and redo logs created in Step 1 above
•
Backup of control files created in Step 2 of section
•
Latest archived redo log that was identified in step 4 above
•
Database initialization parameter file created in step 6.
Note: While copying the control files make sure to rename it according to the parameter i n init.ora file. 7. Set the init.ora Parameters DB_NAME='MYORA' INSTANCE_NAME='MYORA_C' LOG_ARCHIVE_DEST_1='LOCATION=/OPT/ORACLE/ARC/MYORA MANDATORY' LOG_ARCHIVE_DEST_STATE_1=ENABLE LOG_ARCHIVE_FORMAT='MYORA_%T_%S.ARC' REMOTE_ARCHIVE_ENABLE=RECEIVE LOG_ARCHIVE_START=TRUE LOG_PARALLELISM=1 PARALLEL_MAX_SERVERS=9 STANDBY_FILE_MANAGEMENT='AUTO' STANDBY_ARCHIVE_DEST='/OPT/ORACLE/ARC/MYORA/STDBY'
# The following parameter is required only if the primary and standby databases # are located on the same system. LOCK_NAME_SPACE=MYORA_C
8. Configure the Listener for Both the Primary and Standby Databases and Restart/reload Restart/reload the listener(s) 9. Startup the Logical Standby Database SQL> STARTUP MOUNT PFILE=initMYORA_C.ora;
10. Rename the Data files on the Logical Standby Database Database On the Logical standby database rename all the data files and the redo logs to update the control file. Following is an example of renaming files. SQL> ALTER DATABASE RENAME FILE '/opt/oracle/oradata/MYORA/system01.dbf' 2> TO '/opt/oracle/oradata/MYORA_C/system01.dbf';
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Creating Logical Standby Database
Page 7 of of 16
To prevent users from updating objects in the logical standby database, turn on the database guard by issuing the following SQL statements on the standby database: SQL> ALTER DATABASE GUARD ALL; SQL> ALTER DATABASE OPEN RESETLOGS;
12. Reset the Database Name of the Logical Standby Database Run the Oracle DBNEWID (nid) utility to change the database name of the logical standby database. This will change the database name in the control file. Till now the dbname in the control file is primary db name.
SQL> SHUTDOWN IMMEDIATE; SQL> STARTUP MOUNT PFILE=’’ SQL> EXIT $> export ORACLE_SID=MYORA_C password> password> DBNAME=MYORA_C $> nid TARGET=SYS/<
Modify the init.ora file and set parameter DB_NAME=MYORA_C and if password file is used the delete and recreate the password file. SQL> SHUTDOWN IMMEDIATE;
13. Create a server parameter file for the standby database SQL> CREATE SPFILE FROM PFILE=;
14. Restart the Logical Standby Database SQL> STARTUP MOUNT; SQL> ALTER DATABASE OPEN RESETLOGS;
15. Create a New Temporary File for the Logical Standby Database The temporary files are not included as a part of the closed backup operation so the temporary file will have to be recreated manually. To create a Temporary file: SQL> ALTER TABLESPACE TEMP ADD TEMPFILE
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Creating Logical Standby Database
Page 8 of of 16
a. Register the most recently archived redo log with log apply services. services. Register the archived redo log that was identified in step 4 of Section 3.2 The following example specifies the file name and location of the most recently archived redo log: SQL> ALTER DATABASE REGISTER LOGICAL LOGFILE 2> '/opt/oracle/ARC/MYORA_C/arc0004.001';
b. Start applying redo logs to the logical standby database. Specify the following SQL statement to begin applying redo logs to the logical standby database. SQL> ALTER DATABASE START LOGICAL STANDBY APPLY INITIAL;
Note: The INITIAL keyword has to be used only for the first time. To apply redo logs there after, the following statements should be used. SQL> ALTER DATABASE STOP LOGICAL STANDBY APPLY; SQL> ALTER DATABASE START LOGICAL STANDBY APPLY;
17. Enable Archiving in Logical standby database. This step has to be performed in the Primary Database to enable archiving to the Logical Standby database. Use the following statements to start archiving. SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_3='SERVICE=payroll3 lgwr NO AFFIRM' 2 > SCOPE=BOTH; SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_3=ENABLE SCOPE=BOTH;
18. Start Remote archiving To start remote archiving either of the following statements can be used– SQL> ALTER SYSTEM ARCHIVE LOG CURRENT; SQL> ALTER SYSTEM SWITCH LOGFILE;
The configuration of Logical database is complete. The logs created in the primary database should be shifted automatically to the standby location and get applied. See Section 5 for steps to verify whether the logs are getting shifted and applied.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Creating Logical Standby Database
Page 9 of of 16
SQL> ALTER SYSTEM SET RESOURCE_MANAGER_PLAN=SYSTEM_PLAN SCOPE=BOTH; SQL> SHUTDOWN IMMEDIATE SQL> STARTUP
2. Create an Alternate Tablespace If a switchover operation between the primary database and a logical standby database is expected in future , an alternate tablespace in the primary database should be created and the logical standby system tables are moved to that separate tablespace. SQL> 2> 3> SQL>
CREATE TABLESPACE logmnrts DATAFILE '/opt/oracle/oradata/MRORA/logmnrts.dbf' SIZE 25M AUTOEXTEND ON MAXSIZE UNLIMITED; EXECUTE DBMS_LOGMNR_D.SET_TABLESPACE('logmnrts');
4.2 Creating Logical Standby Database This section lists down the tasks that need to be performed to create the Logical Standby database from a Hot Backup. This section lists down the tasks that need to be performed to create the Logical Standby database. 1. Take a hot backup of the Primary database To take a hot backup of o f the Primary database, first a. Find out the the list of tablespaces in the database and the data files belonging to each tablespace. b. Bring a tablespace tablespace to backup mode, copy copy the data file of that tablespace using an OS command, bring back the tablespace to online. An Example of taking a backup of the SYSTEM tablespace SQL> ALTER TABLESPACE SYSTEM BEGIN BACKUP; ! cp /opt/oracle/oradata/MYORA/system01.dbf /backup/MYORA/HOT/ SQL> ALTER TABLESPACE SYSTEM END BACKUP;
c.
Preform step (b) (b) for all the tablespaces in the database.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Creating Logical Standby Database
Page 10 of 16
First switch log file to create the archived log and then query from V$ARCHIVED_LOG SQL> ALTER SYSTEM ARCHIVE LOG CURRENT; SQL> SELECT NAME FROM V$ARCHIVED_LOG WHERE 2 >(SEQUENCE#=(SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG 3 > WHERE DICTIONARY_BEGIN = 'YES' AND STANDBY_DEST='NO')); NAME ----------------------------------------------------------/opt/oracle/ARC/MYORA/MYORA_0001_0000000005.arc SQL> SELECT MAX(FIRST_CHANGE#) FROM V$ARCHIVED_LOG 2> WHERE DICTIONARY_BEGIN='YES'; MAX(FIRST_CHANGE#) -----------------2856516
Note: Remember to record the name of the archi ved redo log for use later in the creation process. 6. Bring the database back to normal SQL> ALTER SYSTEM UNQUIESCE; SQL> ALTER SYSTEM SWITCH LOGFILE;
7. Create the parameter file from spfile in the Primary database. The pfile created will be used to create the pfile of the standby database. CREATE PFILE=’/backup/MYORA/HOT/Primary_init.ora’ FROM SPFILE;
8. Copy Files from the Primary Database Location to the Standby Location Use an operating system copy utility to copy the following binary files from the primary database site to the standby site:
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Creating Logical Standby Database
Page 11 of 16
DB_NAME='MYORA' INSTANCE_NAME='MYORA_H' LOG_ARCHIVE_DEST_1='LOCATION=/OPT/ORACLE/ARC/MYORA MANDATORY' LOG_ARCHIVE_DEST_STATE_1=ENABLE LOG_ARCHIVE_FORMAT='MYORA_%T_%S.ARC' REMOTE_ARCHIVE_ENABLE=RECEIVE LOG_ARCHIVE_START=TRUE LOG_PARALLELISM=1 PARALLEL_MAX_SERVERS=9 STANDBY_FILE_MANAGEMENT='AUTO' STANDBY_ARCHIVE_DEST='/OPT/ORACLE/ARC/MYORA/STDBY'
# The following parameter is required only if the primary and standby databases # are located on the same system. LOCK_NAME_SPACE=MYORA_H
10. Configure the Listener for Both the Primary and Standby Databases and Restart/reload the listener(s) 19. Clear Logfiles Because the online logs were not copied from the primary system the redo logs will have to be cleared. To clear redo logs use the following statement for all the groups SQL> ALTER DATABASE CLEAR LOGFILE GROUP 1; SQL> ALTER DATABASE CLEAR LOGFILE GROUP 2;
11. Recover the Logical Standby Database until SCN recorded at step 5 above. Use the command below to recover the database –
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Creating Logical Standby Database
Page 12 of 16
14. Reset the Database Name of the Logical Standby Database Run the Oracle DBNEWID (nid) utility to change the database name of the logical standby database. This will change the database name in the control file. Till now the dbname in the control file is primary db name. SQL> SHUTDOWN IMMEDIATE; SQL> STARTUP MOUNT PFILE=’’ SQL> EXIT $> export ORACLE_SID=MYORA_H password> password> DBNAME=MYORA_H $> nid TARGET=SYS/<
Modify the init.ora file and set parameter DB_NAME=MYORA_H and if password file is used the delete and recreate the password file. SQL> SHUTDOWN IMMEDIATE;
15. Create a server parameter file for the standby database SQL> CREATE SPFILE FROM PFILE=;
16. Restart the Logical Standby Database SQL> STARTUP MOUNT; SQL> ALTER DATABASE OPEN RESETLOGS;
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Creating Logical Standby Database
Page 13 of 16
a. Register the most most recently recently archived archived redo redo log with log apply services. services. Register the archived redo log that was identified in step 5 of Section 4.2 The following example specifies the filename and location of the most recently archived redo log: SQL> ALTER DATABASE REGISTER LOGICAL LOGFILE 2> '/opt/oracle/ARC/MYORA_H/MYORA_0001_0000000005.arc’;
b. Start applying redo logs to the logical standby database. database. Specify the following SQL statement to begin applying redo logs to the logical standby database using the SCN number identified in Step 5 Section 4.2. SQL> ALTER DATABASE START LOGICAL STANDBY APPLY INITIAL 2856516;
Note: The INITIAL keyword has to be used only for the fi rst time. To apply redo logs there after, the following statements should be used . SQL> ALTER DATABASE STOP LOGICAL STANDBY APPLY; SQL> ALTER DATABASE START LOGICAL STANDBY APPLY;
19. Enable Archiving in Logical standby database This step has to be performed in the Primary Database to enable archiving to the Logical Standby database. Use the following statements to start archiving. a rchiving. SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_3='SERVICE=payroll3 lgwr NO AFFIRM'
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Creating Logical Standby Database
5
Page 14 of 16
Verify Logical Standby Database After the creating the Logical Standby Database, it will have to be verified whether the archived logs are being applied or not. Following are the procedures which can be used to verify the standby database:
5.1 Identify the Existing Archived redo logs On the standby database, query the V$ARCHIVED_LOG view to identify existing archived redo logs. For example SQL> ALTER SESSION SET NLS_DATE_FORMAT=’DD-MM-YY HH24:MI:SS’; SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME 2> FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#; SEQUENCE# FIRST_TIME NEXT_TIME ---------- ------------------ -----------------8 15-AUG-04 17:50:45 15-AUG-04 17:50:53 9 15-AUG-04 17:50:53 15-AUG-04 17:50:58 10 15-AUG-04 17:50:58 15-AUG-04 17:51:03
5.2 Archiving the current log On the primary database, archive the current log using the following SQL statement: SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;
5.3 Verify that the new archived logs are received
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Creating Logical Standby Database
Page 15 of 16
APPLIED_SCN NEWEST_SCN ----------- ---------2858715 2858715
When the numbers in the APPLIED_SCN and NEWEST_SCN columns are equal, it means that all of the available data in the redo log was applied.
6
Troubleshooting 6.1 Error ORA-01152 and ORA-01110 when starting the Logical Logical Standby Standby Database If the above errors are encountered when starting the Logical Standby Database during the Step9 of Section 3.2 then it might be that the backup of control file in step of Section 3.2 is taken after opening the primary database or not immediately after taking the cold backup.
6.2 When Logs are not getting shifted to the Logical Standby Location Some of the causes for logs not getting shifted to the logical standby location might be – • • • •
Listener not running. Check the listener l istener and start the listener. Tnsnames not set properly. If the databases are on two different locations then the network connection might be lost Check the alert log for more information.
6.3 When Logs are not getting applied •
Check whether the logs are getting shifted or not.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Creating Logical Standby Database
Page 16 of 16
SQL> SELECT THREAD#, SEQUENCE#, FILE_NAME FROM DBA_LOGSTDBY_LOG L 2> WHERE NEXT_CHANGE# NOT IN 3> (SELECT FIRST_CHANGE# FROM DBA_LOGSTDBY_LOG WHERE L.THREAD# = THREAD#) 4> ORDER BY THREAD#,SEQUENCE#;
If there is any archive gap then copy the missing logs to the logical standby location and register them using the ALTER DATABASE REGISTER LOGICAL LOGFILE statement on the logical standby database and can restart log apply services .
6.4 If logs are not getting applied after shutting down and restarting the Logical Standby Database When a standby database is restarted the log apply services don’t start automatically. It has to be started manually. If even after starting the log apply services manually the logs are not getting applied then find out the last archived log which has been applied and register the next archived log using ‘ ALTER DATABASE REGISTER LOGICAL LOGFILE’ statement on the logical standby database and start log apply services again.
7
Conclusion The success in creating a Logical Standby Database depends a lot on how the tasks are executed. Whether the initialization parameters are set properly. B efore starting the creation of Logical standby Database make sure that all the Initialization Parameters are set correctly. Are all the steps followed in the correct order and whether the appropriate parameters are used?