HowToForums.net Forum Index HowToForums.net
An Open Source of Knowledge
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

HowTo IBM Informix HDR - High-Availability Data Replication

 
Post new topic   Reply to topic    HowToForums.net Forum Index -> Informix
View previous topic :: View next topic  
Author Message
jacob
Site Admin
Site Admin


Joined: 16 Mar 2006
Posts: 73
Location: USA

PostPosted: Sat Oct 28, 2006 5:54 am    Post subject: HowTo IBM Informix HDR - High-Availability Data Replication Reply with quote

Code:

#################################################
#################################################
#                                               #
#       HowTo Setup Informix-HDR                #
#                                               #
#       These instructions contain irreversible #
#       procedures and should be used with high #
#       caution.                                #
#       WARNING!!! USE AT YOUR OWN RISK!!!      #
#                                               #
##################################################
##################################################



This HowTo is considering that you have 2 identical informix servers up and running...
Identical as in same hardware / software / OS
And configured using the our standard configuration.
see here for our onconfig param standards
http://howtoforums.net/viewtopic.php?t=90

Stop (stopinformix.sh) and Start (startinformix.sh) informix and other scripts used in this post can be found below at the end of the post:


Server Names Used in this example:
Code:

        Primary server: ifxhdr1
        Secondary Server: ifxhdr2


1. validate these parameters to be identical in onconfig:
Code:

# Data Replication Variables
All params in the onconfig must be identical...

Config type 1: Synchronis:
        DRAUTO          OFF             # DR setting to define switching types on failovers
        DRINTERVAL      -1              # DR max time between DR buffer flushes (in sec)
        DRTIMEOUT       40              # DR network timeout (in sec) multiplied by 4
        ###DRLOSTFOUND     /opt/informix/etc/dr.lostfound # DR lost+found file path
Config Type 2: Asynchronis:
        DRAUTO          OFF             # DR setting to define switching types on failovers
        DRINTERVAL      30              # DR max time between DR buffer flushes (in sec)
        DRTIMEOUT       40              # DR network timeout (in sec) multiplied by 4
        DRLOSTFOUND     /opt/informix/etc/dr.lostfound # DR lost+found file path

On Primary:
        DBSERVERALIASES ifxhdr1_shm,ifxhdr1_hdr  # List of alternate dbservernames
On Secondary:
DBSERVERALIASES ifxhdr2_shm,ifxhdr2_hdr  # List of alternate dbservernames


2. vi $INFORMIXDIR/etc/sqlhosts
Code:

On Primary:
        ifxhdr1_shm      onipcshm        ifxhdr1          ifxhdr1_srv_shm
        ifxhdr1_onlds    onsoctcp        ifxhdr1          ifxhdr1_srv

        ##secondary server params
        ifxhdr2_onlds    onsoctcp        ifxhdr2          ifxhdr2_srv

        #HDR specific params
        ifxhdr1_hdr    onsoctcp        ifxhdr1          ifxhdr1_hdr
        ifxhdr2_hdr    onsoctcp        ifxhdr2          ifxhdr2_hdr

On Secondary:
        ifxhdr2_shm      onipcshm        ifxhdr2          ifxhdr2_srv_shm
        ifxhdr2_onlds    onsoctcp        ifxhdr2          ifxhdr2_srv

        ##primary server params
        ifxhdr1_onlds    onsoctcp        ifxhdr1          ifxhdr1_srv

        #HDR specific params
        ifxhdr1_hdr    onsoctcp        ifxhdr1          ifxhdr1_hdr
        ifxhdr2_hdr    onsoctcp        ifxhdr2          ifxhdr2_hdr



3. make sure each server is on different ports
vi /etc/services
Code:

On Primary:
        # Local services

        ifxhdr1_srv_shm         1526/tcp        # Informix RRT AUTO INSTALL
        ifxhdr1_srv             1526/tcp        # Informix RRT AUTO INSTALL
        ifxhdr1_onlds           1526/tcp

        # secondary server ports
        ifxhdr2_onlds           1536/tcp

        ifxhdr1_hdr             1901/tcp        #Infomix hdr protocol
        ifxhdr2_hdr             1902/tcp        #Infomix hdr protocol

