前言:MySQL监控也用过好多产品,包括zabbix、Lepus、PMM,想比较而言,PMM监控更加全面,安装配置也更加简单。
一、Server端安装
server端安装非常简单,我们采用docker的方式来部署。
1.拉取镜像
docker pull percona/pmm-server:latest
2.创建PMM数据容器
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
3.创建PMM服务器容器
docker run -d -p 80:80 \--volumes-from pmm-data \--name pmm-server \-e SERVER_USER=test \-e SERVER_PASSWORD=test \-e ORCHESTRATOR_ENABLED=true \--restart always \percona/pmm-server:latest
4.查看服务启动
[root@db-monitor-01 tmp]# ps -ef|grep dockerroot 8531 1 0 10:38 ? 00:00:05 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --seccomp-profile=/etc/docker/seccomp.json --selinux-enabled --log-driver=journald --signature-verification=false --storage-driver overlay2root 8538 8531 0 10:38 ? 00:00:03 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc --runtime-args --systemd-cgroup=trueroot 9095 8531 0 10:56 ? 00:00:00 /usr/libexec/docker/docker-proxy-current -proto tcp -host-ip 0.0.0.0 -host-port 80 -container-ip 172.17.0.2 -container-port 80root 9100 8538 0 10:56 ? 00:00:00 /usr/bin/docker-containerd-shim-current 7c5656534fed82420cba57ec9ab3f929b242802dae2dcf3fbb400859d2517b6d /var/run/docker/libcontainerd/7c5656534fed82420cba57ec9ab3f929b242802dae2dcf3fbb400859d2517b6d /usr/libexec/docker/docker-runc-currentroot 9660 2640 0 11:25 pts/1 00:00:00 grep --color=auto docker
二、Client安装
1.安装rpm包
rpm -ivh pmm-client-1.9.1-1.el7.x86_64.rpm
2.连接server
pmm-admin config --server server_ip --bind-address=client_ip --client-address=client_ip --server-user=admin --server-password=xxx --client-name=xxx
3.收集数据
pmm-admin add mysql --user=pmm --password=xxxx --port=3306
三、常用操作命令
PMM Client相关
[root@Mariadb-04 tmp]# pmm-admin --helpUsage:pmm-admin [flags]pmm-admin [command]Available Commands:config Configure PMM Client. 配置PMM客户端add Add service to monitoring. 增加监控remove Remove service from monitoring. 删除监控服务list List monitoring services for this system. 列出监控服务info Display PMM Client information (works offline). 打印PMM客户端信息check-network Check network connectivity between client and server. 检查网络ping Check if PMM server is alive. ping server端start Start monitoring service.开启服务stop Stop monitoring service.停止服务restart Restart monitoring service.重启服务show-passwords Show PMM Client password information (works offline).显示客户端密码purge Purge metrics data on PMM server.删除PMM server端监控信息repair Repair installation.重新安装uninstall Removes all monitoring services with the best effort.删除所有服务help Help about any commandFlags:-c, --config-file string PMM config file (default "/usr/local/percona/pmm-client/pmm.yml")-h, --help help for pmm-admin--verbose verbose output-v, --version show versionUse "pmm-admin [command] --help" for more information about a command.
Docker相关
[root@db-monitor-01 tmp]# docker --helpUsage: docker COMMANDA self-sufficient runtime for containersOptions:--config string Location of client config files (default "/root/.docker")-D, --debug Enable debug mode--help Print usage-H, --host list Daemon socket(s) to connect to (default [])-l, --log-level string Set the logging level ("debug", "info", "warn", "error", "fatal") (default "info")--tls Use TLS; implied by --tlsverify--tlscacert string Trust certs signed only by this CA (default "/root/.docker/ca.pem")--tlscert string Path to TLS certificate file (default "/root/.docker/cert.pem")--tlskey string Path to TLS key file (default "/root/.docker/key.pem")--tlsverify Use TLS and verify the remote-v, --version Print version information and quitManagement Commands:container Manage containersimage Manage imagesnetwork Manage networksnode Manage Swarm nodesplugin Manage pluginssecret Manage Docker secretsservice Manage servicesstack Manage Docker stacksswarm Manage Swarmsystem Manage Dockervolume Manage volumesCommands:attach Attach to a running containerbuild Build an image from a Dockerfilecommit Create a new image from a container's changescp Copy files/folders between a container and the local filesystemcreate Create a new containerdiff Inspect changes on a container's filesystemevents Get real time events from the serverexec Run a command in a running containerexport Export a container's filesystem as a tar archivehistory Show the history of an imageimages List imagesimport Import the contents from a tarball to create a filesystem imageinfo Display system-wide informationinspect Return low-level information on Docker objectskill Kill one or more running containersload Load an image from a tar archive or STDINlogin Log in to a Docker registrylogout Log out from a Docker registrylogs Fetch the logs of a containerpause Pause all processes within one or more containersport List port mappings or a specific mapping for the containerps List containerspull Pull an image or a repository from a registrypush Push an image or a repository to a registryrename Rename a containerrestart Restart one or more containersrm Remove one or more containersrmi Remove one or more imagesrun Run a command in a new containersave Save one or more images to a tar archive (streamed to STDOUT by default)search Search the Docker Hub for imagesstart Start one or more stopped containersstats Display a live stream of container(s) resource usage statisticsstop Stop one or more running containerstag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGEtop Display the running processes of a containerunpause Unpause all processes within one or more containersupdate Update configuration of one or more containersversion Show the Docker version informationwait Block until one or more containers stop, then print their exit codesRun 'docker COMMAND --help' for more information on a command.
四、监控界面





五、排错
Aug 17 21:07:24 localhost dockerd: time="2016-08-17T21:07:24.864612251+08:00" level=error msg="Attempting next endpoint for push after error: Get https://192.168.41.80:5001/v2/: dial tcp 192.168.41.80:5001: getsockopt: connection refused"Aug 17 21:07:24 localhost dockerd: time="2016-08-17T21:07:24.864884008+08:00" level=error msg="Attempting next endpoint for push after error: Get https://192.168.41.80:5001/v1/_ping: dial tcp 192.168.41.80:5001: getsockopt: connection refused"
类似于如上错误解决方法:
vim /etc/docker/daemon.json{ "insecure-registries":["myregistry.example.com:5000"] }Restart docker daemonsystemctl restart docker.service
