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

分布式数据库学习Note233:OceanBase社区版中,如何修改集群配置项?

欢迎访问 OceanBase 官网获取更多信息:https://www.oceanbase.com/


通过修改集群配置项,可以使 OceanBase 数据库的行为符合业务的要求。OceanBase 数据库的集群配置项即集群参数,同时参数还分为动态生效和重启生效两类。通过集群配置项的设置可以控制集群的负载均衡、合并时间、合并方式、资源分配和模块开关等功能。

注意

系统租户(即 sys 租户),可以查看和设置集群级配置项,用户租户只能查看集群级配置项,无法设置集群级配置项。

有关配置项的更多说明,请参见 系统配置项概述

操作步骤

  1. 系统租户或用户租户登录到集群。

    连接示例如下,连接数据库时请以实际环境为准。

    obclient -h10.xx.xx.xx -P2883 -utest@mysql -p***** -A
    

    有关更加详细的连接数据库的操作指引,参见 连接数据库概述(MySQL 模式) 和 连接数据库概述(Oracle 模式)

  2. 执行以下命令,查看集群配置项的值。

    示例:

    obclient [(none)]> SHOW PARAMETERS LIKE '%syslog_level%';
    +-------+----------+----------------+----------+--------------+-----------+-------+------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
    | zone  | svr_type | svr_ip         | svr_port | name         | data_type | value | info                                                                                                                   | section  | scope   | source  | edit_level        |
    +-------+----------+----------------+----------+--------------+-----------+-------+------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
    | zone2 | observer | 172.xx.xx.xx   |     2882 | syslog_level | NULL      | PERF  | specifies the current level of logging. There are DEBUG, TRACE, INFO, WARN, USER_ERR, ERROR, six different log levels. | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
    | zone3 | observer | 172.xx.xx.xx   |     2882 | syslog_level | NULL      | PERF  | specifies the current level of logging. There are DEBUG, TRACE, INFO, WARN, USER_ERR, ERROR, six different log levels. | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
    | zone1 | observer | 172.xx.xx.xx   |     2882 | syslog_level | NULL      | PERF  | specifies the current level of logging. There are DEBUG, TRACE, INFO, WARN, USER_ERR, ERROR, six different log levels. | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
    +-------+----------+----------------+----------+--------------+-----------+-------+------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
    3 rows in set
    

    更多集群配置项的查看方法,请参见 查看集群配置项

  3. 执行以下命令,修改集群配置项的值。

    语句如下:

    obclient [(none)]> ALTER SYSTEM [SET]
        parameter_name = expression [SCOPE = {SPFILE | BOTH}]
           [COMMENT [=] 'text']
             [ TENANT [=] ALL|tenant_name ]
             [SERVER [=] 'svr_ip:svr_port' | ZONE [=] 'zone'];
    

    相关参数说明如下:

    • expression 用于指定修改后该配置项的值。

    • SCOPE 用于指定本次配置项修改的生效范围,默认值为 BOTH。其中:

      • SPFILE:表示仅修改配置表中的配置项值,当 OBServer 服务器重启以后才生效。

      • BOTH:表示既修改配置表,又修改内存值,修改后立即生效,且 OBServer 重启以后配置值仍然生效。

    • TENANT:用于系统租户修改所有租户或指定租户的租户级配置项。

      • ALL:所有租户。

      • tenant_name:指定租户的租户名。

    • SERVER 表示指定集群中要修改的 OBServer 服务器,ZONE 表示指定集群中要修改的 Zone。ALTER SYSTEM 语句不能同时指定 Zone 和 Server。并且在指定 Zone 时,仅支持指定一个 Zone;指定 Server 时,仅支持指定一个 Server。如果修改集群级配置项时,不指定 Zone 也不指定 Server,则表示该修改在整个集群内生效。

    在修改集群配置项时,集群级别的配置项不能通过用户租户设置,也不可以通过系统租户(即 sys 租户) 指定为用户租户设置。

    例如,执行 ALTER SYSTEM SET memory_limit='100G' TENANT='test_tenant' 语句将导致报错,因为 memory_limit 是集群级别的配置项。确认一个配置项为集群级别还是租户级别,可根据 SHOW PARAMETERS LIKE 'parameter_name'; 语句执行结果中的 scope 列对应的值来判断:

    • scope 值为 CLUSTER 则表示为集群级别的配置项。

    • scope 值为 TENANT 则表示为租户级别的配置项。

    示例:

    obclient [(none)]> ALTER SYSTEM SET syslog_level='ERROR' SCOPE = SPFILE;
    
    obclient [(none)]> ALTER SYSTEM SET log_disk_utilization_threshold = 20 TENANT='ALL';
    
    obclient [(none)]> ALTER SYSTEM SET system_memory = '50G' ZONE = 'zone1';
    
    obclient [(none)]> ALTER SYSTEM SET syslog_io_bandwidth_limit = '5M';
    
    obclient [(none)]> ALTER SYSTEM SET memory_limit = '250G' SERVER='xx.xx.xx.238:2882';
    
  4. 修改成功后,可以根据实际情况(重启 OBServer 或不重启 OBServer),通过 SHOW PARAMETERS 语句验证配置项的值是否修改成功。

    obclient [(none)]> SHOW PARAMETERS LIKE 'system_memory';
    +-------+----------+----------------+----------+---------------+-----------+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
    | zone  | svr_type | svr_ip         | svr_port | name          | data_type | value | info                                                                                                                                                                    | section  | scope   | source  | edit_level        |
    +-------+----------+----------------+----------+---------------+-----------+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
    | zone1 | observer | xx.xx.xx.237   |     2882 | system_memory | NULL      | 50G   | the memory reserved for internal use which cannot be allocated to any outer-tenant, and should be determined to guarantee every server functions normally. Range: [0M,) | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
    | zone3 | observer | xx.xx.xx.218   |     2882 | system_memory | NULL      | 0M    | the memory reserved for internal use which cannot be allocated to any outer-tenant, and should be determined to guarantee every server functions normally. Range: [0M,) | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
    | zone2 | observer | xx.xx.xx.238   |     2882 | system_memory | NULL      | 0M    | the memory reserved for internal use which cannot be allocated to any outer-tenant, and should be determined to guarantee every server functions normally. Range: [0M,) | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
    +-------+----------+----------------+----------+---------------+-----------+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
    3 rows in set 
    



欢迎访问 OceanBase 官网获取更多信息:https://www.oceanbase.com/

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

评论