安装pmm(Percona Monitoring and Management)
环境:
Os:Centos 7
pmm2
####################################服务端安装#######################
服务端安装我们这里使用docker的方式部署
一、server端部署:
1.监控机器安装docker:
ip:192.168.56.101
操作系统版本:
[root@localhost /]# cat /etc/centos-release
CentOS Linux release 7.5.1804 (Core)
安装:
[root@localhost /]#yum install -y docker
启动:
[root@localhost /]#systemctl start docker
[root@localhost /]#systemctl enable docker
2.拉取PMM服务器映像
[root@localhost /]# docker pull percona/pmm-server:2
Trying to pull repository docker.io/percona/pmm-server ...
2: Pulling from docker.io/percona/pmm-server
2d473b07cdd5: Pull complete
53d9fefd2a3f: Pull complete
Digest: sha256:b80df76e70255d8399e2cfdd37c7d493958e457ccb3bbc123e17efc985cd266b
Status: Downloaded newer image for docker.io/percona/pmm-server:2
3.创建一个PMM数据容器:
[root@localhost /]#docker create -v /opt/prometheus/data -v /opt/consul-data -v /var/lib/mysql -v /var/lib/grafana --name pmm-data percona/pmm-server:2 /bin/true
这里的 -v 指定的是指容器里面的目录,而不是本地机器的目录
4.创建和运行 PMM Server Container:
[root@localhost /]#docker run -d -p 80:80 -p 443:443 --volumes-from pmm-data --name pmm-server --restart always percona/pmm-server:2
这里需要指定端口映射-p 443:443,pmm客户端需要改端口注册到pmm服务器
5. 查看 Docker 运行状态
[root@localhost /]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e18cf4366179 percona/pmm-server:2 "/opt/entrypoint.sh" 30 seconds ago Up 27 seconds (healthy) 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp pmm-server
6.登录
http://192.168.1.136:80
默认的账号密码为:admin/admin,初次登录修改密码,为这里修改为admin123
有些浏览器报如下的错误
If you're seeing this Grafana has failed to load its application files
1. This could be caused by your reverse proxy settings.
2. If you host grafana under subpath make sure your grafana.ini root_url setting includes subpath. If not using a reverse proxy make sure to set serve_from_sub_path to true.
3. If you have a local dev build make sure you build frontend using: yarn start, yarn start:hot, or yarn build
4. Sometimes restarting grafana-server can help
5. Check if you are using a non-supported browser. For more information, refer to the list of supported browsers.
#################################客户端安装######################
1.下载pmm-client
登录https://www.percona.com/downloads/pmm-client下载客户端
我这里下载的是pmm2-client-2.12.0-6.el7.x86_64.rpm
2.12版本之后的不提供centos6的安装包
2.安装
[root@cdc-henan-cdhworker01 soft]# rpm -ivh pmm2-client-2.12.0-6.el7.x86_64.rpm
centos 6的安装
rpm -ivh pmm2-client-2.12.0-6.el6.x86_64.rpm
3.这个时候有相应的命令了
[root@cdc-henan-cdhworker01 soft]# pmm-admin --version
ProjectName: pmm-admin
Version: 2.12.0
PMMVersion: 2.12.0
Timestamp: 2020-12-01 11:57:04 (UTC)
FullCommit: e81fe912b1029095f310945f831abc71c824e139
4.注册到server
[root@cdc-henan-cdhworker01 soft]# pmm-admin config --server-insecure-tls --server-url=https://admin:admin123@192.168.1.136:443
1)192.168.1.136 is the address of your PMM Server.
2)443是默认端口,如果之前docker安装server改了端口请仔细修改保证对应
3)admin/adminPassword 是登录PMM Server页面的用户名密码
5.mysql创建监控用户
grant select,process,super,replication client, reload on *.* to 'pmm'@'%' identified by 'mysql';
6.添加mysql实例
[root@cdc-henan-cdhworker01 soft]# pmm-admin add mysql --username pmm --password 'mysql' mysql-192.168.1.197_3306 192.168.1.197:3306
MySQL Service added.
Service ID : /service_id/76579b88-4947-4916-87fd-964fd4e6ceee
Service name: mysql-192.168.1.197_3306
Table statistics collection disabled (the limit is 1000, the actual table count is 2466).
7.查看状态
pmm-admin list
pmm-admin status
[root@dev-env-22 soft]# pmm-admin list
Service type Service name Address and port Service ID
MySQL mysql-192.168.1.22_3306 192.168.1.22:3306 /service_id/7038ae6c-7d44-4c67-9b2e-5f345af984a5
Agent type Status Metrics Mode Agent ID Service ID
pmm_agent Connected /agent_id/80fa91ee-300f-4a54-8352-faffea65ca55
node_exporter Running push /agent_id/c6a3061f-6bea-4b68-9b92-f43364451e6c
mysqld_exporter Running push /agent_id/45508fb2-2242-4c86-b861-2d23aa21e25b /service_id/7038ae6c-7d44-4c67-9b2e-5f345af984a5
mysql_slowlog_agent Running /agent_id/8253c94c-04be-4908-b424-4d5826ab4c0d /service_id/7038ae6c-7d44-4c67-9b2e-5f345af984a5
vmagent Running push /agent_id/410b0748-8260-4ea2-af0e-bf8d8c1c5839
[root@dev-env-22 soft]# pmm-admin status
Agent ID: /agent_id/80fa91ee-300f-4a54-8352-faffea65ca55
Node ID : /node_id/d01f7d5b-8cb4-4c60-9633-2fd4c81f29d9
PMM Server:
URL : https://192.168.1.136:443/
Version: 2.37.1
PMM Client:
Connected : true
Time drift : -4.526555ms
Latency : 575.663μs
pmm-admin version: 2.12.0
pmm-agent version: 2.12.0
Agents:
/agent_id/410b0748-8260-4ea2-af0e-bf8d8c1c5839 vmagent Running
/agent_id/45508fb2-2242-4c86-b861-2d23aa21e25b mysqld_exporter Running
/agent_id/8253c94c-04be-4908-b424-4d5826ab4c0d mysql_slowlog_agent Running
/agent_id/c6a3061f-6bea-4b68-9b92-f43364451e6c node_exporter Running
删除服务
[root@dev-env-22 log]# pmm-admin remove mysql mysql-192.168.1.22_3306
Service removed.