zoukankan      html  css  js  c++  java
  • influxdb做prometheus永久存储

    一、安装influxdb

    1、下载rpm包

    #  wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.1.x86_64.rpm
    

    2、yum安装

    #  yum  localinstall influxdb-1.8.1.x86_64.rpm
    

    3、修改配置文件 /etc/influxdb/influxdb.conf

    [meta]
      dir = "/var/lib/influxdb/meta"    #存放最终存储的数据,文件以.tsm结尾
    
    [data]
      dir = "/var/lib/influxdb/data"       #存放数据库元数据
      wal-dir = "/var/lib/influxdb/wal"  #存放预写日志文件
    
    [http]
      log-enabled = false   #关闭网页登陆
      access-log-path = "/var/lib/influxdb/influxdb.log"

    4、启动influxdb

    # systemctl start influex
    # systemctl status influex
    # systemctl enable influex
    

    5、创建数据库和授权用户

    [root@localhost influxdb]# influx
    Connected to http://localhost:8086 version 1.8.1
    InfluxDB shell version: 1.8.1
    > show databases;
    name: databases
    name
    ----
    _internal
    > create database promethes;
    > show databases;
    name: databases
    name
    ----
    _internal
    prometheus
    > create user "admin" with password 'Admin123' with all privileges;

    6、编辑prometheus.yml文件

    remote_write:
      - url: "http://localhost:8086/api/v1/prom/write?db=prometheus"
        basic_auth:
          username: admin
          password: Admin123
    
    remote_read:
      - url: "http://localhost:8086/api/v1/prom/read?db=prometheus"
        basic_auth:
          username: admin
          password: Admin123

    重启prometheus

    7、验证数据

    [root@localhost ~]# influx
    Connected to http://localhost:8086 version 1.8.1
    InfluxDB shell version: 1.8.1
    > use prometheus;
    Using database prometheus
    > show measurements;
    name: measurements
    name
    ----
    go_gc_duration_seconds
    go_gc_duration_seconds_count
    go_gc_duration_seconds_sum
    go_goroutines
    go_info
    go_memstats_alloc_bytes
    go_memstats_alloc_bytes_total
    go_memstats_buck_hash_sys_bytes
    go_memstats_frees_total
    go_memstats_gc_cpu_fraction
    go_memstats_gc_sys_bytes
    ....................................
    
    > select * from up limit 10;
    name: up
    time                __name__ instance           job           value
    ----                -------- --------           ---           -----
    1600421728016000000 up       172.16.68.169:9308 kafka         0
    1600421729540000000 up       172.16.68.169:9100 centos7-benji 0
    1600421731123000000 up       localhost:9090     prometheus    1
    1600421733845000000 up       172.16.68.169:9091 cpu-memory    0
    1600421743017000000 up       172.16.68.169:9308 kafka         0
    1600421744540000000 up       172.16.68.169:9100 centos7-benji 0
    1600421746123000000 up       localhost:9090     prometheus    1
    1600421748846000000 up       172.16.68.169:9091 cpu-memory    0
    1600421758018000000 up       172.16.68.169:9308 kafka         0
    1600421759540000000 up       172.16.68.169:9100 centos7-benji 0

     

  • 相关阅读:
    读取列表下标
    字典dict详解
    使用mysql的长连接
    oauth授权协议的原理
    安装性能测试工具:sysbench和使用apache的ab
    发送邮件出现问题
    获取用户的真实ip
    清理代码的阅读笔记
    开发中三个经典的原则
    要干大事就不能把面子看得太重
  • 原文地址:https://www.cnblogs.com/lina-2159/p/13719265.html
Copyright © 2011-2022 走看看