13.OceanBase集群参数修改

1.参数说明

OceanBase 数据库的集群参数即集群级配置项,同时参数还分为动态生效和重启生效两类。
通过集群参数的设置可以控制集群的负载均衡、合并时间、合并方式、资源分配和模块开关等功能。
系统租户(即 sys 租户)可以查看和设置集群参数,普通租户只能查看集群参数,无法设置集群参数。
当 OBServer 启动后,如果没有指定参数,则使用系统指定的参数的 Default 值。
在 observer 进程启动成功后,参数值将持久化到 /home/admin/oceanbase/etc/observer.config.bin 文件中,
您可以通过 strings observer.config.bin 命令来查看文件中的内容。

2.从二进制文件查看参数

[admin@observer1 etc]$ strings observer.config.bin
stack_size=512K
all_server_list=192.168.1.61:2882,192.168.1.62:2882,192.168.1.63:2882      #集群列表
__min_full_resource_pool_memory=2684354560   #最小内存池
min_observer_version=4.0.0.0                 #最小observer版本
workers_per_cpu_quota=10                     #每个cpu,10个工作线程。
cache_wash_threshold=1G                      #缓存超过1G就清理
enable_syslog_recycle=True                   #激活系统日志回收。
enable_syslog_wf=False
max_syslog_file_count=10                     #最大系统日志10个
syslog_level=WARN                            #日志级别:WARN;
cluster_id=2                                  #集群ID 
cluster=hjzqobce							 #集群名称
rootservice_list=192.168.1.61:2882:2881;192.168.1.62:2882:2881;192.168.1.63:2882:2881  #集群列表。
schema_history_expire_time=1d
cpu_count=16
system_memory=3G       						#系统租户内存3G;
memory_limit=17G       						#每个节点总内存:17G	
net_thread_count=4
zone=zone1                                  #当前节点属于那个Zone;
devname=ens33                               #网卡设备的名称。
mysql_port=2881                             #内存通信端口
rpc_port=2882                               #rpc通信端口 
datafile_size=50G                           #数据文件初始50G
data_dir=/data
cpu_quota_concurrency=10
[1005]
[1006]
enable_sql_extension=True
[1007]
[1008]
[admin@observer1 etc]$ pwd
/home/admin/oceanbase-ce/etc


3.命令行查看参数

obclient [sjzt]> SHOW PARAMETERS LIKE 'stack_size';
+-------+----------+--------------+----------+------------+-----------+-------+-------------------------------------------------------+----------+---------+---------+------------------+
| zone  | svr_type | svr_ip       | svr_port | name       | data_type | value | info                                                  | section  | scope   | source  | edit_level       |
+-------+----------+--------------+----------+------------+-----------+-------+-------------------------------------------------------+----------+---------+---------+------------------+
| zone2 | observer | 192.168.1.62 |     2882 | stack_size | NULL      | 512K  | the size of routine execution stackRange: [512K, 20M] | OBSERVER | CLUSTER | DEFAULT | STATIC_EFFECTIVE |
| zone3 | observer | 192.168.1.63 |     2882 | stack_size | NULL      | 512K  | the size of routine execution stackRange: [512K, 20M] | OBSERVER | CLUSTER | DEFAULT | STATIC_EFFECTIVE |
| zone1 | observer | 192.168.1.61 |     2882 | stack_size | NULL      | 512K  | the size of routine execution stackRange: [512K, 20M] | OBSERVER | CLUSTER | DEFAULT | STATIC_EFFECTIVE |
+-------+----------+--------------+----------+------------+-----------+-------+-------------------------------------------------------+----------+---------+---------+------------------+
3 rows in set (0.051 sec)

