A single CMON Controller process is able to monitor one or more database clusters. Each of the clusters requires one exclusive configuration file residing in the /etc/cmon.d/
directory. For instance, the default CMON configuration file is located at /etc/cmon.cnf
, and commonly used to store the default (minimal) configuration for the CMON process to run.
Example of the CMON main configuration file located at /etc/cmon.cnf
:
mysql_port=3306
mysql_hostname=127.0.0.1
mysql_password=cm0nP4ss
mysql_basedir=/usr
hostname=10.0.0.196
logfile=/var/log/cmon.log
rpc_key=390faeffb8166277a4f25336a69efa50915635a7
For the first cluster (cluster_id=1), the configuration options should be stored inside /etc/cmon.d/cmon_1.cnf
. For the second cluster, it would be /etc/cmon.d/cmon_2.cnf
with cluster_id=2
respectively, and so on. The following shows an example content of CMON cluster’s configuration file located at /etc/cmon.d/cmon_4.cnf
:
cluster_id=4
cmon_user=cmon
created_by_job=1
db_stats_collection_interval=30
enable_query_monitor=1
galera_vendor=percona
galera_version=3.x
group_owner=1
host_stats_collection_interval=60
hostname=10.0.0.196
logfile=/var/log/cmon_4.log
mode=controller
monitored_mountpoints=/var/lib/mysql/
monitored_mysql_port=3306
monitored_mysql_root_password='7XU@Wy4nqL9'
mysql_bindir=/usr/bin/
mysql_hostname=127.0.0.1
mysql_password='cm0nP4ss'
mysql_port=3306
mysql_server_addresses=10.0.0.99:3306,10.0.0.253:3306,10.0.0.181:3306
mysql_version=5.6
name='Galera Cluster'
os=redhat
osuser=root
owner=1
pidfile=/var/run
basedir=/usr
repl_password='9hHRgQLSsZz3Vd4a'
repl_user=rpl_user
rpc_key=3V0RaV6dE8KSyClE
ssh_identity=/root/.ssh/id_rsa
ssh_port=22
type=galera
vendor=percona
An example of CMON configuration file hierarchy is as follows:
Example cluster | Configuration file | Cluster identifier | Log file location |
---|---|---|---|
Default configuration | /etc/cmon.cnf |
N/A | logfile=/var/log/cmon.log |
Cluster #1 (Galera) | /etc/cmon.d/cmon_1.cnf |
cluster_id=1 |
logfile=/var/log/cmon_1.log |
Cluster #2 (MongoDB) | /etc/cmon.d/cmon_2.cnf |
cluster_id=2 |
logfile=/var/log/cmon_2.log |
Cluster #N (cluster type) | /etc/cmon.d/cmon_N.cnf |
cluster_id=N |
logfile=/var/log/cmon_N.log |
cluster_id
and logfile
are two important configuration options to distinguish the cluster.The CMON Controller will import the configuration options defined in each configuration file into the CMON database during the process starts up. Once loaded, CMON then use all the loaded information to manage clusters based on the cluster_id
value.