Introduction

This article describes how to configure a renewed process of synchronization among r_keeper 7 databases.

The minimal r_keeper 7 version required for synchronization is 7.6.4.

Synchronization Description

Interaction Procedure

To enable synchronization, specify the following setting in the server INI file:

[DBSYNC]

UseDBSync=1


When run in this mode, the reference server will create the rk7.udb.SQLite file (next to the rk7.udb database file) and a folder where it will store backup copies, log files, and the filtering settings file for transferring them to client applications.

By default, this is the DBSync\outgoing folder, placed in the folder containing the database.

Data transfer to client applications is performed over the network. Network access to this folder is provided by the WebDAV protocol. To work with WebDAV, every server runs the nginx that is automatically accessed through the HTTP interface of the server. If INI files of client applications do not have a static ReqSourceURL, client applications individually request the host and port from the server by default when connecting to it using the network name.

Below is the module interaction procedure in synchronization 2.0:

Synchronization Settings

Open the reference server settings file (rk7srv.INI) and add the setting UseDBSync=1 to the [DBSYNC] section. There is no default section, so it should also be specified.


;;first line comment to avoid problems with BOM
[REFSERVER] Server = RK7TEST
UDBFILE = ..\..\base\rk7.udb
MainLang = .\localize\rkeeper7\rkeeper7.ru.xlf
AltLang = .\localize\rkeeper7\rkeeper7.en.xlf
WorkModules = ..\..\base\workmods
ErrorLogSize = 10485760
DisableSMARTVerify = 1
UseNetChecking=1
LicServerIP=l.ucs.ru:60606
Usesql=1

[DBSYNC]
UseDBSync=1

[NETKERN]
Protocols = tcpsoc.DLL


Save the file and run the reference server.

  1. Open the manager station.
  2. Go to Options > OLAP Reports > Reporting Servers
  3. Select your report or reference server. In the properties, check the box Use Free Listen Port
  4. In the HTTP Rights section, select HTTP Access in the HTTP API line
  5. Save settings and restart the server.

The DBSync folder containing the outgoing folder will appear in the folder RK7\base\. In the outgoing folder, the server will store backup copies and log files for transferring them to client applications.

Specify the same setting in other applications: report servercash server, and cash stations.


[DBSYNC]

UseDBSync=1


Save the settings files and run the applications.

Synchronization Check

To check synchronization, open a folder in a browser. To do so, open the link of the following format:

https://http_host:http_port/rk7api/v1/dbsync/
  • where http_host is the IP address of the required server. In this case, it is 127.0.0.1
  • http_port is the server port. It is specified in the [TCPSOC] section. If it is not specified, you can check it by opening the web interface — double-click the image2021-9-3_16-39-24.png icon in the tray.

    An example for the reference server:

As an example, open the link https://127.0.0.1:54318/rk7api/v1/dbsync/ (this is my reference server). Instead of 54318, specify your port.

The authentication window will appear.

Enter the user name in Latin characters with the HTTP_Access right and the password.

Click Ok. You will see the list of files in the folder:

If the list has appeared, synchronization is enabled. You can perform an additional synchronization check by changing the name of a dish in the menu and checking it at the cash station.

The cash server and report server can be checked in the same way.

Processing of Synchronization Stop, Databases Online-Updating

Additional settings to manage the synchronization mode can be specified in the [DBSYNC] section.

The StopSyncAction parameter is used on the cash server and the report server to indicate their actions in case of synchronization stop, f.ex. the reference server or an upper transit report server is turned off.

This parameter should be specified in the corresponding configuration files:

  • rk7srv.ini — for the reference server
  • repsserv.ini — for the report server

In the [DBSYNC] section, specify StopSyncAction= one of the following values:

  • Nothing — the server creates a record about synchronization stop in the log

    [DBSYNC]
    StopSyncAction=Nothing

  • RestartApp — the server creates a record about synchronization stop in the log and then automatically restarts

    [DBSYNC]
    StopSyncAction=RestartApp

  • ReloadReferences — the server creates a record about synchronization stop in the log, makes new backup copies and download the collections. The newest version of r_keeper 7 database will be saved. 

    [DBSYNC]
    StopSyncAction=ReloadReferences

Description of INI Files

Reference Server

The configuration file for the report server is rk7srv.INI


