prometheus
一.存储支持
https://prometheus.io/docs/prometheus/latest/storage/#local-storage 1.1Local storage 1.2.Remote storage integrations
二.远程存储
https://prometheus.io/docs/operating/integrations/#remote-endpoints-and-storage
三.本地存储配置
[root@rancher data]# cat /usr/lib/systemd/system/prometheus.service [Unit] Description=Prometheus Documentation=https://prometheus.io/ After=network.target [Service] Type=simple User=prometheus ExecStart=/opt/prometheus/prometheus-2.12.0.linux-amd64/prometheus --config.file=/opt/prometheus/prometheus-2.12.0.linux-amd64/conf/prometheus.yml --storage.tsdb.path=/opt/prometheus/prometheus-2.12.0.linux-amd64/data --storage.tsdb.retention.time=10d --storage.tsdb.wal-compression Restart=on-failure [Install] WantedBy=multi-user.target [root@rancher data]#
四.Prometheus支持远程存储
五.读写都支持的(存储数据node_exporter写入数据和配合grafana展示数据)
Azure Data Explorer: read and write Cortex: read and write CrateDB: read and write Google Cloud Spanner: read and write InfluxDB: read and write IRONdb: read and write M3DB: read and write MetricFire: read and write PostgreSQL/TimescaleDB: read and write QuasarDB: read and write Splunk: read and write TiKV: read and write Thanos: read and write
六.prometheus常用的数据库
InfluxDB: read and write
PostgreSQL/TimescaleDB: read and write
Splunk: read and write
七.Influxdb 简介(最新release版本1.8)
Influxdb
https://docs.influxdata.com/influxdb/v1.8/introduction/install/
7.1创建管理员
CREATE USER admin WITH PASSWORD '<password>' WITH ALL PRIVILEGES 7.2普通用户 CREATE USER "todd" WITH PASSWORD '123456' GRANT [READ,WRITE,ALL] ON <database_name> TO <username>
7.3登陆数据库
influx -precision rfc3339
influx
7.4创建数据库(数据字段可以自由变换)
Create database mydb Use mydb INSERT cpu,host=serverA,region=us_west value=0.65 cpu_type=dell
7.5查询
7.6数据备份
influxd backup -portable -database mydb /root/mydb influxd backup -portable -database mytsd -start 2017-04-28T06:49:00Z -end 2017-04-28T06:50:00Z /tmp/backup/influxdb
7.7数据恢复
influxd restore -portable -db mydb /root/mydb/
7.8数据库对比(优点:适应大规模时间序列的数据)
7.9企业版本使用
https://www.influxdata.com/blog/influxdb-clustering/
https://docs.influxdata.com/influxdb/v1.8/high_availability/clusters/
八.PostgreSQL
8.1安装(最新稳定版本12版本)
https://www.postgresql.org/download/linux/redhat/ # Install the repository RPM: yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm # Install PostgreSQL: yum install postgresql12-server # Optionally initialize the database and enable automatic start: /usr/pgsql-12/bin/postgresql-12-setup initdb systemctl enable postgresql-12 systemctl start postgresql-12 wget https://ftp.postgresql.org/pub/source/v12.2/postgresql-12.2.tar.bz2 tar xjvf postgresql*.bz2 #解压至一个目录 cd potgresql-12.2 ./configure --prefix=/opt/pgsql #拟安装至/opt/pgsql make world make install-world adduser postgres #增加新用户,系统提示要给定新用户密码 mkdir /opt/pgsql/data #创建数据库目录 chown -R postgres:postgres /opt/pgsql/data su - postgres #使用postgres帐号操作 /opt/pgsql/bin/initdb -D /opt/pgsql/data #初始化数据库 /opt/pgsql/bin/pg_ctl -D /opt/gsql/data -l logfile start #启动数据库 /opt/pgsql/bin/createdb genericdb #假定数据库名为gerericdb) /opt/pgsql/bin/psql genericdb # (进入数据库内部)
8.2语法(最新稳定版本12版本)
su – postgres https://www.postgresql.org/docs/12/index.html
8.3 创建数据库 ddl语言和mysql几乎一致
createdb mydb dropdb mydb psql mydb select version(); CREATE TABLE weather ( city varchar(80), temp_lo int, temp_hi int, prcp real, date date ); INSERT INTO weather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27');
8.4创建管理员
mydb=#CREATE ROLE admin superuser PASSWORD '123456' login; mydb=# CREATE USER test WITH PASSWORD '123456'; CREATE ROLE mydb=# GRANT ALL PRIVILEGES ON DATABASE mydb TO test; GRANT mydb=# create user zabbix ; create database zabbix owner zabbix; alter user zabbix password zabbix; grant all on DATABASE zabbix to zabbix;
8.5设置PostgreSQL监听地址和允许访问IP地址
1、PostgreSQL监听地址也就是你用什么host地址去访问它,修改配置文件postgresql.conf listen_addresses=’*’ 2、允许访问PostgreSQL服务器的客户端IP地址,修改配置文件pg_hba.conf,添加: host all all 192.168.0.0/16 trust 其中:192.168.0.0/16表示允许192.168.0.1-192.168.255.255网段访问。
8.6客户端
https://www.postgresql.org/ftp/pgadmin/pgadmin4/v1.0/windows/
8.7 pgsql和mysql
https://www.postgresql.org/docs/8.4/plpgsql-overview.html
九.Splunk Grafana不支持
十 Prometheus 修改为influxdb为数据源
CREATE DATABASE "prometheus_db" CREATE USER "prometheus_user" WITH PASSWORD '12345678' GRANT ALL ON "prometheus_db" TO "prometheus_user" Prometheus.yml配置 remote_write: - url: "http://192.168.48.25:8086/api/v1/prom/write?db=prometheus_db&u=prometheus_user&p=12345678" remote_read: - url: http://192.168.48.25:8086/api/v1/prom/read?db=prometheus_db&u=prometheus_user&p=12345678
https://segmentfault.com/q/1010000018661735/a-1020000018663576