1 oracle database version 8i, 9i or 10g
2 database in archive log mode
3 JRE 1.4 or later.
4 Standby Tool uses ssh/scp to ship files from primary site to standby site. The system should be configured so that ssh/scp can copy file from primary site to standby site without being prompted a password.
Unzip standby_tool_unix.tar.gz to any directory
4 directories will be created
Standby_builder:
directory for standby builder
Standby_agent:
directory for standby agent
primary_agent:
directory for primary agent
common:
directory for some objects shared by all 3 tools
Standby
builder is used to build an initial standby database on standby server.
Primary
agent is a program that push archived log from primary site to standby site. It
should be run at primary site.
Standby
agent is a program that monitors archived log from primary database, once it
detects a new archived log file has been pushed to standby site, it will apply
new log file on standby database. Standby agent should be run on standby site.
Go to direcotory standby_builder, and run guiconfig.sh. And setup all the properties for standby tool.
Standby Name: Standby name. Standby tool will create a table MEIEN_<StandbyName> in database to exchange information between primary site and standby site. If a database has multiple standby databases, the standby name must be unique.
User: Username/Password specify database user standby tool’s agent program will connect to database. The user must have DBA priviledge.
Password: Password will be wrapped when stored for better security.
Primary Working Directory: Standby builder need a working directory on both primary server and standby server to store necessary files.
Primary Database(host:port:sid): JDBC connect string used by standby tool to connect to primary database and pull information. The connect string is in this format: host:port:sid
Standby Host: Host name of standby server.
Standby Working Directory: Standby builder need a working directory on both primary server and standby server to store necessary files.
Standby Database SID: oracle sid of standby database.
Standby Oracle Home: Oracle home directory on standby server. Standby tool assumes oracle software has already installed on the standby server.
Standby Archive Directory: Directory to store archived log file on standby server.
Standby Database(host:port:sid): JDBC connect string used by standby tool to connect to standby database and pull information. The connect string is in this format: host:port:sid
Filename Convertion(optional): If files on standby server is not in same directory as primary server filename convertion can be used. This parameter use format <str1>,<str2>. The first <str1> in filename on primary servier will be replaced by <str2> on standby server. Filename convertion applies to all datafiles, logfiles, controlfiles and
user_dump_dest, core_dump_dest, background_dump_dest.
Primary Log Switch: Interval to switch primary database log file, time is in seconds, 0 disable this feature.
Standby Delete Archive(optional): Whether to delete archived log files after applied to dstandby database. Value 'Yes' will delete archived log files after applied to standby database. Other values or blank will leave archived log on standby server.
Standby Delay: How frequently standby agent should check for new archived log files and apply them. Time is in seconds. Standby delay is usefull when standby database is opened in read only mode for reporting purpose, in such situation, it may not be necessary apply archive logs immeidately after primary database generated them as applying archive logs will shutdown the standby database.
After all properties are set, click “Save” button and properties will save to file standby.properties in common directory. Here is a sample file:
..\common\standby.properties
---------------------cut--------------------------
#Mon Oct 24 15:37:21 EDT 2005
PrimaryWorkingDir=/home/oracle/ora10
Delay=0
PrimaryDB=localhost\:1521\:ora10
StandbyHost=localhost
FilenameConvert=/home/oracle,/home/oracle/stby10
StandbyName=standby1
DeleteArchive=Yes
StandbyOraHome=/home/oracle/product/10g
Password=m+c+DakAuc8\=
StandbyWorkingDir=/home/oracle/stby10
LogSwitch=30
User=scott
StandbyArchDest=/home/oracle/stby10/arch
StandbyDB=localhost\:1521\:stby10
StandbySID=stby10
---------------------cut--------------------------
standby.properities can also be edited manually using any text editor. However per java requirement, escape characters need to be used. See this table:
Original char |
Escaped char |
: |
\: or : |
= |
\= or = |
\ |
\\ |
So basicly ‘\’ must be replaced with ‘\\’, other escapes are optional.
Password is wrapped in standby.properties. To get wrapped string of a password run password.bat. This is a sample output:
..\standby_builder>password.sh
Please enter password: tiger
password: tiger
encode: m+c+DakAuc8=
decode: tiger
The
password utility first prompt to input a password, then it wrapped it into an
encoded string, then unwrap it to make sure it can recover the original
password. The wrapped string should be used in property file.
Go to directory standby_builder. Standby builder is used to build a initial standby database on
standby server.
1 Standby
builder uses ssh/scp to push files to standby site. Before run standby builder,
make sure scp can copy file from primary site to standby site without being
prompted a password.
2 Run
standby_builder.sh. Standby builder will take properties from
standby.properties in common directory and build a standby database
accordingly.
3 After
standby builder is finished, the standby database is created on standby site.
And following scripts are created on standby site too:
a)
standbyHost_standbySID_mount.sh
This
script should only run once after standby databae is first build.
b)
standbHost_standbySID_recover.sh
This
script will manually apply archive to standby database.
c)
standbyHost_standbySID_shutdown.sh
This
script shutdown the standby database
d)
standbyHost_standbySID_startup.sh
This
script startup standby database in read only mode.
e)
standbyHost_standbySID_activate.sh
This
script activate standby database.
The
scripts are not used by standby tool. It's for the convenience of DBA when
manual operation standby database is required.
4 On standby site, run standbyHost_standbySID_mount.sh to initialize the standby database and open it in read only mode.
5 Configure and startup primary agent on primary site.
6 Configure and startup standby agent on standby site.
Primary
agent is a program that push archived log from primary site to standby site. It
should be run at primary site.
Primary
agent does not apply archived log file on standby site.
To setup
primary agent:
1 Primary
agent use ssh/scp to push archived log file to standby site, before run primary
agent, make sure scp can copy file to standby site without being prompted a
password.
2 Primary
agent use same standby.properties file in common directory. This file should
already be setup for standby builder, if any change is required, use
guiconfig.sh in standby_builder directory or manually modify standby.properties
in common directory.
3 Run
primary_agent.sh the script will return shortly, and the agent is running at
background.
4 To
monitor primary agent:
A table
MEIEN_<StandbyName> is created in database.
Table
contains 2 columns: key,value.
key
primary_last_heartbeat is used to monitor primary agent, so use this query:
Use this
query:
Col key
format a30
Col value
form a 30
select
value from MEIEN_&StanbyName order by key
Heart beat
should be updated every second.
For
details about how to monitor standby tool, see howto-monitor-standby-tool.html.
For all
the keys standby tools use, please refer DB Properties.
Primary
agent also generates a log file names PrimaryAgent.log
5 To stop
primary agent:
Once primary agent is up, it will never quit. It is error torelent, if it encounters any error, it will automaticly retry until success then it will start to work again. Generally there is no need to stop the agent. However if you do need to stop the agent, run stop_agent.sh.
Standby
agent is a program that monitors archived log from primary database, once it
detects a new archived log file has been pushed to standby site, it will apply
new log file on standby database. Standby agent should be run on standby site.
Standby
agent does not take care of shipping archived log file from primary site to
standby site.
To setup
standby agent:
1 Install
standby tool on standby server.
2 When
building standby database, standby builder should have copied file
standby.properties to working directory on standby server, copy this file to
common directory, standby agent will take properties from this file. If change
is required, use guiconfig.sh in standby builder directory or manually modify
standby.properties in common directory.
3 Before
run standby agent, try sqlplus "/ as sysdba", make sure you can connect
to standby database without prompting a password. Standby agent use sqlplus and
connect “/ as sysdba” to do the recover job.
4 Run
standby_agent.sh. The script will return shortly, and the agent is running at
background.
5 To
monitor standby agent:
A table
MEIEN_<StandbyName> is created in database.
Table
contains 2 columns: key,value.
key
standby_last_heartbeat is used to monitor standby agent, so use this query:
Use this
query:
Col key
format a30
Col value
form a 30
select
value from MEIEN_&StanbyName order by key
Heart beat
should be updated every second, unless standby database is recovering.
For
details about how to monitor standby tool, see howto-monitor-standby-tool.doc.
For all
the keys standby tools use, please refer DB Properties.
Standby
agent also generates a log file names StandbyAgent.log
6 To stop
standby agent:
Once standby agent is up, it will never quit. It is error torelent, if it encounters any error, it will automaticly retry until success then it will start to work again. Generally there is no need to stop the agent. However if you do need to stop the agent, run stop_agent.sh.
Primary
agent and standby agent use a db property table to exchange information. The db
peroperty table is also used to provide DBA monitoring information.
The db
property table has 2 columns, key and value. The db property table's name has
this format: Meien_<StandbyName> where StandbyName is defined by
parameter files of primary agent and standby agent.
Use this
query to check all the keys:
Col key
format a30
Col value
format a30
Select *
from Meien_&StandbyName order by key;
Db
property table should only be queried to monitor agents status, it should never
be updated manually by DBA.
Here is
description of all the keys:
key: last_sent_seq
value: number
description: last archived log sequence sent to
standby site by primary agent
key: primary_last_heartbeat
value: time in format yyyy-mm-dd hh:mi:ss
Descrition: updated every seconds indicating
primary agent is running.
key: standby_last_heartbeat
value: time in format yyyy-mm-dd hh:mi:ss
Description: updated every seconds indicating
standby agent is running. Standby agent stops update heartbeat when apply
archived redo from primary site.
key: standby_status
value: running/recover/stop
Description: standby status can have 3 values:
Running:
standby agent is running and monitoring archive log from primary site. When
standby agent is running, it update standby_last_heartbeat key every second.
Recover:
standby agent is apply archived log from primary site.
Stop:
standby agent is stopped.
Standby_status
key should be used togather with standby_last_heartbeat key to determine the
status of standby agent. In case standby agent terminated abnormally,
standby_status may remain running, however standby_last_heartbeat will stop
updating, indicating a problem with standby agent.
key: primary_status
value: running/stop
Description: primary status can have 2 values:
Running:
primary agent is running and monitoring archive log archived log generated by
primary database. When standby agent is running, it update
primary_last_heartbeat key every second.
Stop:
standby agent is stopped.
primary_status
key should be used togather with primary_last_heartbeat key to determine the
status of primary agent. In case primary agent terminated abnormally,
primary_status may remain running, however primary_last_heartbeat will stop
updating, indicating a problem with primary agent.
Key: primary_last_seq
Value: number
Description: last archived log sequence of primary
database
Key: standby_last_seq
Value: number
Description: last applied log sequence of
standby database
In case the standby database need to be activated, follow these steps
1 Modify init<standbySID>.ora in $ORACLE_HOME/dbs, this is the parameter file of standby database. Looking for these lines:
#aq_tm_processes=1
aq_tm_processes=0
#job_queue_processes=10
job_queue_processes=0
The commented out lines are original parameter value from primary database, they are set to 0 to prevent updates to standby database. Restore their original value to:
aq_tm_processes=1
#aq_tm_processes=0
job_queue_processes=10
#job_queue_processes=0
2 Run this script in the standby working directory:
standbyHost_standbySID_activate.sh
3 After script is run, standby database is activated, but still need to add temporary datafile:
SQL> select tablespace_name,contents from dba_tablespaces where contents='TEMPORARY';
TABLESPACE_NAME CONTENTS
------------------------------ ---------
TEMP TEMPORARY
SQL> alter tablespace TEMP add tempfile ‘<filename>’ size <file size>;
Now the standby database is activated and ready for use.