安装

 yum -y  install docker
 systemctl start docker
 docker pull percona/pmm-server:1
 docker create    -v /opt/prometheus/data    -v /opt/consul-data    -v /var/lib/mysql    -v /var/lib/grafana    --name pmm-data    percona/pmm-server:1 /bin/true
 docker run -d    -p 80:80    --volumes-from pmm-data    --name pmm-server    --restart always    percona/pmm-server:1

修改配置,主要修改pmm 数据默认保留时长:

 进入docker:
 
 vi /etc/supervisord.d/pmm.ini 
 
 --storage.local.retention=120h
 --storage.tsdb.retention=120h
 
 需要重启docker

mysql pmm库占用空间问题,系统空间使用100%

agent_log、query_class_metrics、query_global_metrics表,直接truncate 过了一段时间,还是没有数据
尝试重启一个客户端,在进行观察,就有数据了:
pmm-admin restart --all


pmm 监控mysql

 rpm -ivh pmm-client-1.17.2-1.el7.x86_64.rpm 
 pmm-admin config --server <serverip>:<server port>
 pmm-admin add mysql --user pmmuser --password pmmpassword


pmm 监控mongo

rpm -ivh pmm-client-1.17.2-1.el7.x86_64.rpm 
pmm-admin config --server <serverip>:<server port>
pmm-admin add mongodb --cluster <cluster tag>

非正常端口比如端口32000
pmm-admin add mongodb --cluster <cluster tag> --uri 127.0.0.1:32000



pmm 主配置文件:

[root@86ab35507bd5 opt]# cat /etc/supervisord.d/pmm.ini 
[unix_http_server]
chmod = 0700
username = dummy
password = dummy

[supervisord]
childlogdir = /var/log/supervisor
nodaemon = true
pidfile = /tmp/supervisord.pid

[supervisorctl]
username = dummy
password = dummy
user = root

[program:mysql]
priority = 1
user = mysql
command =
    /usr/sbin/mysqld
        --basedir=/usr
        --datadir=/var/lib/mysql
        --plugin-dir=/usr/lib64/mysql/plugin
        --pid-file=/var/run/mysqld/mysqld.pid
        --socket=/var/lib/mysql/mysql.sock
stdout_logfile = /var/log/mysql.log
stderr_logfile = /var/log/mysql.log
autorestart = true

[program:consul]
priority = 2
user = pmm
command =
    /usr/sbin/consul
        agent
        -server
        -data-dir="/opt/consul-data"
        -bootstrap
        -client="0.0.0.0"
        -advertise="127.0.0.1"
        -ui
stdout_logfile = /var/log/consul.log
stderr_logfile = /var/log/consul.log
autorestart = true

[program:grafana]
priority = 3
user = grafana
directory = /usr/share/grafana
environment = HOME=/usr/share/grafana
command =
    /usr/sbin/grafana-server
        --homepath=/usr/share/grafana
        --config=/etc/grafana/grafana.ini
        cfg:default.paths.data=/var/lib/grafana
        cfg:default.paths.logs=/var/log/grafana
        cfg:default.paths.plugins=/var/lib/grafana/plugins
        cfg:default.server.root_url="%%(protocol)s://%%(domain)s:%%(http_port)s/graph"
        ENV_AUTH_BASIC
# use /var/log/grafana/grafana.log
stdout_logfile = NONE
stderr_logfile = NONE
autorestart = true

[program:nginx]
priority = 4
command = nginx
stdout_logfile = /var/log/nginx.log
stderr_logfile = /var/log/nginx.log
autorestart = true

[program:cron]
priority = 5
command = /usr/sbin/crond -n
stdout_logfile = /var/log/cron.log
stderr_logfile = /var/log/cron.log
autorestart = true

[program:qan-api]
priority = 6
user = pmm
environment = PERCONA_DATASTORE_BASEDIR=/usr/share/percona-qan-api/src/github.com/percona/qan-api,PERCONA_DATASTORE_CONF=/etc/percona-qan-api.conf,BASE_PATH=/qan-api
# Sleep to wait for mysql to start up.
command = bash -c "sleep 5 && /usr/sbin/percona-qan-api -srcPath /usr/share/percona-qan-api/src -importPath github.com/percona/qan-api -runMode prod"
stdout_logfile = /var/log/qan-api.log
stderr_logfile = /var/log/qan-api.log
startretries = 60
autorestart = true
stopasgroup = true

[program:prometheus1]
priority = 7
user = pmm
command =
    /usr/sbin/prometheus1
        --config.file=/etc/prometheus1.yml
        --storage.local.path=/opt/prometheus/data
        --web.listen-address=:9094
        --storage.local.retention=120h
        --storage.local.target-heap-size=731709225
        --storage.local.chunk-encoding-version=2
        --web.console.libraries=/usr/share/prometheus1/console_libraries
        --web.console.templates=/usr/share/prometheus1/consoles
        --web.external-url=http://localhost:9094/prometheus1/
        --web.max-connections=15