[DBSync] ; Enabling the second database SQLiteCMN for the common (main) reference database and the local reference database,
; and recording of their log files and backups for synchronization by databases to work.
; When run in this mode, the reference server will create (next to the database file rk7.udb) the file called rk7.udb.SQLite
; and a folder where it will store backup copies, log files and the filtering configuration file
; for transferring them to client applications. See more details below, in the description of the OutputPath parameter.
; By default, this is the folder DBSync\outgoing, placed in the folder containing the database.
; Network access to this folder is automatically enabled by the WebDAV protocol,
; so every server runs its own nginx that is automatically accessed
; through the HTTP interface of the server. If INI files of client applications do not have a static ReqSourceURL (see below),
; client applications individually request the host and port from the server by default when connecting to it using the network name.
; To perform checks, you can establish a connection to this folder, for example through a web browser, using the URL of the format https://<http host>:<http port>/rk7api/v1/dbsync/ UseDBSync = 1

; The folder that will contain created backup files, log files and the filtering settings file.
; Not obligatory to specify it, as the default folder is DBSync\outgoing\, next to the reference database file
; of the reference server. Client applications take files from it for updating their databases.
; They access it either through the embedded WebDAV or directly as to a folder in the file system or in any other way.
; OutputPath = <DataBasePath>DBSync\outgoing

; Specifies how many transactions are required for a backup. By default, every 1000 log files are backed up.
; BackupOnVersionsDelta = 2000

; What total log size (a percentage of the last backup size) is required to make a new backup.
; By default, this is 30%: a new backup is made once the total size of log files
; created since the last backup reaches 30% of the size of the last backup.
; BackupOnJournalSizeMultiplier = 30

; What total size of log files should be reached so that the earliest of them are deleted from the OutputPath.
; Indicated as a percentage of the last backup size; by default, this is 300.
; That is, the default size of stored log files equals three sizes of the database.
; BackupMaxTotalSizeMultiplier = 300

; Minimal log file storage time in hours
; By default, logs are stored for no less than 8 hours
; MinSaveJournalHours = 8

; How many minutes after a more recent backup is created to wait for missing logs
; This parameter works only when using an external transport, when using a built-in transport, the presence of gaps in the log files is requested from the upstream server and synchronization stops after 5 minutes
; Then the backup is requested and applied, if possible.
; NoJournalMinutesStopSync = 5  

; What number of backups should be reached so that the earliest of them are deleted from the OutputPath.
; By default, two backups are stored: the last one and the next-to-last one (as a precaution)
; BackupCountLimit = 2

; To protect file exchange through http, you can set a system password; a parameter value must start with ":"
; ServerLoginInfo = :<Password>

; Enabling the nginx debugging mode. 1 means 'enabled'. The default value is 0.
; NginxDebug = 0


Report server

The report server configuration file is repserv.ini