obclient [sjzt]> SHOW PARAMETERS WHERE edit_level='static_effective' AND name='stack_size';
+-------+----------+--------------+----------+------------+-----------+-------+-------------------------------------------------------+----------+---------+---------+------------------+
| zone  | svr_type | svr_ip       | svr_port | name       | data_type | value | info                                                  | section  | scope   | source  | edit_level       |
+-------+----------+--------------+----------+------------+-----------+-------+-------------------------------------------------------+----------+---------+---------+------------------+
| zone1 | observer | 192.168.1.61 |     2882 | stack_size | NULL      | 512K  | the size of routine execution stackRange: [512K, 20M] | OBSERVER | CLUSTER | DEFAULT | STATIC_EFFECTIVE |
| zone2 | observer | 192.168.1.62 |     2882 | stack_size | NULL      | 512K  | the size of routine execution stackRange: [512K, 20M] | OBSERVER | CLUSTER | DEFAULT | STATIC_EFFECTIVE |
| zone3 | observer | 192.168.1.63 |     2882 | stack_size | NULL      | 512K  | the size of routine execution stackRange: [512K, 20M] | OBSERVER | CLUSTER | DEFAULT | STATIC_EFFECTIVE |
+-------+----------+--------------+----------+------------+-----------+-------+-------------------------------------------------------+----------+---------+---------+------------------+
3 rows in set (0.034 sec)

4.有四个字段需要解释。

(1)#section 字段:配置项所属的分类:
SSTABLE:表示 SSTable 相关的配置项。
OBSERVER:表示 OBServer 相关的配置项。
ROOT_SERVICE:表示 RootService 相关的配置项。
TENANT:表示租户相关的配置项。
TRANS:表示事务相关的配置项。
LOAD_BALANCE:表示负载均衡相关的配置项。
DAILY_MERGE:表示合并相关的配置项。
CLOG:表示 Clog 相关的配置项。
LOCATION_CACHE:表示 Location Cache 相关的配置项。
CACHE:表示缓存相关的配置项。
RPC:表示 RPC 相关的配置项。
OBPROXY:表示 OBProxy 相关的配置项。

(2)#scope:配置项范围属性:
TENANT:表示该配置项为租户级别的配置项
CLUSTER:表示该配置项为集群级别的配置项

(3)#source :当前值来源:
TENANT
CLUSTER
CMDLINE
OBADMIN
FILE
DEFAULT

(4)#edit_level:定义该配置项的修改行为:
READONLY:表示该参数不可修改。
STATIC_EFFECTIVE:表示该参数可修改但需要重启 OBServer 才会生效。
DYNAMIC_EFFECTIVE:表示该参数可修改且修改后动态生效。

SHOW PARAMETERS where section  LIKE 'SSTABLE';
obclient [sjzt]> SHOW PARAMETERS where section  LIKE 'SSTABLE';
+-------+----------+--------------+----------+--------------------------+-----------+--------+----------------------------------------------------------------------------------------------------------------------------+---------+---------+---------+-------------------+
| zone  | svr_type | svr_ip       | svr_port | name                     | data_type | value  | info                                                                                                                       | section | scope   | source  | edit_level        |
+-------+----------+--------------+----------+--------------------------+-----------+--------+----------------------------------------------------------------------------------------------------------------------------+---------+---------+---------+-------------------+
| zone1 | observer | 192.168.1.61 |     2882 | memory_reserved          | NULL      | 500M   | the size of the system memory reserved for emergency internal use. Range: [10M, total size of memory]                      | SSTABLE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone1 | observer | 192.168.1.61 |     2882 | datafile_disk_percentage | NULL      | 0      | the percentage of disk space used by the data files. Range: [0,99] in integer                                              | SSTABLE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone1 | observer | 192.168.1.61 |     2882 | datafile_size            | NULL      | 50G    | size of the data file. Range: [0, +∞)                                                                                      | SSTABLE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone1 | observer | 192.168.1.61 |     2882 | redundancy_level         | NULL      | NORMAL | EXTERNAL: use extrernal redundancyNORMAL: tolerate one disk failureHIGH: tolerate two disk failure if disk count is enough | SSTABLE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone1 | observer | 192.168.1.61 |     2882 | data_dir                 | NULL      | /data  | the directory for the data file                                                                                            | SSTABLE | CLUSTER | DEFAULT | READONLY          |
| zone3 | observer | 192.168.1.63 |     2882 | memory_reserved          | NULL      | 500M   | the size of the system memory reserved for emergency internal use. Range: [10M, total size of memory]                      | SSTABLE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone3 | observer | 192.168.1.63 |     2882 | datafile_disk_percentage | NULL      | 0      | the percentage of disk space used by the data files. Range: [0,99] in integer                                              | SSTABLE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone3 | observer | 192.168.1.63 |     2882 | datafile_size            | NULL      | 50G    | size of the data file. Range: [0, +∞)                                                                                      | SSTABLE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone3 | observer | 192.168.1.63 |     2882 | redundancy_level         | NULL      | NORMAL | EXTERNAL: use extrernal redundancyNORMAL: tolerate one disk failureHIGH: tolerate two disk failure if disk count is enough | SSTABLE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone3 | observer | 192.168.1.63 |     2882 | data_dir                 | NULL      | /data  | the directory for the data file                                                                                            | SSTABLE | CLUSTER | DEFAULT | READONLY          |
| zone2 | observer | 192.168.1.62 |     2882 | memory_reserved          | NULL      | 500M   | the size of the system memory reserved for emergency internal use. Range: [10M, total size of memory]                      | SSTABLE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone2 | observer | 192.168.1.62 |     2882 | datafile_disk_percentage | NULL      | 0      | the percentage of disk space used by the data files. Range: [0,99] in integer                                              | SSTABLE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone2 | observer | 192.168.1.62 |     2882 | datafile_size            | NULL      | 50G    | size of the data file. Range: [0, +∞)                                                                                      | SSTABLE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone2 | observer | 192.168.1.62 |     2882 | redundancy_level         | NULL      | NORMAL | EXTERNAL: use extrernal redundancyNORMAL: tolerate one disk failureHIGH: tolerate two disk failure if disk count is enough | SSTABLE | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone2 | observer | 192.168.1.62 |     2882 | data_dir                 | NULL      | /data  | the directory for the data file                                                                                            | SSTABLE | CLUSTER | DEFAULT | READONLY          |
+-------+----------+--------------+----------+--------------------------+-----------+--------+----------------------------------------------------------------------------------------------------------------------------+---------+---------+---------+-------------------+
15 rows in set (0.016 sec)

