Move changelog Data to Enterprise Database with a Cron Job
Description
LogicNets uses the changelog_ctx table to store system data that includes user information, session details, package information, actions taken my users, and the dates on which actions happened. This database houses system meta data, including what changed. This is the data table LogicNets use for reporting, and for that, it's good to put it in a centrally accessed location.
For most applications, LogicNets stores the changelog_ctx as part of the SQLite data tables that are part of each application. However, to provide reporting that is faster or combines data from different servers, you can create a cron job that moves the data stored in the changelog from the SQLite database format to the MySQL enterprise database format.
This topic contains the technical information and actions necessary to set up the MySQL database as well as the connection to allow the cron job to run.
Create the Schema
To use the cron job that moves the data in the changelog_ctx to the MySQL enterprise database, you must first create the schema. This involves creating the database and then running the table-create statement to create the required table. Once that is done, you create the required views of the data found in the changelog_ctx table for the reporting tool.
Automatically Create the Schema
For convenience, LogicNets created a batch file you can use to have the system automatically perform the steps necessary to create the schema. To use the batch file, do the following:
- Navigate to the LogicNets installation.
- Navigate to "system/scripts/Remote databases".
- Use "create_changelog_schema.bat" to set up the changelog schema.
After following the steps outlined in the batch file, go to Update Configuration Settings below, to ensure the communication between the schema and LogicNets is established.
Manually Create the Database
Create the MySQL database to house the tables and corresponding views using the following statement:
Manually Create the changelog_ctx Table
Create the changelog_ctx table using the following table-create statement:
Manually Create the reporting_changelog_ctx View
Create the reporting_changelog_ctx view using the following create statement:
Manually Create the session_summary View
Create the session_summary view using the following create statement::
Update Configuration Settings
The final step is setting up the reporting cron job in MySQL is to establish the connection between LogicNets and the MySQL schema created.
- Navigate to "System Configuration" on your LogicNets dashboard.
- Navigate to the Database tab.
- In the Alias field under "External databases", add "__changelog_ctx".
- In the "Database name/ ODBC string" field, add the following ODBC string:
1odbc:DRIVER={MySQL ODBC 8.0 ANSI Driver}; SERVER=localhost;
DATABASE=changelog; UID=root;
PASSWORD=pass123;NO_TRANSACTIONS=1;MULTI_STATEMENTS=1
Make sure to update the ODBC string to include the correct server settings, including the server name and password.
Add Cron Job to Scheduler Monitor
Once you have created the schema and set up the reporting cron job, navigate to the Scheduler Monitor on your LogicNets dashboard.
Add the cron job to the Scheduler Monitor. The steps required to do that are available here: Scheduler Monitor Overview.
Cron Job Configurable Settings
The cron job contains the following configurable settings that all that you should check:
- changelog_limit: By configuring the changelog limit you can set how many rows of the database the system copies over each time it runs the cron job.
- device: This allows you to set the name of the server from which the cron job runs.