While infx itself does not contain any services for Informix database replication, it can still be used to simplify the process.
The Informix High Availability Data Replication (HDR), is used to replicate all the databases in an Informix instance to another host. Informix Enterprise Replication (ER) is used to replicate individual databases and tables.
In this example I will show how to setup Informix HDR with infx services. The example assumes that Informix and infx are already installed on both servers.
The basic process is:
- create a new instance on the second server
- modify it to be a secondary instance
- copy the primary instance data with the hot copy service
- start HDR on the secondary
- start HDR on the primary
Step 1: Create new instance
On the second server, create a new instance to be the secondary.
noenv@cloud2:/home/informix>infxenv test1dr
test1dr@cloud2:/home/informix>
Step 2a: Change Informix ONCONFIG
Use the infxonconfig
command to edit the ONCONFIG file of the new instance. We need to match the settings on the primary server, minimally this means changing the ROOTPATH.
Change ROOTPATH /infx/inst/test1dr/chks/root.001 to /infx/inst/test1/chks/root.001
Step 2b: Change infx chunks directory
Change the chunks directory to match the primary server. Use the infxconfig
command to edit the infx config file and add to the [infxenv] section:
CHKDIR = /infx/inst/test1/chks
Step 3: Hot copy data from primary server
To start HDR, we first need to synchronize data between the primary and secondary servers. I will use the hot copy function of the restore service to run an ontape backup on the primary and restore it directly to the secondary.
restore service is continuing in background, pid=14033
test1dr@cloud2:/home/informix>
To monitor this restore processes you can:
- Use
infx follow
to monitor the restore service log - Use
infx dbspace
to monitor the dbspace status - Use
infx service
to monitor the status of the restore service - Use
infx status
to monitor the status of the instance
Example output, infx dbspace
command showing dbspace output during restore:
test1dr@cloud2:/home/informix>infx dbspace class space pg flags chks size mb free mb used mb used% read mb write mb warn root 2k IP RESTORE 1 100.00 91.83 8.17 8.17% 0.00 3.84 error dat01 2k DOWN DOWN 1 100.00 99.89 0.11 0.11% 0.00 0.00 error dat02 2k DOWN DOWN 1 100.00 99.89 0.11 0.11% 0.00 0.00 error plog 2k DOWN DOWN 1 100.00 4.89 95.11 95.11% 0.00 0.00 error log01 2k DOWN DOWN 1 100.00 66.89 33.11 33.11% 0.00 6.38 error log02 2k DOWN DOWN 1 100.00 66.89 33.11 33.11% 0.00 0.00
The output shows that the root space is being restored, and all others are still down.
Once the hot copy completes, the secondary will be in fast recovery mode, ready to start HDR replication.
Step 4a: Add primary server to sqlhosts file
Use the infxsqlhosts
command to add the primary server to the Informix sqlhosts file. Add this entry:
test1 onsoctcp cloud1 62001
Step 4b: Start HDR on secondary
Once the restore is complete, use the onmode command to start HDR replication on the secondary.
test1dr@cloud2:/home/informix>
Step 5a: Add secondary server to primary sqlhosts file
On the primary server, use the infxsqlhosts
command to add the secondary server to the Informix sqlhosts file. Add this entry:
test1dr onsoctcp cloud2 62001
Step 5b: Start HDR on primary
Use the onmode command to start HDR replication on the primary.
test1@cloud1:/home/informix>
Use the onstat -m command and check the instance message log.
...
11:45:20 DR: new type = primary, secondary server name = test1dr
11:45:20 DR: Trying to connect to secondary server = test1dr
11:45:21 DR: Primary server connected
11:45:21 DR: Secondary server needs failure recovery
11:45:25 Logical Log 9 Complete, timestamp: 0x2e016.
11:45:25 DR: Sending log 9, size 5500 pages, 58.05 percent used
11:45:26 Logical Log 9 - Backup Started
11:45:31 Logical Log 9 - Backup Completed
Once sending of the logs and synchronization is complete, HDR replication will be on.
Check primary server status
Use the infx status
command and check the primary server status.
test1@cloud1:/home/informix>infx status test1 (online(prim)) ver: 11.50.FC7IE up: 00:13:20 host user memory space write prof name cloud1 active 19 total 186.39mb total 0.60gb total 16 read 67.05% cpu 1/1 max 24 res 120.85mb free 0.43gb fg 0 write 36.00% mem 0.51gb total 128 virt 65.54mb temp 0.00gb lru 0 ckpts 14 free 0.04gb threads 19 free 34.11mb free 0.00gb chunk 16 waits 4 status: good hdr: test1dr (good:on) backup: 2011-05-24 11:39 (9) ll avail: 100% threads: 1 active: soctcppoll(1)
Check secondary server status
Check the status of the secondary instance.
test1@cloud1:/home/informix>infx status test1dr@cloud2 test1dr (readonly(sec)) ver: 11.50.FC7IE up: 00:13:20 host user memory space write prof name cloud2 active 34 total 186.39mb total 0.60gb total 4 read 89.68% cpu 1/1 max 34 res 120.85mb free 0.43gb fg 0 write 0.00% mem 0.51gb total 128 virt 65.54mb temp 0.00gb lru 0 ckpts 16 free 0.01gb threads 34 free 27.82mb free 0.00gb chunk 4 waits 0 status: good hdr: test1 (good:on) backup: 2011-05-24 11:39 (9) ll avail: 100% threads: 1 active: soctcppoll(1)
Summary
infx simplified this process by:
- Creating the secondary instamce, ONCONFIG file and sqlhosts entries
- Creating chunk files that match the primary server
- Providing the correct environment for the primary server ontape backup
There are a few other things infx could do, such as using the new ifxclone command from v11.7. But that will be the subject of a different post.
What do you find is the most annoying thing about setting up and managing Informix HDR instances?
No comments:
Post a Comment