Skip to content

Commit

Permalink
New Blog Post for PMM on a Pi (#804)
Browse files Browse the repository at this point in the history
* pi-arm-pmm-0.0.1

* image added

* new images

* Update 2023-08-15-pi-arm-pmm.md

* verbage clean up

* pmm client 2.27

---------

Co-authored-by: cetanhota <[email protected]>
  • Loading branch information
cetanhota and cetanhota authored Aug 16, 2023
1 parent 5583ede commit 9a8c0fd
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 0 deletions.
Binary file added assets/blog/2023/08/fresh-raspi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/blog/2023/08/node-summary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/blog/2023/08/pmm-view2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
165 changes: 165 additions & 0 deletions content/blog/2023/2023-08-15-pi-arm-pmm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
---
title: 'PMM Client on Raspberry Pi 4'
date: "2023-08-15T00:00:00+00:00"
draft: false
tags: ['Percona', 'MySQL', 'PMM', 'monitoring', 'performance']
authors:
- wayne
images:
- blog/2023/08/fresh-raspi.png
slug:
---
This will be the third in my series of Percona Products on a Raspberry Pi. My previous posts:
- [How to Build a Percona Server "Stack" on a Raspberry Pi 3+
](https://percona.community/blog/2019/08/01/how-to-build-a-percona-server-stack-on-a-raspberry-pi-3/)
- [Raspberry Pi Bullseye Percona Server 64bit](https://percona.community/blog/2022/04/05/percona-server-raspberry-pi/)

Before I get started I would like to thank [guriandoro](https://www.percona.com/blog/compiling-a-percona-monitoring-and-management-v2-client-in-arm-raspberry-pi-3/), for the work he did in complying the PMM Client tools.

Now as most of you know I love the Raspberry Pi and I love running MySQL on it for my hobby projects. I recently decided that I need to be able to monitor the two MySQL Server here at home.

**In this BLOG we will be using PMM Client 2.27 and PMM Server version 2.39.**

## Prerequisites

**Important Note:** Your Raspberry Pi must be on Raspbian Bullseye.

I will assume if you have made it this far into the BLOG post, then you already have a running PMM Server. If not, you can read about installing a PMM Server [here](https://www.percona.com/software/pmm/quickstart).

### Add the pmm user to your MySQL Server
```
CREATE USER 'pmm'@'127.0.0.1' IDENTIFIED BY 'pass' WITH MAX_USER_CONNECTIONS 10;
GRANT SELECT, PROCESS, REPLICATION CLIENT, RELOAD, BACKUP_ADMIN ON *.* TO 'pmm'@'localhost';
```

## The following steps should be run on your Raspberry Pi

---

### Download the pre-complied pmm-client tools

These were complied based on 2.27 source code.

```
cd
wget https://github.com/cetanhota/pi4-arm-pmm-client/archive/refs/heads/main.zip
unzip main.zip
```

Once we have the client unzipped its a good idea to verify that the tools will work on your Raspberry Pi.

```
cd ~/pi4-arm-pmm-client-main/raspbian-bullseye
./pmm-agent --version
```
You should get output like below.
```
ProjectName: pmm-agent
ProjectName: pmm-agent
Version: 2.27.0-84-g78b8519-dirty
PMMVersion: 2.27.0-84-g78b8519-dirty
Timestamp: 2023-08-16 00:57:34 (UTC)
FullCommit: 78b85198ad1e2c319d4012ef5ae338f389e2000a
Branch: main
```

If the pmm-agent displayed info like above, then you good to keep moving down the document. If you ran into issues please post in the comments and we can see what can be done to get you working. The only problem I ran in to was that the root user could not execute the client tools.

## Setup install directories

We need to create the install directory and move files to the correct locations.
```
sudo mkdir -p /usr/local/percona
sudo mkdir -p /usr/local/percona/pmm2
sudo mkdir -p /usr/local/percona/pmm2/tools
sudo mkdir -p /usr/local/percona/pmm2/config
sudo mkdir -p /usr/local/percona/pmm2/exporters
sudo mkdir -p /usr/local/percona/exporters
sudo mkdir -p /usr/local/percona/exporters/collectors/textfile-collector/high-resolution
sudo mkdir -p /usr/local/percona/exporters/collectors/textfile-collector/medium-resolution
sudo mkdir -p /usr/local/percona/exporters/collectors/textfile-collector/low-resolution
```

### Copy files into directories
```
cd ~/pi4-arm-pmm-client-main/raspbian-bullseye
sudo cp pmm-admin pmm-agent /usr/local/bin
sudo cp node_exporter vmagent /usr/local/percona/pmm2/exporters
```

## Configure the PMM Client
Its time to configure and test the PMM Client for the MySQL server where we are install PMM Client.

Please make sure you have the following three items:

1. PMM Server Hostname or IP Address
2. PMM Server admin ID
3. PMM Server admin Password

```
sudo pmm-agent setup --config-file=/usr/local/percona/pmm2/config/pmm-agent.yaml\
--server-address=<YOUR-PMM-Server> --server-insecure-tls\
--server-username=<YOURADMIN> --server-password=<YOURPASSWORD>
```
Now that the PMM Client has been configured, lets move on to starting the PMM Client.

## Start the PMM Client

```
sudo pmm-agent --config-file=/usr/local/percona/pmm2/config/pmm-agent.yaml
```
Verify by reviewing the client is running correctly. If all is well you should see output like:
```
INFO[2023-08-15T17:00:34.294-04:00] Loading configuration file /usr/local/percona/pmm2/config/pmm-agent.yaml. component=main
INFO[2023-08-15T17:00:34.295-04:00] Using /usr/local/percona/pmm2/exporters/node_exporter component=main
INFO[2023-08-15T17:00:34.295-04:00] Using /usr/local/percona/pmm2/exporters/mysqld_exporter component=main
INFO[2023-08-15T17:00:34.295-04:00] Using /usr/local/percona/pmm2/exporters/mongodb_exporter component=main
INFO[2023-08-15T17:00:34.295-04:00] Using /usr/local/percona/pmm2/exporters/postgres_exporter component=main
INFO[2023-08-15T17:00:34.295-04:00] Using /usr/local/percona/pmm2/exporters/proxysql_exporter component=main
INFO[2023-08-15T17:00:34.295-04:00] Using /usr/local/percona/pmm2/exporters/rds_exporter component=main
INFO[2023-08-15T17:00:34.295-04:00] Using /usr/local/percona/pmm2/exporters/azure_exporter component=main
INFO[2023-08-15T17:00:34.296-04:00] Using /usr/local/percona/pmm2/exporters/vmagent component=main
INFO[2023-08-15T17:00:34.296-04:00] Starting... component=client
INFO[2023-08-15T17:00:34.296-04:00] Starting local API server on http://127.0.0.1:7777/ ... component=local-server/JSON
INFO[2023-08-15T17:00:34.296-04:00] Connecting to https://admin:***@192.168.1.127:443/ ... component=client
INFO[2023-08-15T17:00:34.298-04:00] Started. component=local-server/JSON
INFO[2023-08-15T17:00:34.320-04:00] Connected to 192.168.1.127:443. component=client
INFO[2023-08-15T17:00:34.320-04:00] Establishing two-way communication channel ... component=client
INFO[2023-08-15T17:00:34.341-04:00] Two-way communication channel established in 21.349589ms. Estimated clock drift: -84.399159ms. component=client
```
At this point press ctl+c to stop the pmm-agent.

If you want to start the pmm-agent again and running the background use this command:
```
sudo nohup pmm-agent --config-file=/usr/local/percona/pmm2/config/pmm-agent.yaml &
```
You may choose a different startup process for the PMM Client based on personal preference.

## Add pt-summary to the PMM Client

```
cd /usr/local/percona/pmm2/tools
sudo wget percona.com/get/pt-summary
sudo chmod ugo+x pt-summary
```

Let's see summary in action:

![image](blog/2023/08/node-summary.png)

## Add your Raspberry Pi MySQL Server to PMM Server

I am sure most of you know how to add a server to your existing PMM Server but if you have not done this before here is what you need to do.

1. Connect to your PMM Server.
2. Use pmm-admin command to add server for monitoring.

```
/usr/local/percona/pmm2/bin/pmm-admin add mysql --service-name=<MYSQL SERVER NAME> --server-insecure-tls --server-url=https://<YOUR ADMIN>:<YOUR PASSWORD>@localhost --username=<DB USER> --password=<DB PASSWORD> --host=<MYSQL SERVER NAME>
```

## PMM Server Screen Shoot

![image](blog/2023/08/pmm-view2.png)

I hope you found this helpful. I know enjoyed learning the process and documenting to share with you!

0 comments on commit 9a8c0fd

Please sign in to comment.