SQL Mirroring

How it works

  1. A record in one of the .dat files is altered. This includes changes to quantities, balances. This includes some changes that polling would not normally send/receive.
  2. The type of record and the record number is recorded in dblog.dat
  3. log2odbc takes unprocessed dblog.dat entries, generates SQL query for the whole record and sends it via ODBC

  4. dblog.dat gets updated so that newly processed entries are not re-processed.

Installation

This instruction will help you understand how CONTROL and SQL database works together. Also this instruction will be helpful to troubleshoot or implementing SQL database for the client.

All control data files are stored in .dat files and .idx files are indexes for the .dat files.

Steps to configure SQL database and control

  1. Install SQL database. This could be either on same server that Control resides on or a different server.
    # yum install postgresql
  2. Download and install odbc driver for your database.
    # yum install unixODBC
  3. Configure /etc/odbc.ini which you will need to configure:
    • [xxxxxx]: This is a ODBC connection name
    • Driver: This is ODBC driver that is used to connect to database (different for different SQL vedors)
    • Database: Name of database that you created
    • ServerName: The IP of the SQL server (possibly this machine)

    • Port: Port SQL server listens on (different for different SQL vendors)
    • UserName: -> SQL login name

    • Password: -> SQL password

    [control]
    Driver     = /usr/local/lib/psqlodbcw.so
    Port       = 5432
    ServerName = localhost
    Database   = control
    UserName   = ccc
    Password   = support
  4. Create database now using following command
    # createdb databasename 
  5. Create table command
    # createtb --help ( to see option)
    # createtb -d <databasename>
  6. Log off all Control users
  7. Set flag in cooad.

    Enable update of odbc data file = Y
    Now this flag will start loging in dblog.dat.
  8. If the sql database is not used from the begining of control, all files will not be logged in dblog.dat to update in sql database. So simple enabling flag will not logged old files of control to dblog.dat, only the new files will be logged. To update old and as well as old , use this command.
    # fdb2log
  9. Use
    # dblogdump
    command to check contents of dblog.dat
  10. Now to start dumping control data to sql database. use this command
    • # log2odbc --help
    • # log2odbc -d <ODBC_Connection_Name>
  11. To test to see if the data dumping is successful.
    # psql dannydb postgresql
      => select * from stock;
    If you see the data you are looking for, then it is working.
  12. log2odbc defaults has the following default values:

    ODBC Connection Name = control
    Username = ccc
    Password = support 

    You will need to alter the /u/cc/binl/incremental_dump script so that log2odbc accesses the correct DB

  13. Now after everything is done, place a job in ccc's crontab to do perform the automatic update.

    * * * * * /u/cc/binl/incremental_dump >> /u/cc/LOG/incremental_dump.log 2>&1
  14. dblog.dat does not get re-initialised. You will need to run rolldblog to initialise dblog.dat

Maybe add to backup script