Manual Standby Database under Oracle Standard Edition
Create a Manual StadBy database without Data Guard, using Standard Edition (SE)
- First you need to create the initial standby database. Here are the steps to do that:
- Put the primary database in archivelog mode, if it is not already, and add at least LOG_ARCHIVE_DEST and LOG_ARCHIVE_START to your init.ora.
- Consider also to use FORCE LOGGING to enforce all objects are archived in Redo Logs:
b. Next, create a backup of the primary database, easiest done via RMAN.
c. Now, create a standby controlfile from primary database:
d. At this point, you want to copy everything over to the standby server including datafiles, standby controlfile & config files:
e. From the standby machine, edit the standby init.ora file. Use this parameter to tell Oracle where files on the primary database will be located on the standby. For example if you had files in /ora/oracle on primary, and they are moved to /export/home/oracle on standby, this would work for you:
Note that you can use MULTIPLE pairs of values here, if you have files in different locations.
Now you're also likely to have a new location for your archived redo log files, and that's where the parameter LOG_FILE_NAME_CONVERT comes into play.
Important note, neither of these two parameters work for the ONLINE redolog files. Those you will have to rename yourself. If you do not do so, you will get an error at the time you try to SWITCHOVER your standby database. Such errors are easily remedied by running that command.
f. Now, it's time to start the standby instance and mount it.
g. Almost there. Lastly, we need to recover the standby database using the AUTO option. Note that you should build a simple shell script to startup sqlplus and run these commands. A name like manual_standby.sh would work well. You can then run this periodically, say every half hour, from cron to apply any new archived redolog files that have showed up via move_standby.sh below.
h. Test your standby database. You do this by starting up in read-only mode.
i. Don't forget to put it back in standby mode so that when your manual_standby.sh script runs from cron, it won't return errors.
2. What scripts should run via cron on the primary and standby database?
As we mentioned earlier, a script called manual_standby.sh would work well on the standby database. This script applies new archived redologs that have arrived from the production system. Run it every half hour and see how that works for you. The database must be mounted in standby mode (not read-only) or this script will fail.
You'll also want a script on the production server. Name it move_standby.sh, and run it every thirty minutes to start with. This can use rsync to move redolog files from production to standby. A command like this would work:
Note that you may want to adjust options to ssh to your needs. In addition, this presumes you have ssh autologin configured. Read up on the ssh-keygen command. The .ssh directory contains a public key, which is shipped over to the standby machine, and put in the "authorized_keys" file. ssh will then login without a password. Rsync uses ssh as the transport mechanism, so it also executes without a password. Rsync is very smart and only copies blocks and pieces of files that are different, so it is very fast, and also does checksums to guarantee consistency.
3. Is the standby database behind the production database?
Yes, keep in mind we are creating a manual standby database. The standby database will tend to be behind production by about half the size of a redolog file. So if those files are 100M, and you generate 100M of transactions in 30 minutes, then on average standby will be fifteen minutes behind.
4. What types of changes and statements on production will not be automatically applied to standby?
In database parlance, any PHYSICAL changes to the db, plus any commands, issues with the NOLOGGING option. Physical changes include creation of new tablespaces, adding new datafiles, renaming datafiles, autosizing of datafiles, altering redolog files, altering controlfiles and so on. In addition, primary database processes or commands using the UNRECOVERABLE option will not be propagated to the standby database.
There are specific and detailed instructions for making some of these physical changes on the standby db manually, however in many cases recreating the entire standby database per the instructions above, might be the best option.
5. How can we verify that the standby database is up to date?
If you already have the manual_standby.sh script running from cron, disable it.
Then login with sqlplus and issue:
SQL> alter database open read only;
Now that you have the database open read-only, run whatever SQL commands you want to in order to verify some change which you know about on production. When you are done, shutdown, and startup in standby mode again. Don't forget to reenable manual_standby.sh in the crontab.
6. What happens if the standby system restarts?
You could have it automatically start the standby database. In that case, be sure to just check the logfiles. If you want to do it manually in those instances, fire up sqlplus and then issue:
7. What kind of messages can I expect to see in the standby alert.log?
The alert.log is going to have a lot of extra messages since we are repeatedly trying to RECOVER when there may or may not be new transaction logs. When it does this it will say, "looking for archived logfile 1_356.dbf, not found". On the other hand, if it finds it, it will say that it is applying it. You can use unix commands "grep" and "less" to scan through the alert.log file quickly.
8. What other scripts should be put in place?
a. a script to cleanup old archived redo logs on primary.
b. a script to cleanup old archived redo logs on standby
c. a script to rotate and archive the alert.log file when it gets large
d. a script to watch the alert.log file for ORA-xxxxx errors and report them to nagios if it finds any (on both primary and standby)
e. a script to login (via ssh autologin) and check what the latest archived redolog file is, and then also login to the standby and check the alert.log file to verify that those transactions have been applied.
9. How do we switchover in the event of a failure of the primary?
Switchover can be done with a script, however I recommend with our manual standby database that you (a) monitor for emergencies on production and (b) manually perform the failover if necessary. This will avoid false positives. Also, it allows you to ship additional redolog data if you have it available from production.
The switchover is a two-step process.
a. Apply remaining redo as we have done before with commands in manual_standby.sh.
b. Startup the database normally, in a read-write mode.
10. What network changes need to happen to failover?
The listener.ora file should be already configured. You can use the same config as primary with a different IP, or you can give this db a different tnsname. For instance, you could call primary SEANA and standby SEANB. Then in your application server configs, when you failover, your database connection configurations need to be updated to point to SEANB. The app servers will probably also need to be restarted at this point.
11. Why can't the primary ship redologs and synchronous changes?
Basically they call it a manual standby database for a reason. DataGuard supports options that look like the following:
Again, these are not available in Oracle SE.
12. Once we've failed over, how do we switch back to the primary?
Switching back to the primary database involves these steps:
a. Follow the steps in item 1 above to create a standby database on what was the primary system.
b. If you want to be perfectly clean syncing, do the following:
c. Copy over the last archived redolog files
d. Apply them and switchover as described in item 8 above.
13. Are there special init.ora parameters? What makes our standby database special?
The main two things that make it a standby database are:
a. The standby control file (created from primary)
- alter database create standby controlfile as '/my/path/to/standby.ctl
b. The process of mounting as a standby database
- startup nomount pfile=standby.ora
- alter database mount standby database;
There are of course some init.ora parameters which are special for the standby database as well:
So if you do a "shutdown immediate" on the standby, you would start again with:
The StandBy DB must be licensed as seperate database when used for production.
"Standby – In this type of recovery, a copy of the primary database is maintained on a separate server at all times. These systems are configured for disaster recovery purposes. If the primary database fails, the standby database is activated to act as the new primary database. In this environment, both the primary and the standby databases must be fully licensed."
Based on work By Sean Hull, see: DataBaseJournal