Professional Documents
Culture Documents
Manual Standby Database Under Oracle Standard Edition PDF
Manual Standby Database Under Oracle Standard Edition PDF
SQL> alter tablespace EXAMPLE begin backup;SQL> !cp example01.dbf /my/db/backup/SQL> !cp example02.dbf /my/db/backup/SQL> !cp example03.dbf /my
In the above example, the '!'symbol tells sqlplus to run the c ommand from the shell, so we're using the Unix'c p' c ommand to make copies of those files (which
are now frozen in bac kupmode) in another location.
c. Now, create a standby controlfilefrom primary database:
ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/oracle/dbs/stbycf.ctl';
d. At this point, you want to c opyeverything over to the standby server including datafiles, standby controlfile& config files:
$ scp /my/db/backup/*.dbf oracle@192.168.0.10:/export/home/oracle/
e. From the standby mac hine, editthe standby init.ora file. Use this parameter to tell Orac le where files onthe primary database will be loc ated on the
standby. For example if you hadfiles in /ora/oracle on primary, and they are moved to /export/home/oracle onstandby, this would work for you:
DB_FILE_NAME_CONVERT='/ora/oracle','/export/home/oracle'
Note that you can use MULTIPLEpairs of values here, if you have files in different locations. Alternatively,you can startup and mount the standby database
then issue:
SQL> alter database rename file '/ora/oracle/myfile.dbf' to /export/home/oracle/myfile.dbf' as an example.
Now you're also likely to have anew location for your arc hived redo log files, and that's where the parameterLOG_FILE_NAME_CONVERT c omes into play.
Important note, neither of thesetwo parameters work for the ONLINE redolog files. Those you will have torename yourself. If you do not do so, you will get an
error at the time youtry to SWITCHOVER your standby database. Such errors are easily remedied byrunning that c ommand.
f. Now, it's time to start thestandby instanc e and mount it.
SQL> startup nomount pfile=/export/home/oracle/admin/SEAN/pfile/initSEAN.standbySQL> atler database mount standby database;
g. Almost there. Lastly, we needto rec over the standby database using the AUTO option. Note that you shouldbuild a simple shell script to startup sqlplus
and run these commands. A namelike 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 thathave showed up via move_standby.sh below.
SQL> recover standby database;AUTO
h. Now, of course, you'll want totest your standby database. You do this by starting up in read-only mode.
SQL> alter database open read only;
i. Don't forget to put it back instandby mode so that when your manual_standby.sh sc ript runs from c ron, it won'treturn errors.
SQL> shutdown immediate;SQL> startup nomount pfile=/export/home/oracle/admin/SEAN/pfile/initSEAN.standbySQL> atler database mount standby datab
2. What scripts should run via cron on the primary andstandby database?
As we mentioned earlier, a script called manual_standby.shwould work well on the standby database. This script applies new archived redologsthat have arrived
from the production system. Run it every half hour and seehow that works for you. The database must be mounted in standby mode (notread-only) or this sc ript
will fail.
You'll also want a script on the production server. Name itmove_standby.sh, and run it every thirty minutes to start with. This can use rsyncto move redolog files
from produc tion to standby. A command like this wouldwork:
$ rsync -e ssh -Pazv /ora/oracle/arch/ oracle@remote:/export/home/oracle/arch/
Note that you may want to adjust options to ssh to yourneeds. In addition, this presumes you have ssh autologin configured. Read upon the ssh-keygen command.
The .ssh directory c ontains a public key, which isshipped over to the standby machine, and put in the "authorized_keys"file. ssh will then login without a password.
Rsync uses ssh as the transportmec hanism, so it also exec utes without a password. Rsync is very smart andonly copies blocks and pieces of files that are
different, so it is very fast, andalso does c hec ksums to guarantee c onsistency.
3. Is the standby database behind the productiondatabase?
Yes, keep in mind we are creating a manual standbydatabase. The standby database will tend to be behind production by about halfthe size of a redolog file. So if
those files are 100M, and you generate 100Mof transactions in 30 minutes, then on average standby will be fifteen minutesbehind.
4. What types of changes and statements on productionwill not be automatically applied to standby?
In database parlance, any PHYSICAL changes to the db, plusany commands, issues with the NOLOGGING option. Physical changes inc ludec reation of new
tablespaces, adding new datafiles, renaming datafiles, autosizingof datafiles, altering redolog files, altering controlfiles and so on. Inaddition, primary database
processes or c ommands using the UNRECOVERABLE optionwill not be propagated to the standby database.
There are specific and detailed instructions for making someof these physical changes on the standby db manually, however in many c asesrecreating the entire
standby database per the instructions above, might be thebest option.
Conclusion:
Standby database technology in Oracle is a powerful highavailability solution. Even if you're using Oracle SE, you c an still takeadvantage of these features built into
Orac le, with just a little scripting,hand holding, and ample monitoring. Do your researc h, test, test, and testagain on a development server. And don't forget to
monitor all your logfilesfor errors. Following these guidelines, you should be in very good shape, at amuc h lower c ost.