On Secondary:
        # Local services
        ifxhdr2_srv_shm         1536/tcp        # Informix RRT AUTO INSTALL
        ifxhdr2_srv             1536/tcp        # Informix RRT AUTO INSTALL
        ifxhdr2_onlds           1536/tcp

        # primary server ports
        #--not-sure# ifxhdr1_srv      1526/tcp  # Informix RRT AUTO INSTALL
        ifxhdr1_onlds   1526/tcp

        ifxhdr1_hdr             1901/tcp        #Infomix hdr protocol
        ifxhdr2_hdr             1902/tcp        #Infomix hdr protocol


4. vi /etc/hosts
Code:

        127.0.0.1               localhost.localdomain localhost
        192.168.112.181         ifxhdr1 ifxhdr1.domain.net      ifxhdr1_srv     ifxhdr1_onlds
        192.168.112.182         ifxhdr2 ifxhdr2.domain.net      ifxhdr2_srv     ifxhdr2_onlds


5. vi /etc/hosts.equiv
Code:

On Primary:
        ifxhdr2.domain.net
        ifxhdr2
        ifxhdr2_srv
        ifxhdr2_onlds

On Secondary:
        ifxhdr1.domain.net
        ifxhdr1
        ifxhdr1_srv
        ifxhdr1_onlds



6. set faketape in onconfig to something big and start a level0 archive
- remember to change on both or change back
Code:

        # System Archive Tape Device

        TAPEDEV         /opt/informix/faketape2 # Tape device path
        TAPEBLK         16              # Tape block size (Kbytes)
        TAPESIZE        10002400        # Maximum amount of data to put on tape (Kbytes)

        # Log Archive Tape Device

        LTAPEDEV        /opt/informix/faketape2 # Log tape device path
        LTAPEBLK        16              # Log tape block size (Kbytes)
        LTAPESIZE       10002400        # Max amount of data to put on log tape (Kbytes)

*soft link faketape2 to a writable file, this file will be the backup
* note: if you never did a transactional backup on the db you loaded
then you must do one before the level 0 backup that will
be transfered to the secondary server:
Code:
 
               ontape -s -L 0 -U dbname


7. Put the primary server in quiesent mode
Code:

        onmode -s


8. Create the full level 0 backup to faketape2 on the primary server
Code:

        stopinformix.sh
        cat /dev/null > db_chunks/faketape2
        oninit -s
        sleep 5
        onmode -m
        ontape -s -L 0


9. Start the primaryserver using the hdr startup:
Code:

        onmode -d primary ifxhdr2_hdr #(hdr_sec_name)

        *Note at this point you shuold tail the log...
        It should say:
                Messages to message log
                DR: new type = primary, secondary
                server name = sec_name
                DR: trying to connect to
                secondary server
                DR: Cannot connect to secondary
                server


10. If you have existing chunks or dbsapces on the primary then touch files for the chunks on the secondary.

11. Stop informix on secondary

12. comment out the startlogbackup part of the startinformix scripts...

13. Copy the Level0 backup file from the primary to the secondary tape location
Code:

        stopinformix.sh

        Restore without backing up the logs
        ontape -p
        Continue restore? (y/n)y
        Do you want to back up the logs? (y/n)n
        Restore a level 1 archive (y/n) n

                Messages to message log
                Informix Dynamic Server Initialized --
                Shared Memory Initialized
                Recovery Mode
                Physical restore of rootdbs started.
                Physical restore of rootdbs completed.


14. Start the hdr mode on the secondary:
Code:

        onmode command:
        onmode -d secondary ifxhdr1_hdr #(hdr_prim_name)
                Messages to message log
                DR: new type = secondary, primary server
                name = prim_name


15. --------------------------Servers start syncing-----------------------------------
Code:

        Primary Messages to message log         Secondary Messages to message log
        DR: Primary server connected            DR: Trying to connect to primary server
        DR: Primary server operational          DR: Secondary server connected
                                                DR: Failure recovery from disk in process.
                                                Logical Recovery allocating n worker threads
                                                ('OFF_RECVRY_THREADS').
                                                Logical Recovery Started
                                                Start Logical Recovery - Start Log n, End
                                                Log?
                                                Starting Log Position - n 0xnnnnn
                                                DR: Secondary server operational



