Differences between revisions 1 and 11 (spanning 10 versions)
Revision 1 as of 2008-05-16 05:26:36
Size: 187
Comment:
Revision 11 as of 2009-08-07 01:43:32
Size: 3314
Editor: DannyCheung
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
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. ## page was renamed from sql and control
= 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.
 1. The type of record and the record number is recorded in dblog.dat
 1. {{{log2odbc}}} takes unprocessed dblog.dat entries, generates SQL query for the whole record and sends it via ODBC
 1. 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}}}

 1. Download and install odbc driver for your database.
 {{{
# yum install unixODBC}}}
 1. 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}}}

 1. Create database now using following command
 {{{
# createdb databasename }}}

 1. Create table command
 {{{
# createtb --help ( to see option)
# createtb -d <databasename>}}}

 1. Log off all Control users

 1. Set flag in {{{cooad}}}.
 {{{
Enable update of odbc data file = Y}}}
 Now this flag will start loging in dblog.dat.

 1. 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}}}

 1. Use
 {{{
# dblogdump}}}
 command to check contents of dblog.dat

 1. Now to start dumping control data to sql database. use this command
  * {{{
# log2odbc --help}}}
  * {{{
# log2odbc -d <ODBC_Connection_Name>}}}

 1. 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.

 1. {{{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

 1. 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}}}
----
 . CategorySql

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


SQL_Mirroring (last edited 2013-09-18 06:09:33 by localhost)