Project

General

Profile

Database Mirroring (DB2) on remote site » History » Version 12

chin-yeh, 03/22/2012 10:33 AM

1 1 chin-yeh
{{toc}}
2
3 12 chin-yeh
h1. Database Mirroring (DB2) on remote site
4 2 chin-yeh
5
h2. Introduction
6
7 3 chin-yeh
To mirror production database(s) to remote site, there are a number of approaches:
8
# Use <code>(full)</code> database backup
9 10 chin-yeh
# Use <code>(full + cumulative)</code> database backup
10 3 chin-yeh
# Use <code>(full + delta)</code> database backup
11 10 chin-yeh
# Use <code>(full + cumulative+ delta)</code> database backup - _not recommended because it is too complex_
12 3 chin-yeh
# Use <code>(full database backup + transaction logs)</code>
13
14 1 chin-yeh
> the approach 1-4 are described in "Using DB2 incremental backup":http://www.ibm.com/developerworks/data/library/techarticle/dm-0910db2incrementalbackup/
15
16 10 chin-yeh
We will only discuss about the last approach, _full + transaction logs_ in the coming sections. Before that, let's do a quick compare for these approaches:
17
||_.full|_.full + cumulative|_.full + delta|_.full + cumulative + delta|_.full + transaction logs|
18
|*Backup Image Size*|Biggest|Small|Smallest|In between Small and Smallest|Smaller|
19
|*Backup Time*|Longest|Depends on how the data is stored across tablespaces. If all data is stored in one tablespace then it won't make any difference|Depends on how the data is stored across tablespaces. If all data is stored in one tablespace then it won't make any difference|Depends on how the data is stored across tablespaces. If all data is stored in one tablespace then it won't make any difference|Fast|
20
|*Easy To Recover*|Easiest|Easy|Difficult|Very Difficult|Easy|
21
|*Need To Revise Backup Strategies*|No|Yes|Yes|Yes|No|
22
|*Resources Utilization*|High|High to Medium|High to Medium|High to Medium|Low|
23 11 chin-yeh
|*DB is usable after first restored*|Yes|No|No|No|No|
24
|*Functions Used*|backup + restore + rollforward|backup + restore + rollforward|backup + restore + rollforward|backup + restore + rollforward|backup + restore + rollforward + rsync|
25 3 chin-yeh
26 4 chin-yeh
27
h2. Full Database Backup + Transaction Logs
28 5 chin-yeh
29
Below diagram describes how this approach works:
30
31
!full_transaction_logs_approach.png!
32 6 chin-yeh
33
_Sample steps:_
34
# Like any other approaches, you must perform a full database backup _(either offline or online)_
35 1 chin-yeh
** e.g.:
36
<pre>$ db2 backup db prod_db online</pre>
37 11 chin-yeh
# Transfer the full backup image to the standby site and perform a database restoration:
38
** e.g.:
39
<pre>$ db2 restore db prod_db replace history file</pre>
40 6 chin-yeh
# Use the <code>rsync</code> command to do an one way incremental sync from remote (production) site to standby site.
41
** e.g.:
42
<pre>$ rsync -var --delete db2inst1@db-prod:/home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/ /home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR</pre>
43
# Execute the <code>rollfoward</code> on the standby database: (*do not* include the *complete* option)
44 1 chin-yeh
** e.g.:
45 6 chin-yeh
<pre>$ db2 rollforward db prod_db to end of logs</pre>
46 9 chin-yeh
# If want to bring up the standby database, just execute this command (_change the database alias_):
47 6 chin-yeh
<pre>$ db2 rollforward db prod_db complete</pre>
48
49 10 chin-yeh
The biggest advantage of this approach is there's little or no need to revise current backup strategies, however, the mirror database cannot be used until the <code>rollforward</code> process is terminated (_also happens on the other db incremental backup approaches_).
50 6 chin-yeh
51 1 chin-yeh
h2. Test Tools
52 12 chin-yeh
53
To test run those database backup