|
Size: 2046
Comment: More accurate and descritpive name
|
Size: 3031
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 2: | Line 2: |
| SQL Mirroring |
= 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 == |
| Line 6: | Line 11: |
| All control data files are store in .dat files and .idx is a header which works like index page for .dat file. | All control data files are stored in .dat files and .idx files are indexes for the .dat files. |
| Line 11: | Line 16: |
| {{{ # yum install postgresql}}} |
|
| Line 15: | Line 23: |
| * [control] -> This is a connection name that you use for database * Driver: -> This is driver that is used * Databasename: -> Name of database that you create * login: -> SQL login name * password: -> SQL password |
* [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}}} |
| Line 22: | Line 40: |
| #createdb databasename | {{{ # createdb databasename }}} |
| Line 25: | Line 44: |
| #createtb --help ( to see option) #createtb -d <databasename> | {{{ # createtb --help ( to see option) # createtb -d <databasename>}}} |
| Line 27: | Line 48: |
| 1. Kill all Control users 1. Set flag in cooad. |
1. Log off all Control users 1. Set flag in {{{cooad}}}. |
| Line 32: | Line 54: |
| Line 33: | Line 56: |
| * #fdb2log 1. use #dblogdump command to check contents of dblog.dat |
{{{ # fdb2log}}} 1. Use {{{ # dblogdump}}} command to check contents of dblog.dat |
| Line 36: | Line 65: |
| * #log2odbc --help * #log2odbc -d |
* {{{ # log2odbc --help}}} * {{{ # log2odbc -d}}} |
| Line 39: | Line 71: |
| * #psql dannydb postgresql * #select * from stock; ( if you see data you are looking for then is working) 1. Now after everything is done, you have to put this in cronjob to do automatic update. See the example in braun server cronjob how incremental_dumb script is used in crontab |
{{{ # psql dannydb postgresql => select * from stock; }}} If you see the data you are looking for, then it is working. 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
- 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.
- The type of record and the record number is recorded in dblog.dat
log2odbc takes unprocessed dblog.dat entries, generates SQL query for the whole record and sends it via ODBC
- 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
- Install SQL database. This could be either on same server that Control resides on or a different server.
# yum install postgresql
- Download and install odbc driver for your database.
# yum install unixODBC
- 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
- Create database now using following command
# createdb databasename
- Create table command
# createtb --help ( to see option) # createtb -d <databasename>
- Log off all Control users
Set flag in cooad.
Enable update of odbc data file = Y
Now this flag will start loging in dblog.dat.- 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
- Use
# dblogdump
command to check contents of dblog.dat - Now to start dumping control data to sql database. use this command
# log2odbc --help
# log2odbc -d
- 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. 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