###------------------------------------------------------###
Steps to load a db from one to the other while replication is setup:
These steps require downtime!

On Secondary:
Code:

        stopinformix.sh


On Primary:
Code:

        stopinformix.sh
        oninit -s
        onmode -d standard
        onmode -m
        create spaces and chunks
        onload the database to be imported
        set tape to /dev/null
        ontape -s -L 0 -U dbname #set transactional mode on db
        set tape to file
        ontape -s -L 0
        onmode -d primary ifxhdr2_hdr


On Secondary:
Code:

        scp bkup to tape path
        touch files in the db_chunk directory so that primary &
        secondary servers are identical
        ontape -p
                Continue restore? (y/n)y
                Do you want to back up the logs? (y/n)n
                Restore a level 1 archive (y/n)n
        onmode -d secondary ifxhdr1_hdr


check status of replication with:
Code:

onstat -g dri

        *then after everything syncs up you can
        stopinformix.sh
        startinformix.sh
        on both servers.
                 DR: Reservation of the last logical log for log backup turned on
                     Data replication type and state information reset. To start DR, use
                     the 'onmode -d' command and wait for the pair to be operational,
                     before shutting down the database server



###------------------------------------------------------###
Steps for failover - switching secondary to primary

We are gonna pretend that the primary server
has gone bad or is offline, so I will just
stopinformix.sh on primary.


On Secondary:
Code:

        onmode -d standard

        Uncomment the startLogBackup section of the
        startinformix script that was commented in
        the earlier steps

        stopinformix.sh
        set tape to /dev/null
        startinformix.sh

        * at this point the secondary server has
        become a standalone and functional server.
       
To restore the original primary to be the new secondary:

On Current Primary (ifxhdr2)

        oninit -s
        sleep 5
        onmode -m
        ontape -s -L 0 -U dbname #set transactional mode on db
        set tape to file
        ontape -s -L 0
        onmode -d primary ifxhdr1_hdr
        link tape back to /dev/null

On Previous Primary (ifxhdr1)
WARNING!!! the following steps are irreversable and
        will wipe out any existing database on the server!!!

        oninit -i
        create the temp db space
                touch $INFORMIXDIR/db_chunks/temp_chunk
                onspaces -c -d tempdbs -t -p $INFORMIXDIR/db_chunks/temp_chunk -o 0 -s 100000

        scp Level 0 bkup from Current Primary to tape path
        add spaces in the db_chunk directory so that primary &
        secondary servers are identical
        stopinformix.sh

        ontape -p
                Continue restore? (y/n)y
                Do you want to back up the logs? (y/n)n
                Restore a level 1 archive (y/n)n
        onmode -d secondary ifxhdr2_hdr

check status of replication with:
onstat -g dri

        *then after everything syncs up you can...
Double check that:
        startLogBackup is Uncommented on the Current Primary ifxhdr2 &
        Commented on Current Secondary (ifxhdr1)
        the startLogBackup section of the
        startinformix script that was commented in
        the earlier steps

        stopinformix.sh
        startinformix.sh
        on both servers.
                 DR: Reservation of the last logical log for log backup turned on
                     Data replication type and state information reset. To start DR, use
                     the 'onmode -d' command and wait for the pair to be operational,
                     before shutting down the database server





###------------------------------------------------------###
###------------------------------------------------------###
###------------------------------------------------------###

EXAMPLE SCRIPTS USED IN THIS PROCCESS:

Create & Add Spaces:
Code:

        #!/bin/bash
        echo "    -->   Start: $(date)"

        cd /opt/informix/db_chunks
        touch informixdb
        onspaces -c -d informixdb -p /opt/informix/db_chunks/informixdb -o 0 -s 97150


        touch informixdbchunk1
        touch informixdbchunk2

        onspaces -a informixdb -p /opt/informix/db_chunks/informixdbchunk1 -o 0 -s 2097150
        onspaces -a informixdb -p /opt/informix/db_chunks/informixdbchunk2 -o 0 -s 2097150

        echo " SPACES CREATED SUCCESSFULLY "
        ls -lh
        echo "***************************************************"
        echo "*                                                 *"
        echo "     -->  End: $(date)"
        echo "*                                                 *"
        echo "***************************************************"



