deploy-obagent-with-obd.md 5.5 KB
Newer Older
C
chris-sun-star 已提交
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
# 使用 OBD 部署 OBAgent

OBAgent 提供使用 ODB 部署和手动部署。要手动部署 OBAgent,您要配置 OBAgent、Prometheus 和 Prometheus Alertmanager(可选)。推荐您使用 OBD 部署 OBAgent。

## 前提条件

在部署 OBAgent 之前,您需要确认 OBAgent 的默认端口 8088、8089 未占用。您也可以自定义端口。

> **说明**:如果您的机器可以连接公网,在您执行了 `obd cluster deploy` 命令之后,OBD 将检查您的目标机器是否有 OBAgent 安装包。如果没有安装包,OBD 将自动从 yum 源获取。

## 同时部署 OceanBase 集群和 OBAgent

如果您希望同时部署 OceanBase 集群和 OBAgent,您只需要在 OceanBase 数据库的配置文件中添加以下 OBAgent 的配置信息:

```yaml
obagent:
  servers:
    - 127.0.0.1
  depends: 
    - oceanbase-ce
  global:
    home_path: /root/observer
```

> **注意**:`servers` 字段必须与 oceanbase-ce 的 `servers` 字段一致。

详细信息,参考 [配置文件](https://github.com/oceanbase/obdeploy/blob/master/example/obagent/distributed-with-obproxy-and-obagent-example.yaml)

## 单独部署 OBAgent

OBD 不支持为已部署的集群添加新的组件。如果您希望为要已部署的集群配置 OBAgent,您需要单独部署 OBAgent。要单独部署 OBAgent,您需要准备 OBAgent 的配置文件。请确保配置文件中的以下字段与 OceanBase 数据库相同:

```yaml
obagent:
  global:
    # Username for HTTP authentication. The default value is admin.
    http_basic_auth_user: admin
    # Password for HTTP authentication. The default value is root.
    http_basic_auth_password: root
    # Username for debug service. The default value is admin.
    pprof_basic_auth_user: admin
    # Password for debug service. The default value is root.
    pprof_basic_auth_password: root
    
    # 以下配置必须与 OceanBase 数据库一致
    # Monitor username for OceanBase Database. The user must have read access to OceanBase Database as a system tenant. The default value is root.
    monitor_user: root
    # Monitor password for OceanBase Database. The default value is empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the root_password in oceanbase-ce.
    monitor_password: 
    # The SQL port for observer. The default value is 2881. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the mysql_port in oceanbase-ce.
    sql_port: 2881
    # The RPC port for observer. The default value is 2882. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the rpc_port in oceanbase-ce.
    rpc_port: 2882
    # Cluster name for OceanBase Database. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the appname in oceanbase-ce.
    cluster_name: obcluster
    # Cluster ID for OceanBase Database. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the cluster_id in oceanbase-ce.
    cluster_id: 1
    # Zone name for your observer. The default value is zone1. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the zone name in oceanbase-ce.
    zone_name: zone1
    # Monitor status for OceanBase Database.  Active is to enable. Inactive is to disable. The default value is active. When you deploy an cluster automatically, OBD decides whether to enable this parameter based on depends.
```

更多信息,参考 [OBAgent 配置文件](https://github.com/oceanbase/obdeploy/blob/master/example/obagent/obagent-only-example.yaml
)

## 启动 OBAgent

使用以下命令 启动 OBAgent:

```bash
# 传入配置信息
obd cluster deploy <deploy name> [-c <yaml path>] [-f] [-U] [-A]
# 启动 OBAgent
obd cluster start <deploy name> [flags]
```

更多信息,参考 [OBD 使用文档](https://github.com/oceanbase/obdeploy/blob/master/README-CN.md#obd-cluster-deploy)

## (可选)启动 Prometheus

> 说明:您需要安装 Prometheus。

运行以下命令,启动 Prometheus:

```bash
./prometheus --config.file=./prometheus.yaml
```

## (可选)部署 Prometheus Alertmanager

- 下载并解压 Prometheus Alertmanager。
- 启动 Prometheus Alertmanager。
- 配置 Prometheus Alertmanager。更多信息,参考 [Prometheus 文档](https://www.prometheus.io/docs/alerting/latest/configuration/)

OBAgent 提供默认的报警项,配置文件位于 `conf/prometheus_config/rules`。其中,`host_rules.yaml` 存储机器报警项,`ob_rules.yaml` 存储 OceanBase 数据库报警项。如果默认报警项不能满足您的需求,按照以下方式自定义报警项:

```yaml
# 在 Prometheus 的配置文件中增加报警相关的配置。报警相关的配置文件需放在 rules 目录,且命名满足 *rule.yaml。

groups:
- name: node-alert
    rules:
    - alert: disk-full
    expr: 100 - ((node_filesystem_avail_bytes{mountpoint="/",fstype=~"ext4|xfs"} * 100) / node_filesystem_size_bytes {mountpoint="/",fstype=~"ext4|xfs"}) > 80
    for: 1m
    labels:
        serverity: page
    annotations:
        summary: "{{ $labels.instance }} disk full "
        description: "{{ $labels.instance }} disk > {{ $value }}  "
```

## (可选)更新 KV 配置

要更新 KV 配置,请使用 `obd cluster edit-config`。详细信息,参考 [OBD 使用文档](https://github.com/oceanbase/obdeploy/blob/master/README-CN.md#obd-cluster-edit-config)