1. 创建监控用户
[admin]# obclient -h127.0.0l -P2881 -D -uroot@sys -p -A
obclient [sys]> grant select on oceanbase.* to monitor identified by 'OceanBase010';
2. 更新配置文件
参考obagent配置文件:https://github.com/oceanbase/obdeploy/blob/master/example/obagent/obagent-only-example.yaml
编辑obagent.yaml配置文件
[admin]# vi obagent.yaml
obagent:
servers:
- 192.168.1.71
- 192.168.1.72
- 192.168.1.73
global:
home_path: /home/admin/obagent
monagent_http_port: 8088
mgragent_http_port: 8089
log_path: log/monagent.log
mgragent_log_level: info
mgragent_log_max_size: 30
mgragent_log_max_days: 30
mgragent_log_max_backups: 15
monagent_log_level: info
monagent_log_max_size: 200
monagent_log_max_days: 30
monagent_log_max_backups: 15
http_basic_auth_user: admin
http_basic_auth_password: OceanBase010
pprof_basic_auth_user: admin
pprof_basic_auth_password: OceanBase010
monitor_user: monitor
monitor_password: OceanBase010
sql_port: 2881
rpc_port: 2882
cluster_name: observer
cluster_id: 1
ob_monitor_status: active
192.168.1.71:
zone_name: zone1
192.168.1.72:
zone_name: zone2
192.168.1.73:
zone_name: zone3
3. 部署obagent集群
部署命令:obd cluster deploy 集群名称 -c 配置文件
[admin]# obd cluster deploy obagent -c obagent.yaml
+---------------------------------------------------------------------------+
| Packages |
+------------+---------+---------+------------------------------------------+
| Repository | Version | Release | Md5 |
+------------+---------+---------+------------------------------------------+
| obagent | 1.3.0 | 22.el7 | d57fbb4962b2fbecb6282358c59295fdfba4d6ac |
+------------+---------+---------+------------------------------------------+
Repository integrity check ok
Parameter check ok
Open ssh connection ok
Cluster status check ok
Initializes obagent work home ok
Remote obagent-1.3.0-22.el7-d57fbb4962b2fbecb6282358c59295fdfba4d6ac repository install ok
Remote obagent-1.3.0-22.el7-d57fbb4962b2fbecb6282358c59295fdfba4d6ac repository lib check ok
obagent deployed
Trace ID: 3bd4feb8-e26b-11ed-aa21-000c29501e19
If you want to view detailed obd logs, please run: obd display-trace 3bd4feb8-e26b-11ed-aa21-000c29501e19
4. 查看集群状态,obagent集群状态为“deployed”
[admin]# obd cluster list
+----------------------------------------------------------------+
| Cluster List |
+----------+-----------------------------------+-----------------+
| Name | Configuration Path | Status (Cached) |
+----------+-----------------------------------+-----------------+
| observer | /home/admin/.obd/cluster/observer | running |
| obagent | /home/admin/.obd/cluster/obagent | deployed |
+----------+-----------------------------------+-----------------+
Trace ID: 92c2982a-e26b-11ed-9865-000c29501e19
If you want to view detailed obd logs, please run: obd display-trace 92c2982a-e26b-11ed-9865-000c29501e19
5. 启动obagent集群(obagent使用8088、8089端口)
[admin]# obd cluster start obagent
Get local repositories ok
Search plugins ok
Open ssh connection ok
Load cluster param plugin ok
Check before start obagent ok
Start obagent ok
obagent program health check ok
Connect to Obagent ok
+-----------------------------------------------------------------+
| obagent |
+--------------+--------------------+--------------------+--------+
| ip | mgragent_http_port | monagent_http_port | status |
+--------------+--------------------+--------------------+--------+
| 192.168.1.71 | 8089 | 8088 | active |
| 192.168.1.72 | 8089 | 8088 | active |
| 192.168.1.73 | 8089 | 8088 | active |
+--------------+--------------------+--------------------+--------+
obagent running
Trace ID: aa3d0670-e26b-11ed-9c91-000c29501e19
If you want to view detailed obd logs, please run: obd display-trace aa3d0670-e26b-11ed-9c91-000c29501e19
6. 查看集群状态,obagent集群状态为“running”
[admin]# obd cluster list
+----------------------------------------------------------------+
| Cluster List |
+----------+-----------------------------------+-----------------+
| Name | Configuration Path | Status (Cached) |
+----------+-----------------------------------+-----------------+
| observer | /home/admin/.obd/cluster/observer | running |
| obagent | /home/admin/.obd/cluster/obagent | running |
+----------+-----------------------------------+-----------------+
Trace ID: d650fabe-e26b-11ed-a7a5-000c29501e19
If you want to view detailed obd logs, please run: obd display-trace d650fabe-e26b-11ed-a7a5-000c29501e19
7. obagent部署启动后会生成的prometheus.yaml配置文件,对4个“job_name”部分中“basic_auth”、“static_configs”稍作修改即可被使用
[admin]# cat /home/admin/obagent/conf/prometheus_config/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: OceanBase010
metrics_path: /metrics/node/host
scheme: http
static_configs:
- targets:
- 192.168.1.71:8088
- 192.168.1.72:8088
- 192.168.1.73:8088
- job_name: ob_basic
basic_auth:
username: admin
password: OceanBase010
metrics_path: /metrics/ob/basic
scheme: http
static_configs:
- targets:
- 192.168.1.71:8088
- 192.168.1.72:8088
- 192.168.1.73:8088
- job_name: ob_extra
basic_auth:
username: admin
password: OceanBase010
metrics_path: /metrics/ob/extra
scheme: http
static_configs:
- targets:
- 192.168.1.71:8088
- 192.168.1.72:8088
- 192.168.1.73:8088
- job_name: agent
basic_auth:
username: admin
password: OceanBase010
metrics_path: /metrics/stat
scheme: http
static_configs:
- targets:
- 192.168.1.71:8088
- 192.168.1.72:8088
- 192.168.1.73:8088
8. 安装prometheus
[admin]# wget https://github.com/prometheus/prometheus/releases/download/v2.43.0/prometheus-2.43.0.linux-amd64.tar.gz
[admin]# tar -zxvf prometheus-2.43.0.linux-amd64.tar.gz
[admin]# cd prometheus-2.43.0.linux-amd64
[admin]# ./prometheus --config.file="/home/admin/obagent/conf/prometheus_config/prometheus.yaml"
浏览器访问:http://192.168.1.71:9090/graph
9. 安装Grafana
[admin]# wget https://dl.grafana.com/enterprise/release/grafana-enterprise-9.4.7-1.x86_64.rpm
[admin]# sudo rpm -ivh grafana-enterprise-9.4.7-1.x86_64.rpm
[admin]# sudo /bin/systemctl start grafana-server.service
然后添加prometheus的数据源(http://192.168.1.71:9090)
可以到grafana官网下载OceanBase提交的监控模版并将模版导入Grafana中。
参考:《oceanbase社区版入门与实战.pdf》