合 使用OBD部署一个OceanBase 三副本集群并使用Promethues监控OB(在不同节点)
Tags: 高可用监控环境搭建OceanBase分布式数据库Grafana
安装Promethues和Grafana
参考:https://open.oceanbase.com/docs/tutorials/quickstart/V1.0.0/2-9-how-to-deploy-obagent
Prometheus 配置
OBAgent 启动后会在节点自动生成 Prometheus
配置文件, 位置在 OBAgent 安装目录下,如 /home/admin/obagent/conf/prometheus_config/
。这个配置文件可以给 Prometheus
产品直接使用。
示例如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | [root@lhrob1 admin]# cd /home/admin/obagent/conf/prometheus_config/ [root@lhrob1 prometheus_config]# ll total 8 -rw------- 1 admin admin 1242 Jan 9 17:27 prometheus.yaml drwxrwxr-x 2 admin admin 4096 Jan 9 17:27 rules [root@lhrob1 prometheus_config]# more prometheus.yaml global: scrape_interval: 1s evaluation_interval: 10s rule_files: - "rules/*rules.yaml" scrape_configs: - job_name: prometheus metrics_path: /metrics scheme: http static_configs: - targets: - 'localhost:9090' - job_name: node basic_auth: username: admin password: lhr metrics_path: /metrics/node/host scheme: http static_configs: - targets: - 172.72.8.11:8088 - 172.72.8.12:8088 - 172.72.8.13:8088 - job_name: ob_basic basic_auth: username: admin password: lhr metrics_path: /metrics/ob/basic scheme: http static_configs: - targets: - 172.72.8.11:8088 - 172.72.8.12:8088 - 172.72.8.13:8088 - job_name: ob_extra basic_auth: username: admin password: lhr metrics_path: /metrics/ob/extra scheme: http static_configs: - targets: - 172.72.8.11:8088 - 172.72.8.12:8088 - 172.72.8.13:8088 - job_name: agent basic_auth: username: admin password: lhr metrics_path: /metrics/stat scheme: http static_configs: - targets: - 172.72.8.11:8088 - 172.72.8.12:8088 - 172.72.8.13:8088 |
稍加说明如下:
配置项 | 值 | 说明 |
---|---|---|
scrape_interval | 1s | 抓取间隔 |
evaluation_interval | 10s | 评估规则间隔 |
rule_files | rules/*rules.yaml | 报警规则 |
scrape_configs | 抓取配置 |
使用方法:
从 https://prometheus.io/download/ 下载相应版本,安装到服务器上官网提供的是二进制版,解压就能用,不需要编译
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | wget https://github.com/prometheus/prometheus/releases/download/v2.32.1/prometheus-2.32.1.linux-amd64.tar.gz -- 安装prometheus tar -zxvf prometheus-2.32.1.linux-amd64.tar.gz -C /usr/local/ ln -s /usr/local/prometheus-2.32.1.linux-amd64 /usr/local/prometheus ln -s /usr/local/prometheus/prometheus /usr/local/bin/prometheus scp prometheus.yaml lhrobproxy:/usr/local/prometheus/prometheus.yml -- 启动 prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/usr/local/prometheus/data/ --web.enable-lifecycle --storage.tsdb.retention.time=60d & [root@lhrobproxy ~]# netstat -tulnp | grep 9090 tcp6 0 0 :::9090 :::* LISTEN 19891/prometheus |