stdout_logfile = /var/log/prometheus1.log
stderr_logfile = /var/log/prometheus1.log
autorestart = true
stopwaitsecs = 300

[program:prometheus]
priority = 7
user = pmm
# --web.enable-lifecycle: pmm-managed uses /-/reload path to reload config.
command =
    /usr/sbin/prometheus
        --config.file=/etc/prometheus.yml
        --storage.tsdb.path=/opt/prometheus/data/.prom2-data
        --storage.tsdb.retention=120h
        --web.listen-address=:9090
        --web.console.libraries=/usr/share/prometheus/console_libraries
        --web.console.templates=/usr/share/prometheus/consoles
        --web.external-url=http://localhost:9090/prometheus/
        --web.enable-admin-api
        --web.enable-lifecycle
stdout_logfile = /var/log/prometheus.log
stderr_logfile = /var/log/prometheus.log
autorestart = true
stopwaitsecs = 300

# This is here to support data containers of v1.0.4.
[program:createdb]
priority = 8
# Sleep to wait for mysql to start up.
command = bash -c "sleep 5 && mysql -uroot -vv -e \"CREATE DATABASE IF NOT EXISTS orchestrator; GRANT ALL PRIVILEGES ON orchestrator.* TO 'orchestrator'@'localhost' IDENTIFIED BY 'orchestrator'\""
stdout_logfile = /var/log/createdb.log
stderr_logfile = /var/log/createdb.log
startretries = 60
autorestart = unexpected

# support pmm-data containers <1.5.0
[program:createdb2]
priority = 8
# Sleep to wait for mysql to start up.
command = bash -c 'sleep 5 && mysql -uroot -vv -e "CREATE DATABASE IF NOT EXISTS \`pmm-managed\`; GRANT ALL PRIVILEGES ON \`pmm-managed\`.* TO \"pmm-managed\"@localhost IDENTIFIED BY \"pmm-managed\""'
stdout_logfile = /var/log/createdb2.log
stderr_logfile = /var/log/createdb2.log
startretries = 60
autorestart = unexpected

# support pmm-data containers <1.8.0
[program:createdb3]
priority = 8
# Sleep to wait for mysql to start up.
command = bash -c "sleep 5 && mysql -uroot -vv -e \"GRANT SELECT ON pmm.* TO 'grafana'@'localhost' IDENTIFIED BY 'N9mutoipdtlxutgi9rHIFnjM'\""
stdout_logfile = /var/log/createdb3.log
stderr_logfile = /var/log/createdb3.log
startretries = 60
autorestart = unexpected

[program:orchestrator]
priority = 9
user = pmm
directory = /usr/share/orchestrator
# Sleep to wait for mysql to start up.
command = bash -c "sleep 7 && /usr/sbin/orchestrator -verbose http"
stdout_logfile = /var/log/orchestrator.log
stderr_logfile = /var/log/orchestrator.log
startretries = 60
autostart = false
autorestart = true
stopasgroup = true

[program:dashboard-upgrade]
priority = 10
command = /usr/share/percona-dashboards/import-dashboards.py
stdout_logfile = /var/log/dashboard-upgrade.log
stderr_logfile = /var/log/dashboard-upgrade.log
startsecs = 0
startretries = 60
autorestart = unexpected

[program:node_exporter]
priority = 11
command =
    /usr/local/percona/pmm-client/node_exporter
        -web.listen-address=localhost:9100
        -collectors.enabled=diskstats,filefd,filesystem,loadavg,meminfo,netdev,netstat,stat,time,uname,vmstat
stdout_logfile = /var/log/node_exporter.log
stderr_logfile = /var/log/node_exporter.log
autorestart = true

[program:pmm-manage]
priority = 12
command =
    /usr/sbin/pmm-configurator
        -ssh-key-owner pmm
        -grafana-db-path /var/lib/grafana/grafana.db
stdout_logfile = /var/log/pmm-manage.log
stderr_logfile = /var/log/pmm-manage.log
autorestart = true

[program:pmm-managed]
priority = 13
command =
    /usr/sbin/pmm-managed
        -prometheus-config /etc/prometheus.yml
        -prometheus-url http://127.0.0.1:9090/prometheus
        -db-name pmm-managed
        -db-username pmm-managed
        -db-password pmm-managed
stdout_logfile = /var/log/pmm-managed.log
stderr_logfile = /var/log/pmm-managed.log
startretries = 1000000
autorestart = true
[root@86ab35507bd5 opt]#

特别关注文件:

/opt/entrypoint.sh 
/etc/supervisord.conf