Just read the drill section!
Create a CentOS 8 VM with 4 vcpus, 8G memory, and 60G disk.
TAB
on boot menu, and append the parameter console=ttyS0
.LVM
.tw.pool.ntp.org
.http://mirror01.idc.hinet.net/centos/8/BaseOS/x86_64/os/
.Resize root partition.
Upgrade system.
Install MySQL 5.7 on CentOS 8 / RHEL 8 Linux
There is no MySQL repository for EL 8, so we’ll use EL 7 repository instead. Create a new repository file.
Installing MySQL on Linux Using the MySQL Yum Repository
Create ~/.my.cnf
with content:
Running the command mysql
in the future will automatically log you in with the MySQL root account.
Use AdoptOpenJDK.
Create /etc/yum.repos.d/adoptopenjdk.repo
with content:
The typical result of port is 3306. I'll denote this number by <port>.
The GitHub Readme page instructs that we compile the exporter from source:
This requires that go exists on the host; if not, run dnf install golang
, and make again.
If you face the following message among assertions, check the existence of the executable mysqld_exporter
.
If mysqld_exporter
is found, don't worry about the error message; it's the part of the Makefile that queries the version of mysqld via 'root'@'localhost'
.
As long as mysqld_exporter
is successfully compiled, we are good.
We test it as follows:
By default, mysqld_exporter exposes the metrics for prometheus on port 9104. We intentionally changed it to 8081 with the web.listen-address flag.
If the output of grep is empty, something is wrong, as it should be mysql_up 1
; consider the following:
Then, one would have to write a systemd unit file for mysqld_exporter. This could be quite a hassle. I suggest using podman on CentOS 8.
Podman is a closely-compatible docker alternative.
Podman's is singular in its daemonless container runtime and rootless containers.
However, its default rootless containers are painful when it comes to networking, so we will be running rootfull containers, i.e., running sudo podman
instead of podman
.
The pain comes from having to deal with:
The docker package of CentOS 8 is, in fact, a facade of podman. Running docker in CentOS 8 prints the following message.
To hide this message, simply do:
To install the containerized mysqld_exporter, the mysql grants have to updated. First, find out subnet and gateway associated with podman's default network – podman.
In my case, I have:
According to the offical documentation, it seems that access to mysqld can be granted to a whole subnet but the netmask must be spelled out in full, instead of just the netmask length, e.g., 10.88.0.0/255.255.0.0
.
I'll refer to 10.88.0.1
and 10.88.0.0/255.255.0.0
as <gateway> and <subnet>, respectively.
I grant access to whole subnet as, I won't configure static IPs for containers.
Similarly, we test with the following, where the output should read mysql_up 1
, precisely.
GitHub: tomitribe/JMS-1.1-PubSub-Queue-Example-with-ActiveMQ
With a fresh install, I can confirm that CentOS 8 uses an emulated docker by podman. To prevent networking pitfalls, prepend sudo to every docker command on CentOS 8; CentOS 7 is not subject to this problem.
Create the prometheus config file prom_config.yml
with content:
Start prometheus with:
We will run the mysqld_exporter as a container. The exporter will log into the MySQL database to be monitored and read metrics. Hence, we have to create a special user in the database for this occasion.
Identify the network configuration of the default bridge maintained by the container-runtime.
You should see something like:
This should result in something like:
According to the offical documentation, it seems that access to mysqld can be granted to a whole subnet but the netmask must be spelled out in full, instead of just the netmask length. To assist discussion, I'll define variables <gateway> and <subnet>. Taking the two examples above:
10.88.0.1
for podman.172.17.0.1
for docker.10.88.0.0/255.255.0.0
for podman.172.17.0.0/255.255.0.0
for docker.The SQL user will be called <user> whose password will be <password>.
With MySQL 5.7, the SQL variable MAX_USER_CONNECTIONS
can be set to mitigate the load on the database due to metric-scraping; I'll denote this number by <connections> which is typically 3.
Log in the database as the root user:
Then, run these commands:
Test with:
On success, you should see the string "mysql_up 1" being echoed; if the output is empty, something is wrong.
This will monitor ActiveMQ and its associated JVM. I can't find a way to run the JMX exporter without restarting ActiveMQ.
JMX exporter is meant to be run as a javaagent, e.g.,
I read about dynamically loaded javaagent. With this in mind, I experimented with jattach.
<pid> is determined by:
Unfortunately, this failed with:
The content of jmx_exporter/example_configs/activemq.yml
is:
I will fix the version to 0.15.0. First, clone the GitHub repo to get the configuration file for the JMX exporter. Then, download the the JMX exporter (a jar file).
Suppose the path to the ActiveMQ directory is apache-activemq-5.11.0
.
First, stop the ActiveMQ broker, e.g.,
Edit the file apache-activemq-5.11.0/bin/env
by changing
to
Test with curl localhost:8080/metrics
.