Compiling a Percona Monitoring and Management v2 Client in ARM Architecture

Percona Monitoring and Management ARM

Percona Monitoring and Management ARMIn this blog, we are going to see how to compile a Percona Monitoring and Management 2 (PMM v2) client in ARM. For this, we are going to use an AWS EC2 ARM instance with Amazon Linux 2.

Installing Dependencies

First, let’s get some basic packages out of the way, which probably are installed in your environment already:

sudo yum -y install vim wget git

And some needed for compiling:

sudo yum -y install glibc-static.aarch64 gcc.aarch64

Then, let’s download the necessary GitHub projects to our Go source path:

mkdir -p ~/go/src/github.com/percona/
cd $_
git clone https://github.com/percona/pmm-admin.git
git clone https://github.com/percona/pmm-agent.git
git clone https://github.com/percona/node_exporter.git

We will focus on getting some basic functionality in this round, so we’ll only install the OS metrics exporter. If needed, you can download and compile other exporters like MySQL, MongoDB, or PostgreSQL (which are listed on the GitHub PMM projects page).

Now let’s go ahead and install Go from their tar.gz distribution, since we will need the latest available versions, and package managers generally fall behind. I tried using package manager versions at first, but was getting errors due to outdated libraries due to it. If you want to try, go ahead, but know that if you get any errors it is very possible to be due to that.

cd /tmp/
wget https://golang.org/dl/go1.14.6.linux-arm64.tar.gz
tar xzf go1.14.6.linux-arm64.tar.gz
sudo mv go /usr/local/
sudo ln -s /usr/local/go/bin/go /usr/bin/go

If you need to set your Go path to something else than default (~/go/) you can read more about it in the How to Write Go Code (with GOPATH) documentation section. Note that PMM doesn’t support the use of Go Modules yet.

Compiling

Ok, we are ready to begin our first compilation! We’ll begin with the pmm-admin tool:

cd ~/go/src/github.com/percona/pmm-admin
make release

This process should be straightforward and proceed without errors. Then we can compile pmm-agent. In this case, we encounter the first caveat. The error we would get is linked to the pg_query_go module, and is fully documented in its own GitHub issue:

https://github.com/lfittl/pg_query_go/issues/27 

We will use that workaround until there is better support for ARM in the future (note how we added a step in the middle, that involves getting a file with wget). We are now tracking this under Jira ticket PMM-6384.

cd ~/go/src/github.com/percona/pmm-agent
wget -O vendor/github.com/lfittl/pg_query_go/parser/include/port/atomics/arch-arm.h \
  https://raw.githubusercontent.com/postgres/postgres/master/src/include/port/atomics/arch-arm.h
make release

After this, the last step is to build the node_exporter:

cd ~/go/src/github.com/percona/node_exporter/
make build

Finally, let’s move the generated binaries under the correct paths:

cd ~/go/src/github.com/percona/
sudo cp -a pmm-admin/bin/pmm-admin /usr/local/bin
sudo cp -a pmm-agent/bin/pmm-agent /usr/local/bin

sudo mkdir -p /usr/local/percona/pmm2/exporters/
sudo cp -a node_exporter/node_exporter \
  /usr/local/percona/pmm2/exporters/

And since we are on it, let’s create the following directories to avoid unnecessary errors (and logs being flooded) down the line:

cd /usr/local/percona/pmm2/
sudo mkdir -p collectors/textfile-collector/high-resolution
sudo mkdir -p collectors/textfile-collector/medium-resolution
sudo mkdir -p collectors/textfile-collector/low-resolution

Starting the PMM Client

We are now all set, and ready to set up the PMM client! The following steps will need root privileges, so we log in as root as the first step. Additionally, you will need to tune the ADDR variables according to your own environment. Note that I’m assuming you have a PMM server node already set up and reachable, since this is out of scope for this blog (if needed, check the references section below).

sudo su -
mkdir -p /usr/local/percona/pmm2/config/

PMM_CLIENT_ADDR='172.30.0.17'
PMM_SERVER_ADDR='172.30.0.79:443'
NODE_NAME='aws_arm_1'

pmm-agent setup ${PMM_CLIENT_ADDR} generic ${NODE_NAME} \
  --config-file=/usr/local/percona/pmm2/config/pmm-agent.yaml \
  --server-address=${PMM_SERVER_ADDR} --server-insecure-tls \
  --server-username=admin --server-password=admin

Finally, we can really start the PMM client agent process:

pmm-agent --config-file=/usr/local/percona/pmm2/config/pmm-agent.yaml

This will leave the process running in the foreground, but for the initial testing it will suffice. If you want, you can also create your own systemctl service for it, create your own script to run it in the background, or manually redirect logs to a file and run in the background with:

pmm-agent --config-file=/usr/local/percona/pmm2/config/pmm-agent.yaml > /tmp/pmm_agent.log &

Check if things are running ok with the following command:

shell> pmm-admin list
Service type  Service name         Address and port  Service ID
Agent type                  Status     Agent ID                                        Service ID
pmm_agent                   Connected  /agent_id/8b801812-6d65-4750-a899-43a2815082e0
node_exporter               Running    /agent_id/53f6011d-6e0f-4537-af01-8f1b110e28f1

If you see node_exporter -> Running, it worked! We can now enjoy our OS-related graphs from our ARM server in PMM:

ARM server in PMM

References:

  • How to install PMM server using Docker
  • For ease of use, all commands mentioned above are detailed in a public gist.
  • Lastly, the binaries can be found in this github project. They may not work in your node in particular, and you may need to do the manual compilation steps yourself, but I’ve published the resulting binaries here in case they help 🙂 Also note that they are for version 2.9.0, which is current latest at the time of writing, and that this project will not necessarily be kept up to date in the future. We are always glad to help, though, so feel free to create a new issue or forum question if needed.

by Agustín via Percona Database Performance Blog

Comments