zoukankan      html  css  js  c++  java
  • PMM安装和部署

    ###### 服务器信息

    ### 生产环境

    IP     10.0.5.179

    ### 开发环境

    IP     10.0.2.76

    ###### PMM构构图

    PMM监控工具自带监控LINUX,MySQL,MongoDB
    pmm重要组件 grafana,prometheus
    https://grafana.com/ //grafana作为数据展示
    https://prometheus.io/ //数据采集数据库

    ###### mysql数据库服务配置

    https://www.percona.com/doc/percona-monitoring-and-management/conf-mysql.html

    innodb_monitor_enable = all

    docker run -d -p 80:80 --volumes-from pmm-data --name pmm-server -e SERVER_USER=pmm -e SERVER_PASSWORD=123456 -e METRICS_MEMORY=786432 --restart always --init percona/pmm-server:1.2.0

    PMM 1.2.0需要加 METRICS_MEMORY=786432

    https://www.percona.com/forums/questions-discussions/percona-monitoring-and-management/49047-pmm-1-2-0-a-lot-of-data-is-not-shown

    ###### PMM监控工具安装
    参考:https://www.percona.com/doc/percona-monitoring-and-management/deploy/index.html
           https://docs.docker.com/engine/installation/linux/centos 


    ### 第一步:安装docker

    1.yum remove docker docker-common container-selinux docker-selinux docker-engine 

    yum install -y yum-utils

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

    yum makecache fast

    yum list docker-ce.x86_64 --showduplicates |sort -r

    yum install docker-ce.x86_64

    ### 修改默认存储路径

    vim /usr/lib/systemd/system/docker.service 

    ExecStart=/usr/bin/dockerd -g /apps/docker/pmm (线上环境179的配置)

    1. mkdir /home/docker(你想要docker存放image的目录)

    2. systemctl stop docker

    3. vi /usr/lib/systemd/system/docker.service

    4. 添加 -g /home/docker (本地开发环境10.0.2.76的配置)

    [Unit]
    Description=Docker Application Container Engine
    Documentation=https://docs.docker.com
    After=network.target docker.socket
    Requires=docker.socket

    [Service]
    Type=notify
    ExecStart=/usr/bin/docker daemon -g /home/docker -H fd://
    MountFlags=slave
    LimitNOFILE=1048576
    LimitNPROC=1048576
    LimitCORE=infinity

    [Install]
    WantedBy=multi-user.target

    ### 启动

    systemctl start docker



    ### 第二步:安装PMM服务端安装

    # 配置加速镜像

    1.curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://396e823a.m.daocloud.io //开启镜像加速,由于docker镜像被墙

    [root@pgxl-71 ~]# curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://396e823a.m.daocloud.io
    docker version >= 1.12
    {"registry-mirrors": ["http://396e823a.m.daocloud.io"]}
    Success.
    You need to restart docker to take effect: sudo systemctl restart docker

    systemctl restart docker // docker重启

     # 添加pmm-server镜像

    docker pull percona/pmm-server:latest

    # 添加数据容器

    2.Create a PMM Data Container //数据目录
    $ 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.1.3 /bin/true

    # 启动pmm-server容器
    3.Create and Run the PMM Server Container //创建PMM Server
    $ docker run -d
    -p 80:80
    --volumes-from pmm-data
    --name pmm-server
    -e SERVER_USER=admin
    -e SERVER_PASSWORD=password 
    --restart always
    --init
    percona/pmm-server:1.1.3


    ### 第三步:安装PMM客户端安装
    参考:https://www.percona.com/doc/percona-monitoring-and-management/deploy/client/yum.html#install-client-yum
    1.yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
    yum install pmm-client

    [root@pgxl-71 ~]# pmm-admin --help
    Usage:
    pmm-admin [flags]
    pmm-admin [command]

    Available Commands:
    config Configure PMM Client.
    add Add service to monitoring.
    remove Remove service from monitoring.
    list List monitoring services for this system.
    info Display PMM Client information (works offline).
    check-network Check network connectivity between client and server.
    ping Check if PMM server is alive.
    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.
    repair Repair installation.
    uninstall Removes all monitoring services with the best effort.

    Flags:
    -c, --config-file string PMM config file (default "/usr/local/percona/pmm-client/pmm.yml")
    -v, --version show version

    Use "pmm-admin [command] --help" for more information about a command.


    2.添加MongoDB监控服务,自动会添加Linux相关监控
    ##### 客户端配置
    pmm-admin config --server 10.0.0.148 --server-user admin --server-password password --client-name hostname //

    ##### mongo服务器配置
    pmm-admin add mongodb --cluster cluster1 --uri mongodb://root:123456@localhost:27017/admin
    //cluster1 为自定义集群名
    //--uri mongodb://root:123456@localhost:27017/admin 为monogo链地址

    3.添加MySQL监控服务,自动会添加Linux相关监控
    pmm-admin config --server 10.0.0.148 --server-user admin --server-password password --client-name hostname

    以上3,4操作都会写入配置文件 /usr/local/percona/pmm-client/pmm.yml
    pmm-admin 已经封装对prometheus修改

    pmm-admin add mysql --user root --socket /apps/dbdat/mysql-5.7.17/mysql.sock --password 123456 mysql143

    4.添加redis监控服务(生产线已不使用该方式)

    wget https://github.com/oliver006/redis_exporter/releases/download/v0.11/redis_exporter-v0.11.linux-amd64.tar.gz
    tar -zxvf redis_exporter-v0.11.linux-amd64.tar.gz

    [root@pgxl-76 tmp]# ./redis_exporter --help
    Usage of ./redis_exporter:
    -check-keys string
    Comma separated list of keys to export value and length/size
    -debug
    Output verbose debug information
    -log-format string
    Log format, valid options are txt and json (default "txt")
    -namespace string
    Namespace for metrics (default "redis")
    -redis.addr string
    Address of one or more redis nodes, separated by separator (default "redis://localhost:6379")
    -redis.alias string
    Redis instance alias for one or more redis nodes, separated by separator
    -redis.password string
    Password for one or more redis nodes, separated by separator
    -separator string
    separator used to split redis.addr, redis.password and redis.alias into several elements. (default ",")
    -version
    Show version information and exit
    -web.listen-address string
    Address to listen on for web interface and telemetry. (default ":9121")
    -web.telemetry-path string
    Path under which to expose metrics. (default "/metrics")

    启动客户端 ./redis_exporter -redis.addr redis://localhost:6379

    redis_exporter 由于没有集成到PMM服务,所以需要修改prometheus,登入PMM服务端 
    [root@pgxl-76 tmp]# docker exec -it pmm-server /bin/bash
    [root@a5914a0f9617 opt]# vim /etc/prometheus.yml //添加以下
    - job_name: redis_exporter
    static_configs:
    - targets: ['10.0.2.76:9121']

    5添加linux监控

    pmm-admin config --server 10.0.5.179 --server-user pmm --server-password XXXXXXX --client-name PGXL182
    pmm-admin add linux:metrics

    ###邮箱报警添加
    进入docker
    docker exec -it pmm-server /bin/bash

    编缉grafana.ini
    vim /etc/grafana/grafana.ini

    [smtp]
    enabled = true
    host = smtp.healthmall.cn:25
    user = liuqian@healthmall.cn
    password = 123456
    from_address = liuqian@healthmall.cn
    from_name = Grafana

     
    重启pmm-server容器
    docker restart pmm-server

    ### 钉钉报警配置

    http://docs.grafana.org/alerting/notifications/

    在钉钉上创作一个内部群,并添加webhook机器人。

    DingDing/DingTalk

    Instructions in Chinese.

    In DingTalk PC Client:

    1. Click “more” icon on left bottom of the panel.

    2. Click “Robot Manage” item in the pop menu, there will be a new panel call “Robot Manage”.

    3. In the “Robot Manage” panel, select “customised: customised robot with Webhook”.

    4. In the next new panel named “robot detail”, click “Add” button.

    5. In “Add Robot” panel, input a nickname for the robot and select a “message group” which the robot will join in. click “next”.

    6. There will be a Webhook URL in the panel, looks like this: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxx. Copy this URL to the grafana Dingtalk setting page and then click “finish”.

    Dingtalk supports the following “message type”: textlink and markdown. Only the text message type is supported.

    升级
    docker pull percona/pmm-server:latest
    docker stop pmm-server && docker rm pmm-server
    docker run -d -p 80:80 -p 9090:9090 --volumes-from pmm-data --name pmm-server -e SERVER_USER=pmm -e SERVER_PASSWORD=ngiISI0Q4g9gfqWz89folKJSi --restart always --init percona/pmm-server:latest


  • 相关阅读:
    入门MyBatis框架你一点都不需要慌
    手把手教你玩转Git
    小米商城项目(JSP+Servlet项目)
    超详细Maven技术应用指南
    如何深入理解关系型数据库的三大范式
    MySQL触发器的详细教学与实战分析
    cute-cnblogs 番外篇-自定义博客园样式美化
    2019以终为始,不迷茫的2020 | 前端小菜鸡的年度总结~
    可爱的博客园样式之自定义“评论区”样式
    Vue中使用key的作用
  • 原文地址:https://www.cnblogs.com/hyming011/p/8252135.html
Copyright © 2011-2022 走看看