Create backups (backup2disk.sh)
Code:

        #!/bin/bash
        date

        . /opt/informix/settings.env


        cd /home/informix/cron_backups

        bfile=ifxdb_$(date +%d%b%y)
        touch  $bfile

        #send 'enter for auto execution'
        echo -e "\n
        " | onunload -t $bfile -b 2048 -s 999999999 informixdb
        bzip2 $bfile


        #delete older files
        find /home/informix/cron_backups -type f -mtime +14 | while read oldbfile
        do
                echo "Delete old file [$oldbfile]"
                rm -f "$oldbfile"
        done
        date
        echo; echo;


Example Load from Backup
Code:

        onload -t /db_chunks/bkup/Import26May2006/ifxdb_26May06 -b 2048 -d informixdb -s 999999999 informixdb


startinformix.sh
Code:

        #!/bin/bash
        # A script to start up the informix database

        oninit -s
        sleep 5
        onmode -m


        #!!!!!!!!!! DO NOT USE ANYWHERE ELSE!!!!!!!
        sleep 5
        (nohup /home/informix/bin/startLogBackup.sh &)&


stopinformix.sh
Code:

        #!/bin/bash
        # A script to stop the informix database

        onmode -yk

        #!!!!!!!!!! DO NOT USE ANYWHERE ELSE!!!!!!!
        killall startLogBackup.sh
        killall ontape


startLogBackup.sh
Code:

        #!/bin/bash

        while sleep 0
        do
                echo -e "\n
        "
        done | ontape -c



for search engine
IBM Informix High-Availability Data Replication
IBM Software - Informix Dynamic Server (IDS) HDR
HowTo HDR informix
How To Informix HDR
Informix HDR
Informix backup scripts
How To Informix backup
Informix backup
Informix redundancy
howto automate informix
informix deployment best practices
informix guru
informix tips and tricks
setup informix HDR
setup informix
How To setup informix
How To setup informix 9.4
How To setup informix 10.0
install informix HDR
install informix
How To install informix



Have Fun!!! Smile

"Forgiving is not a Weakness, rather a Godly Strength"
--Jacob
Back to top
jacob
Site Admin
Site Admin


Joined: 16 Mar 2006
Posts: 73
Location: USA

PostPosted: Wed Jul 22, 2009 1:06 pm    Post subject: Backup / Restore on the fly... Reply with quote

Level 0

Level 0 backup can be done straight to standard out, without any parameters in onconfig being set related to tape device path and size.
Code:

ontape -s -L 0 >/backup_disk/level_0_archive


Link to the documentation at IBM for this feature:
http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.bar.doc/barmst282.htm


Level 0 Backup / Restore HDR

If you need to restore a Level 0 between a HDR pair then you can do it on the fly using the ontape to standard out over a ssh pipe.
Before you start this, you need to make sure your primary server is set to standard mode.
You can also setup ssh keys between the 2 machines.
Only after the restore completes can you set the roles of the primary and secondary using onmode.

Code:

[informix@hdr_primary]$ ontape -s -L 0 -t STDIO | ssh informix@hdr_secondary 'ontape -p -t STDIO'


And if you really want to get fancy you can do it all in one line...
Code:

[informix@hdr_primary]$ ontape -s -L 0 -t STDIO | ssh informix@hdr_secondary 'ontape -p -t STDIO' ; onmode -d primary secondary_hdr ; ssh informix@hdr_secondary 'onmode -d secondary primary_hdr'


Logical Log Continuous Backup

Logical logs no longer have to be backed up using an automated script and a fake tape device. Simply setting the LTAPEDEV parameter in onconfig causes the logical logs to be automatically marked as backed up, and there is no need for an automated ontape -c script to be running in the background.

Code:

LTAPEDEV       /dev/null


Link to the documentation at IBM for this feature:
http://publib.boulder.ibm.com/infocenter/idshelp/v10/topic/com.ibm.bar.doc/barmst287.htm#sii-13tape-34410


for search engines
IBM informix ontape over ssh
informix HDR restore over ssh standard output
informix hdr restore stdio
ontape restore over ssh
Back to top
Display posts from previous:   
Post new topic   Reply to topic    HowToForums.net Forum Index -> Informix All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group