使有prometheus监控redis,mongodb,nginx,mysql,jmx(经典推荐!)

以下操作在CENTOS7环境。

使用prometheus做监控,使用grafana做dashboard的界面展示:

因prometheus自带的监控web界面图形化展示方面比较弱,推荐使用grafana集成prometheus展示;

一、软件安装

1)granafa的安装:

官方安装指南:https://grafana.com/grafana/download?platform=linux

wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.2-1.x86_64.rpm 
sudo yum localinstall grafana-5.2.2-1.x86_64.rpm

service grafana-server start

2)prometheus的安装:

官方下载地址:https://prometheus.io/download/

安装prometheus主程序

wget https://github.com/prometheus/prometheus/releases/download/v2.3.2/prometheus-2.3.2.linux-amd64.tar.gz

tar -zxvf prometheus-2.3.2.linux-amd64.tar.gz -C /usr/local/prometheus

cd /usr/local/prometheus 

nohup ./prometheus >/dev/null &

安装 prometheus的告警程序

wget https://github.com/prometheus/alertmanager/releases/download/v0.15.2/alertmanager-0.15.2.linux-amd64.tar.gz

tar -zxvf alertmanager-0.15.2.linux-amd64.tar.gz -C /usr/local/prometheus

cd /usr/local/prometheus

nohup ./alertmanager >/dev/null &

3)需在各监控节点安装prometheus的node程序;

wget https://github.com/prometheus/node_exporter/releases/download/v0.16.0/node_exporter-0.16.0.linux-amd64.tar.gz

tar -zxvf node_exporter-0.16.0.linux-amd64.tar.gz -C /usr/local/prometheus

cd /usr/local/prometheus

nohup ./node_exporter >/dev/null &

二、mysql的插件安装可直接在prometheus官网下载安装;

wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.11.0/mysqld_exporter-0.11.0.linux-amd64.tar.gz

tar -zxvf mysqld_exporter-0.11.0.linux-amd64.tar.gz -C /usr/local/prometheus

配置.my.cnf文件

[client]
host = 127.0.0.1
user = REPL
password = Pbu4@123
socket = /mysqldata/data/mysqld.sock
[mysqladmin]
host = 127.0.0.1
user = zabbix
password = Zabbix@123
socket = /mysqldata/data/mysqld.sock

nohup ./mysqld_exporter --config.my-cnf=/etc/zabbix/.my.cnf --collect.binlog_size --collect.info_schema.processlist --collect.info_schema.innodb_metrics --collect.engine_innodb_status --collect.perf_schema.file_events --collect.perf_schema.eventswaits --collect.perf_schema.indexiowaits --collect.perf_schema.tableiowaits --collect.info_schema.tables --collect.info_schema.tablestats --collect.auto_increment.columns --collect.info_schema.userstats --collect.info_schema.innodb_cmp --collect.info_schema.innodb_cmpmem --collect.perf_schema.replication_group_member_stats >/dev/null &

可到grafana下载percona APP dashboard.

三、nginx,redis,mongodb,jmx的安装如下:

1、mongodb的插件安装:

wget https://github.com/dcu/mongodb_exporter/releases/download/v1.0.0/mongodb_exporter-linux-amd64

tar -zxvf mongodb_exporter-linux-amd64 -C /usr/local/prometheus

cd /usr/local/prometheus

mongod配置副本集启动

./mongodb_exporter -mongodb.uri mongodb://192.168.152.128:27017,192.168.152.128:27018,192.168.152.128:27019

mongodb配置单机启动

/mongodb_exporter -mongodb.uri mongodb://192.168.152.128:27017

2、redis的插件安装:

3、nginx的插件安装:

下载源码nginx,再下载nginx-module-vts moudle进行编译安装。

git clone git://github.com/vozlt/nginx-module-vts.git

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_sysguard_module --with-stream --add-module=nginx-module-vts

make &&make install

更改Nginx Conf的配置,添加监控接口/status/:

http {
vhost_traffic_status_zone;
    vhost_traffic_status_filter_by_host on;

...

server {

    ...

    location /status {
        vhost_traffic_status_display;
        vhost_traffic_status_display_format html;
    }
}
}

 

4、jmx的插件安装:

注意只对Oracle原生的jdk的相关指标可监控,openjdk的只能监控部分指标。

wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.3.1/jmx_prometheus_javaagent-0.3.1.jar

tar -zxvf jmx_prometheus_javaagent-0.3.1.jar

配置config.yml文件

---
startDelaySeconds: 0
hostPort: localhost:58888 #master为本机IP(一般可设置为localhost);1234为想设置的jmx端口(可设置为未被占用的端口)
ssl: false
lowercaseOutputName: false
lowercaseOutputLabelNames: false

启动jar

java -Djava.security.egd=file:/dev/./urandom -javaagent:/var/lib/prometheus/jmx_prometheus_javaagent-0.3.1.jar=9157:/etc/prometheus/config.yml -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=58888 -Djava.rmi.server.hostname=localhost -jar /app.jar

四、最后在安装后的granfa里,配置prometheus 源,再到granfa里下载相关的dashboard进行配置。
 

 

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值