OceanBase的那些系统参数
OceanBase的系统参数分为好几个级别,下面我将从级别从高到底一一介绍下OceanBase数据库里的那些系统参数。
系统配置项(系统参数)
OceanBase的系统配置项,我们可以称为parameter,是OB最高级别的系统参数。系统配置项分为集群级配置项和租户级配置项。大部分需要关注的系统配置项都是集群级别的,parameter更多的是在集群级别对整个集群的各种功能进行配置。通过show parameters语法可以查询系统配置项,可以看到scope为cluster即表示这是一个集群级别的配置项,edit_level为dynamic_effective表示这个参数动态修改生效。
修改集群级系统配置项也需要到sys租户下修改,修改语句为:alter system set parameter=’xxxx’ 。对于集群级配置项,生效范围为集群、zone、机器,修改集群级别的配置项也可以指定zone和server,如不指定那将对整个集群生效。此外,修改系统配置项会默认自动持久化到内部表和参数文件。
修改租户级系统配置项在sys租户和业务租户下都可以修改,在sys租户下修改需要指定TENANT='xxxx',在业务租户下仅可以修改本租户的系统配置项。
obclient> show parameters like '%enable_sql_audit%'; +-------+----------+------------+----------+------------------+-----------+-------+---------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ | zone | svr_type | svr_ip | svr_port | name | data_type | value | info | section | scope | source | edit_level | +-------+----------+------------+----------+------------------+-----------+-------+---------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ | zone1 | observer | 10.10.10.1 | 2882 | enable_sql_audit | NULL | True | specifies whether SQL audit is turned on. The default value is TRUE. Value: TRUE: turned on FALSE: turned off | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | | zone2 | observer | 10.10.10.2 | 2882 | enable_sql_audit | NULL | True | specifies whether SQL audit is turned on. The default value is TRUE. Value: TRUE: turned on FALSE: turned off | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | | zone3 | observer | 10.10.10.3 | 2882 | enable_sql_audit | NULL | True | specifies whether SQL audit is turned on. The default value is TRUE. Value: TRUE: turned on FALSE: turned off | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | +-------+----------+------------+----------+------------------+-----------+-------+---------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ obclient> ALTER SYSTEM SET mysql_port=8888; obclient> ALTER SYSTEM SET mysql_port=8888 ZONE='z1'; obclient> ALTER SYSTEM SET mysql_port=8888 SERVER='192.168.100.1:2882';
系统变量
OceanBase的系统变量,我们可以称为variable,都是租户级别的,在各个租户里设置。这个就类似于MySQL的variables。不管是oracle还是mysql模式,都可以通过show variables like查看参数值,并且修改参数也是直接通过set来修改。此外,variable也像MySQL一样分为global和session级别,修改参数时加上global就可以自动持久化。
obclient> show variables like '%ob_query_time%'; +------------------+----------+ | VARIABLE_NAME | VALUE | +------------------+----------+ | ob_query_timeout | 10000000 | +------------------+----------+ obclient> show variables like '%ob_compatibility_mode%'; +-----------------------+--------+ | VARIABLE_NAME | VALUE | +-----------------------+--------+ | ob_compatibility_mode | ORACLE | +-----------------------+--------+ SET ob_query_timeout = 20000000; SET GLOBAL ob_query_timeout = 20000000;
隐藏参数
除了系统配置项和系统变量,OB还有一些隐藏参数,__xx_xx格式的参数为隐藏参数。隐藏参数无法通过SHOW PARAMETERS语句来查询,只能通过系统表查询:oceanbase.__all_virtual_sys_parameter_stat。隐藏参数和系统配置项类似,也分为集群级和租户级,修改和方式也和系统配置项一样。
obclient> SELECT * FROM oceanbase.__all_virtual_sys_parameter_stat WHERE name='__easy_memory_limit'; +-------+----------+------------+----------+---------------------+-----------+-------+--------------+-------------------------------------------------------------------------------------+-------------+----------+---------------+---------+---------+-------------------+ | zone | svr_type | svr_ip | svr_port | name | data_type | value | value_strict | info | need_reboot | section | visible_level | scope | source | edit_level | +-------+----------+------------+----------+---------------------+-----------+-------+--------------+-------------------------------------------------------------------------------------+-------------+----------+---------------+---------+---------+-------------------+ | zone2 | observer | 10.10.10.1 | 2882 | __easy_memory_limit | NULL | 4G | NULL | max memory size which can be used by libeasy. The default value is 4G. Range: [1G,) | NULL | OBSERVER | NULL | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | | zone3 | observer | 10.10.10.1 | 2882 | __easy_memory_limit | NULL | 4G | NULL | max memory size which can be used by libeasy. The default value is 4G. Range: [1G,) | NULL | OBSERVER | NULL | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | | zone1 | observer | 10.10.10.1 | 2882 | __easy_memory_limit | NULL | 4G | NULL | max memory size which can be used by libeasy. The default value is 4G. Range: [1G,) | NULL | OBSERVER | NULL | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | +-------+----------+------------+----------+---------------------+-----------+-------+--------------+-------------------------------------------------------------------------------------+-------------+----------+---------------+---------+---------+-------------------+ 3 rows in set (0.04 sec) obclient> SELECT count(*) FROM oceanbase.__all_virtual_sys_parameter_stat; +----------+ | count(*) | +----------+ | 1239 | +----------+ 1 row in set (0.02 sec)