5.修改参数的说明

语句说明:
仅 sys 租户可以修改集群级配置项,普通租户无法修改集群级配置项。
SCOPE 用于指定本次配置项修改的生效范围,默认值为 BOTH。其中:
	MEMORY:表示仅修改内存中的配置项,修改立即生效,且本修改在 Server 重启以后会失效(当前暂无配置项支持这种方式)。
	SPFILE :表示仅修改配置表中的配置项值,当 Server 重启以后才生效。
	BOTH:表示既修改配置表,又修改内存值,修改后立即生效,且 Server 重启以后配置值仍然生效。

SERVER 表示指定集群中要修改的 Server,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 则表示为租户级别的配置项。

6.登录系统租户更改集群级别参数。

[admin@obcontrol ~]$ obclient -h192.168.1.61 -P2883 -uroot@sys#hjzqobce -p'rootroot' -Doceanbase -A
obclient [oceanbase]> ALTER SYSTEM SET net_thread_count=1 SCOPE = SPFILE;
Query OK, 0 rows affected (0.046 sec)
obclient [oceanbase]> ALTER SYSTEM SET net_thread_count=2 SCOPE = SPFILE;
Query OK, 0 rows affected (0.073 sec)
obclient [oceanbase]> ALTER SYSTEM SET mysql_port=8888;
Query OK, 0 rows affected (0.049 sec)
obclient [oceanbase]> ALTER SYSTEM SET mysql_port=2881;
Query OK, 0 rows affected (0.053 sec)
obclient [oceanbase]> ALTER SYSTEM SET mysql_port=8888 ZONE='zone1';
Query OK, 0 rows affected (0.075 sec)
obclient [oceanbase]> ALTER SYSTEM SET mysql_port=2881 ZONE='zone1';
Query OK, 0 rows affected (0.142 sec)
obclient [oceanbase]> ALTER SYSTEM SET mysql_port=8888 SERVER='192.168.1.61:2882';
Query OK, 0 rows affected (0.055 sec)
obclient [oceanbase]> ALTER SYSTEM SET mysql_port=8888 SERVER='192.168.1.62:2882';
Query OK, 0 rows affected (0.062 sec)
obclient [oceanbase]> ALTER SYSTEM SET mysql_port=8888 SERVER='192.168.1.63:2882';
Query OK, 0 rows affected (0.081 sec)
obclient [oceanbase]> ALTER SYSTEM SET mysql_port=2881 SERVER='192.168.1.61:2882';
Query OK, 0 rows affected (0.119 sec)
obclient [oceanbase]> ALTER SYSTEM SET mysql_port=2881 SERVER='192.168.1.62:2882';
Query OK, 0 rows affected (0.057 sec)
obclient [oceanbase]> ALTER SYSTEM SET mysql_port=2881 SERVER='192.168.1.63:2882';
Query OK, 0 rows affected (0.043 sec)


