今天我们来研究一下,怎么用PMM监控MongoDB cluster。

安装docker

安装docker依赖

yum install -y yum-utils device-mapper-persistent-data lvm2

配置docker yum源

yum-config-manager  --add-repo   https://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --enable docker-ce-nightly
yum-config-manager --enable docker-ce-test
yum-config-manager --disable docker-ce-nightly

安装docker

yum -y install docker-ce docker-ce-cli containerd.io
systemctl start docker
systemctl enable docker

安装PMM Server

创建PMM数据容器

docker pull percona/pmm-server:latest
docker create \
-v /opt/prometheus/data \
-v /opt/consul-data \
-v /var/lib/mysql \
-v /var/lib/grafana \
--name pmm-data \
percona/pmm-server:latest /bin/true

运行PMM容器

docker run -d -p 443:443 --volumes-from pmm-data --name pmm-server -e SERVER_USER=admin -e SERVER_PASSWORD=admin --restart always percona/pmm-server:latest

查看docker运行状态

docker ps -a

安装PMM Client

安装pmm-client

RPM包下载地址: https://downloads.percona.com/downloads/pmm2/2.16.0/binary/redhat/7/x86_64/pmm2-client-2.16.0-6.el7.x86_64.rpm 所有client节点:

pmm-admin config --server-url=http://admin:admin@172.16.254.139

添加client节点监控

我的环境是MongoDB分片集群,三个节点安装了mongos 所有client节点:

pmm-admin add mongodb --host 172.16.254.136 --port 30000 --username admin --password admin123
pmm-admin add mongodb --host 172.16.254.137 --port 30000 --username admin --password admin123
pmm-admin add mongodb --host 172.16.254.138 --port 30000 --username admin --password admin123

查看监控信息

浏览器地址栏输入:http://172.16.254.139:443 用户名和密码均为admin(前边配置)

进入各个版块查看监控信息

注意:

PMM最新版本是2.X,我们拉取的最新的PMM Server镜像是2.X,所以client端安装pmm-client版本也必须是2.X(pmm2-client),否则报如下错误:

pmm-admin config --server 172.16.254.139 --server-user admin --server-password admin
Unable to connect to PMM server by address: 172.16.254.139

Even though the server is reachable it does not look to be PMM server.
Check if the configured address is correct. Unexpected response code: 404 (Not Found
)