[DBSYNC]
; Allowing to receive backups, logs and the filtering configuration file from the upstream server for synchronizing
; the main reference database with it and enabling the second database SQLiteCMN for local references
; and for recording its log files and backups for synchronization by databases to work.
; When run in this mode, the report server will create (next to the database file rk7.udb) the folder called rk7.udb.SQLiteDBSync\outgoing
; where it will store backups, log files and the filtering configuration file for transferring them to its client
; applications both through the main reference database, received from the upstream server and applied to its database,
; and through the local database, generated when editing local references on this server. UseDBSync = 1
; As for the outgoing folder settings, see the description of the similar section of the reference server parameters.
; Access to the OutputPath folder on the upstream server can be granted via the WebDAV protocol and via external means,
; in this case, in the ReqSourceURL parameter, please indicate the URL from where to request data (Request).
; ReqSourceURL = http://<serverIP>:<WebDAVPort>/rk7api/v1/dbsync
; If this parameter has an empty value, downloading via the WebDAV protocol will be disabled.
; This is useful if the upstream server is located on the same computer or in the local network and if it is possible
; to grant access to its outgoing folder directly through the file system means.
; ReqSourceURL =
; To balance the network and server load, specify how many seconds should pass for processes of downloading via WebDAV
; between requests to the server for new log files or new backups. The default interval is 2 seconds.
; ReqInterval = 2
; To balance the network and server load, during downloading via WebDAV you can control
; the percentage of backup size that log files can take up, so that when the client starts working, this backup will be downloaded
; instead of those log files.
; The default value is 100 percent
; if the size of required log files is larger than the backup, the backup is downloaded.
; If the value of 200 is specified, log files must be 2 times larger than the backup for it to be downloaded,
; and 50 is specified, the backup can be 2 times larger than logs, but it will still be downloaded.
; You should select the value of this parameter depending on the network speed, the speed at which log files are applied,
; the system slowdown when many log files are applied, etc.
; ReqStartLoadBackupMultiplier = 100
; By default, when connected via WebDAV, backups for the OutputPath folder are made locally considering the settings
; for conditions of taking backups and independently from servers. Therefore, they are made not for the same data versions for which backups
; are taken on other servers. If it is necessary to synchronize backups or to reduce some of the loads,
; it is possible to turn on the mode in which backups are downloaded from the upstream server. It is disabled by default.
; ReqToDownloadBackups = 0
; The folder (relatively to the exe file) from where backups and log files will be taken from the closest upstream server
; for the database to be updated. By default, it is equal to <DatabasePath>DBSync\incoming
; If the ReqSourceURL parameter (see above) is not empty, it is to this folder that files will be downloaded via WebDAV.
; If the ReqSourceURL is empty, here you can specify the path to the DBSyncOutputPath folder of the upstream
; reference server or report server if it is in the same network or on the same computer
; alternatively, you can specify the path to its copy received; from the remote server via some external means.
; InputPath = <RefServerBaseFolder>\DBSync\outgoing
; The folder where processed backup and log files will be placed. Database files of local references will also be added there.
; It is not obligatory to specify it, as the default folder is <DatabasePath>DBSync\outgoing\ next to the reference database file of the report server.
; OutputPath = <DataBasePath>DBSync\outgoing
; The mode in which the report server deletes processed files from the InputPath folder after copying them to the OutputPath.
; This is useful if they are downloaded to the InputPath folder individually for a given report server.
; If the incoming folder is the outgoing one of the upstream server and it is shared by several clients,
; this mode is irrelevant, and cleaning of this folder is controled by the upstream server.
; Therefore, if InputPath=<DataBasePath>DBSync\incoming, by default RemoveProcessed = 1, otherwise 0.
; RemoveProcessed = 0
; To exchange files via http, you can specify a system user with a password
; For the http server:
; ServerLoginInfo = :<Password>
; For the http client:
; ReqSourceLoginInfo = [<User>]:<Password>
; <User> is only for external WebDAV servers. To connect to RK7 servers, there is no need to specify the <User> (the network name will be used)!
; The same as on the reference server
; BackupOnVersionsDelta = 2000
; BackupOnJournalSizeMultiplier = 30
; BackupMaxTotalSizeMultiplier = 300
; MinSaveJournalHours = 8
; BackupCountLimit = 2
; NginxDebug = 0 [CONFIG]
; The type of the used database. The mechanism is intended to work with SQLite, so it is required to indicate SQLiteCMN or SQLiteUCS.
; Must be the same as the database type specified on the reference server.
; For now, it is impossible to specify it so there is no need to indicate it here either.
; DataBaseKind = SQLiteCMN
; Filtering settings have not changed: if required, it is enabled via SyncSchdFile.
; But when synchronization is performed by databases, filtering settings are used for reading from the database
; so they are required not only on the repeater unit but also have to be configured on each cash server and on each cash station.
; Therefore:
; When UseDBSync is enabled, servers save their filter to the OutputPath for clients to use.
; When UseDBSync is enabled and if not indicated otherwise in the SyncSchdFile parameter, clients use the filtering settings file
; from the folder specified by the InputPath parameter. It should get there from the OutputPath of the upstream server.
; Moreover, only RestFilterIn and skipDeleteIn are used from the file specified in this parameter while the schedule is not used.
; SyncSchdFile =

Cash Server

The cash server configuration file is RKEEPER.INI

[DBSYNC]
; See the description of the similar section of the report server parameters, considering that the local reference database on the cash server is also taken solely from the upstream server.
[CONFIG]
; See the description of the similar section of the report server parameters.

Cash Station and Printing Station

The configuration files for cash stations and printing stations are wincash.ini and winprint.ini

[DBSYNC]
; See the description of the similar section of the report server parameters but parameters responsible for filling and cleaning the OutputPath folder and making backups are ignored
[CONFIG]
; The path to the folder for the cash station references database.
; In the mode of synchronization by databases, a cash station also has its own database and should know where to place it.
; If not indicated, the app folder will be used.
BasePath = ..
; Instead of the DBSyncMoveToOutput parameter used on servers, the parameter is called DBSyncRemoveProcessed for cash stations
; This is the mode in which the cash station deletes the files from the DBSyncInputPath folder after processing them.
; This is useful if they are placed into the DBSyncInputPath folder individually for a given cash station by some external mechanism.
; The default value is 1 if DBSyncInputPath=<DataBasePath> + 'DBSync\incoming', otherwise 0.
; DBSyncRemoveProcessed = 0
; For other details, see the description of the similar section of the cash server parameters.
  • No labels