Use an external database
This page describes how to configure Cyberwatch to use an external database instead of the database deployed as a container of the Cyberwatch instance.
Prerequisites
Cyberwatch supports the following databases:
- MariaDB 10.11
- MySQL 8.X
Material prerequisites
Cyberwatch recommends the following hardware configuration to ensure proper operation of the application:
- 2 vCPU
- 12 Go of RAM
- 100 Go of disk space
External Database use case
Cyberwatch uses a containerized MariaDB database by default.
However, using an externalized database can be beneficial in some cases.
Cyberwatch requires the use of an external database for any instance that monitors 5000 or more assets. The use of an external database is also possible for smaller instances, considering the advantages and limitations below.
Advantages of using an external database
- ability to configure and customize database configurations;
- use of a dedicated server, allowing for more accurate resource allocation;
- better performance;
- replication and backup mechanisms that can be more finely tuned.
Limitations related to the use of an outsourced database
- the use of a dedicated server leads to additional infrastructure requirements;
- the maintenance of the database and the dedicated server is not the responsibility of Cyberwatch, although our teams are available to advise you if necessary.
Configuration through the base of the Cyberwatch orchestrator
-
Reconfigure your instance to not use a local database:
sudo cyberwatch configure --no-db
If your instance is more complex than a single node, you need to specify again which configuration to use.
For instance, on a master node, the command is:
sudo cyberwatch configure --no-db --master
Configuring the external database
In order to actually profit from the performances increase expected through the use of an external database, it is required to configure it based on the size of the Cyberwatch instance. The default configuration is not suitable.
The configuration file to edit can depend on the database used and on the system on which it is installed. In this documentation, we choose to modify the file /etc/my.cnf
as an example on the system hosting the external database.
For more information, please refer to the MariaDB documentation regarding the different configuration files : https://mariadb.com/kb/en/configuring-mariadb-with-option-files/#default-option-file-locations-on-linux-unix-mac
Minimal configuration and variables to update
Here is minimal configuration example of the file /etc/my.cnf
when using an external database:
[mysqld]
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
innodb_buffer_pool_size = 1536M
innodb_log_file_size = 384M
The first two lines define the charset to be used, in order to avoid any encoding problem later down the line.
The following two lines are minimal InnoDB configurations to be used at the date of the writing of this documentation.
Adapting the configuration to the size of the database
This default configuration should be adapted based on the size of the Cyberwatch database.
The size of the database typically depends on the number of assets monitored in Cyberwatch.
Two golden rules must be followed in any circumstances for optimal performances:
- the variable
innodb_buffer_pool_size
should always be superior to the size of the database; - the variable
innodb_log_file_size
should be about equal or slightly superior to the value ofinnodb_buffer_pool_size
/8.
Other parameters are often modified to improve the performance of the database. Ideally, you should follow recommendations given by the tool MySQLTuner
which is commonly used to review a MySQL installation and that makes recommendations adjustments to increase performance and stability.
Using MySQLTuner
MySQLTuner is an open source tool used to audit the configuration of a MySQL database and recommends configurations tweaks to improve the installation performance and stability: https://github.com/major/MySQLTuner-perl
The MySQLTuner tool is embedded in the sidekiq
container of the Cyberwatch application and can be used with the following command:
sudo cyberwatch exec sidekiq mysqltuner
Based on the script recommendations, configuration changes can be applied to the database. If you have any question, please feel free to contact our technical support.