obclient [oceanbase]> SHOW PARAMETERS LIKE '%memory_limit%';
+-------+----------+--------------+----------+--------------------------+-----------+-------+---------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
| zone  | svr_type | svr_ip       | svr_port | name                     | data_type | value | info                                                                                                                            | section  | scope   | source  | edit_level        |
+-------+----------+--------------+----------+--------------------------+-----------+-------+---------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
| zone2 | observer | 192.168.1.62 |     2882 | memory_limit_percentage  | NULL      | 80    | the size of the memory reserved for internal use(for testing purpose). Range: [10, 90]                                          | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone2 | observer | 192.168.1.62 |     2882 | rootservice_memory_limit | NULL      | 2G    | max memory size which can be used by rs tenant The default value is 2G. Range: [2G,)                                            | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone2 | observer | 192.168.1.62 |     2882 | memory_limit             | NULL      | 17G   | the size of the memory reserved for internal use(for testing purpose), 0 means follow memory_limit_percentage. Range: 0, [4G,). | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone3 | observer | 192.168.1.63 |     2882 | memory_limit_percentage  | NULL      | 80    | the size of the memory reserved for internal use(for testing purpose). Range: [10, 90]                                          | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone3 | observer | 192.168.1.63 |     2882 | rootservice_memory_limit | NULL      | 2G    | max memory size which can be used by rs tenant The default value is 2G. Range: [2G,)                                            | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone3 | observer | 192.168.1.63 |     2882 | memory_limit             | NULL      | 17G   | the size of the memory reserved for internal use(for testing purpose), 0 means follow memory_limit_percentage. Range: 0, [4G,). | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone1 | observer | 192.168.1.61 |     2882 | memory_limit_percentage  | NULL      | 80    | the size of the memory reserved for internal use(for testing purpose). Range: [10, 90]                                          | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone1 | observer | 192.168.1.61 |     2882 | rootservice_memory_limit | NULL      | 2G    | max memory size which can be used by rs tenant The default value is 2G. Range: [2G,)                                            | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| zone1 | observer | 192.168.1.61 |     2882 | memory_limit             | NULL      | 17G   | the size of the memory reserved for internal use(for testing purpose), 0 means follow memory_limit_percentage. Range: 0, [4G,). | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
+-------+----------+--------------+----------+--------------------------+-----------+-------+---------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
9 rows in set (0.015 sec)

7.参数查看方法二

obclient [oceanbase]> show global variables like '%timeout%';
+---------------------+------------------+
| Variable_name       | Value            |
+---------------------+------------------+
| connect_timeout     | 10               |
| interactive_timeout | 28800            |
| lock_wait_timeout   | 31536000         |
| net_read_timeout    | 30               |
| net_write_timeout   | 60               |
| ob_pl_block_timeout | 3216672000000000 |
| ob_query_timeout    | 10000000         |
| ob_trx_idle_timeout | 86400000000      |
| ob_trx_lock_timeout | -1               |
| ob_trx_timeout      | 86400000000      |
| wait_timeout        | 28800            |
+---------------------+------------------+
obclient [oceanbase]> set global ob_query_timeout=100000000;
Query OK, 0 rows affected (0.103 sec)
obclient [oceanbase]> set session ob_query_timeout=100000000;
Query OK, 0 rows affected (0.002 sec)
obclient [oceanbase]> alter system set memory_limit = '17G';     --修改集群占用的内存。
Query OK, 0 rows affected (0.068 sec)
obclient [oceanbase]> alter system set memory_limit_percentage = 90; --如果没有指定内存大小,也可以改集群展会用内存百分比。
Query OK, 0 rows affected (0.077 sec)
--登录白名单查看:所有人可以登录。
obclient [oceanbase]> show variables like 'ob_tcp_invited_nodes';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| ob_tcp_invited_nodes | %     |
+----------------------+-------+
1 row in set (0.004 sec)

你可能感兴趣的:(OceanBase数据库运维,oceanbase,数据库,服务器)