暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

OceanBase 学习笔记7:如何添加 OBProxy?

270

您可以通过 OCP 或 OBD 添加新的 OBProxy 到已有的 OBProxy 集群中。

前提条件

已创建 OBProxy 集群,OBProxy 集群创建相关操作请参见 创建 OBProxy 集群

通过 OCP 添加 OBProxy

  1. 登录 OCP。

  2. 在左侧导航栏单击 OBProxy 。

  3. 在集群列表中选择需要操作的 OBProxy 集群,进入 OBPRoxy 集群总览页面。

  4. 单击 添加 OBProxy 。

    1

  5. 在弹出框中填写 软件版本 、 SQL 端口 、 Exporter 端口 、 机房 、 机型 、 机器选择方式 、 主机 等信息。

    1

    参考下表填写信息:

    参数说明
    SQL 端口默认为 2883。
    Exporter 端口默认为 2884。
    软件版本选择要安装的 OBProxy 版本。
    选择 OBProxy 主机选择部署 OBProxy 所使用的主机,包括该主机的 机房、机型(可选)、机器选择方式、主机 IP。
  6. 单击 确定 。

通过 OBD 添加 OBProxy

前提条件

  • 已创建的 OBProxy 集群需是使用 OBD 创建的集群。

  • 您已部署可供 OBProxy 连接的 OceanBase 集群。

操作步骤

  1. 从 GitHub 上下载对应的配置文件模板。

  2. 根据自身机器情况修改配置文件,配置文件各个模块的含义可参考 配置文件说明

    注意

    您需在 rs_list 配置项中按要求填写该 OBProxy 集群可访问的 OceanBase 集群 IP 和 mysql_port 端口。

  3. 执行如下命令部署新集群。

    obd cluster deploy <deploy_name> -c <deploy_config_path>
    

    其中,参数 deploy_name 为部署集群名称,可以理解为配置文件的别名,deploy_config_path 为配置文件名。

    在您执行了 obd cluster deploy 命令之后,OBD 将检查您的目标机器是否有 OBProxy 安装包。如果没有安装包,OBD 将自动从 yum 源获取。

  4. 参考下述步骤将新建集群的信息添加到原 OBProxy 集群中。

    1. 查看配置路径:

      obd cluster list
      
    2. 打开原集群配置文件,并添加新部署集群的配置:

      vim .obd/cluster/<deploy_name>/config.yaml
      

      修改后的配置文件可参考如下文件:

       ## Only need to configure when remote login is required
       user:
         username: admin
         # password: your password if need
         key_file: /home/admin/.ssh/id_rsa.pub
         # port: your ssh port, default 22
         # timeout: ssh connection timeout (second), default 30
       obproxy-ce:
         servers:
            - name: z1
               ip: xxx.xx.xxx.xx # 原集群 IP
            - name: z2
               ip: xxx.xx.xxx.xx # 新集群 IP
       global:
         listen_port: 2883 # External port. The default value is 2883.
         prometheus_listen_port: 2884 # The Prometheus port. The default value is 2884.
         home_path: /home/admin/obproxy
         # oceanbase root server list
         # format: ip:mysql_port;ip:mysql_port. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.
         rs_list: xxx.xx.xxx.xx:2881;xxx.xx.xxx.xx:2881;xxx.xx.xxx.xx:2881
         enable_cluster_checkout: false
         # observer cluster name, consistent with oceanbase-ce's appname. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.
         cluster_name: obcluster
         skip_proxy_sys_private_check: true
         enable_strict_kernel_release: false
         # obproxy_sys_password: # obproxy sys user password, can be empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.
         # observer_sys_password: # proxyro user pasword, consistent with oceanbase-ce's proxyro_password, can be empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends.
      
  5. 执行如下命令再次启动集群:

    obd cluster start <deploy_name>
    
  6. 执行如下命令查看集群状态:

    obd cluster display <deploy_name>
    

    出现如下结果即表示集群创建成功:

    Get local repositories and plugins ok
    Open ssh connection ok
    Cluster status check ok
    Connect to obproxy ok
    +---------=----------------------------------------+
    |                     obproxy                      |
    +---------=------+------+-----------------+--------+
    | ip             | port | prometheus_port | status |
    +----------------+------+-----------------+--------+
    | 172.xxx.xxx.24 | 2883 | 2884            | active |
    | 172.xxx.xxx.25 | 2883 | 2884            | active |
    +-------------=--+------+-----------------+--------+
    

说明

上述步骤中使用的到 OBD 命令,详细信息可参考 集群命令组

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论