# Please don't use hostname, only IP can be supported
- 192.168.32.131
global:
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path: /home/observer
# The directory for data storage. The default value is $home_path/store.
data_dir: /data
# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
redo_dir: /redo
# Please set devname as the network adaptor's name whose ip is in the setting of severs.
# if set severs as "127.0.0.1", please set devname as "lo"
# if current ip is 192.168.1.10, and the ip's network adaptor's name is "eth0", please use "eth0"
devname: ens33
mysql_port: 2881 # External port for OceanBase Database. The default value is 2881. DO NOT change this value after the cluster is started.
rpc_port: 2882 # Internal port for OceanBase Database. The default value is 2882. DO NOT change this value after the cluster is started.
zone: zone1
cluster_id: 1
# please set memory limit to a suitable value which is matching resource.
memory_limit: 8G # The maximum running memory for an observer
system_memory: 4G # The reserved system memory. system_memory is reserved for general tenants. The default value is 30G.
stack_size: 512K
cpu_count: 10
cache_wash_threshold: 1G
__min_full_resource_pool_memory: 268435456
workers_per_cpu_quota: 10
schema_history_expire_time: 1d
# The value of net_thread_count had better be same as cpu's core number.
net_thread_count: 4
major_freeze_duty_time: Disable
minor_freeze_times: 3
enable_separate_sys_clog: 0
enable_merge_by_turn: FALSE
datafile_disk_percentage: 20 # The percentage of the data_dir space to the total disk space. This value takes effect only when datafile_size is 0. The default value is 90.
syslog_level: INFO # System log level. The default value is INFO.
enable_syslog_wf: false # Print system logs whose levels are higher than WARNING to a separate log file. The default value is true.
enable_syslog_recycle: true # Enable auto system log recycling or not. The default value is false.
max_syslog_file_count: 4 # The maximum number of reserved log files before enabling auto recycling. The default value is 0.
# observer cluster name, consistent with obproxy's cluster_name
appname: obcluster
# root_password: # root user password, can be empty
root_password: admin
# proxyro_password: # proxyro user pasword, consistent with obproxy's observer_sys_password, can be empty
obproxy:
# Set dependent components for the component.
# When the associated configurations are not done, OBD will automatically get the these configurations from the dependent components.
depends:
- oceanbase-ce
servers:
- 192.168.32.131
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: /root/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: 192.168.32.131: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
# 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.
obclient -h127.0.0.1 -uroot@sys#obcluster -P2883 -p'your password' -Doceanbase -A
# 连接obproxy
obclient -h 127.0.0.1 -P2883 -uroot@proxysys
复制代码
5. 创建unit和资源池、租户
create resource unit lcxunit max_cpu=2,max_memory='2G',max_iops=10000,max_disk_size='2G',max_session_num=2000;
create resource pool lcxpool unit='lcxunit',unit_num=1;
CREATE TENANT IF NOT EXISTS test_tenant charset='utf8mb4', replica_num=1, zone_list=('zone1'), primary_zone='zone1', resource_pool_list=('lcxpool') SET ob_tcp_invited_nodes='%';
DROP TENANT tenant_name [FORCE]
复制代码
示例 1:
下述语句展示了创建名为 test_tenant 的一个 3 副本的 MySQL 租户(创建新租户默认是 MySQL 租户)。
obclient> CREATE TENANT IF NOT EXISTS test_tenant charset='utf8mb4', replica_num=3, zone_list=('zone1','zone2','zone3'), primary_zone='zone1;zone2,zone3', resource_pool_list=('pool1')
复制代码
示例 2:
下述语句展示了创建租户后,直接通过修改变量 ob_tcp_innvited_nodes 的值为 % 以便允许任何客户端 IP 连接该租户。
如果不调整,默认租户的连接方式为只允许本机的 IP 连接数据库。
obclient> CREATE TENANT IF NOT EXISTS test_tenant charset='utf8mb4', replica_num=3, zone_list=('zone1','zone2','zone3'), primary_zone='zone1;zone2,zone3', resource_pool_list=('pool1') SET ob_tcp_invited_nodes='%'
复制代码
示例说明如下:
primary_zone 指该租户的表的分区 Leader 所在的 Zone ,例如,primary_ zone =’ zone1; zone2, zone3’ 表示该租户的表的分区 Leader 在 zone1 上, 这时通过分号来分隔。
SELECT a.zone,concat(a.svr_ip,':',a.svr_port) observer, cpu_total, (cpu_total-cpu_assigned) cpu_free, round(mem_total/1024/1024/1024) mem_total_gb, round((mem_total-mem_assigned)/1024/1024/1024) mem_free_gb, usec_to_time(b.last_offline_time) last_offline_time, usec_to_time(b.start_service_time) start_service_time, b.status FROM __all_virtual_server_stat a JOIN __all_server b ON (a.svr_ip=b.svr_ip AND a.svr_port=b.svr_port) ORDER BY a.zone, a.svr_ip;
SELECT DATE_FORMAT(gmt_create, '%b%d %H:%i:%s') gmt_create_ , module, event, name1, value1, name2, value2, rs_svr_ip FROM __all_rootservice_event_history WHERE 1 = 1 ORDER BY gmt_create DESC LIMIT 20;
复制代码
如何查看用户表
可以通过以下 SQL 查看指定租户中所有用户表。
其中,gvtenant视图记录了租户信息 , gvtenant 视图记录了租户信息,gv tenant视图记录了租户信息,gvdatabase 记录了数据库信息,gvKaTeX parse error: Expected group after '_' at position 14: table 记录了表信息,_̲_all_virtual_me…tenant_id 表示租户 ID。
SELECT t1.tenant_id,t1.tenant_name,t2.database_name,t3.table_id,t3.table_Name,t3.tablegroup_id,t3.part_num,t4.partition_Id,t4.zone,t4.svr_ip,t4.role, round(t4.data_size/1024/1024) data_size_mb FROM `gv$tenant` t1 JOIN `gv$database` t2 ON (t1.tenant_id = t2.tenant_id) JOIN gv$table t3 ON (t2.tenant_id = t3.tenant_id AND t2.database_id = t3.database_id AND t3.index_type = 0) LEFT JOIN `__all_virtual_meta_table` t4 ON (t2.tenant_id = t4.tenant_id AND ( t3.table_id = t4.table_id OR t3.tablegroup_id = t4.table_id ) AND t4.role IN (1)) WHERE t1.tenant_id = $tenant_id ORDER BY t3.tablegroup_id, t4.partition_Id, t3.table_name ;
复制代码
查看指定用户 SQL 命令执行情况
可以通过以下 SQL 查看指定用户执行的 SQL 命令的执行情况。
其中 TENANT_ID 表示租户 ID,USER_NAME 表示用户名,IP_ADDRESS 表示执行 SQL 的节点的 IP 地址。
obclient> SELECT /*+ read_consistency(weak) ob_querytimeout(100000000) */ substr(usec_to_time(request_time),1,19) request_time_, s.svr_ip, s.client_Ip, s.sid,s.tenant_id, s.tenant_name, s.user_name, s.db_name, s.query_sql, s.affected_rows, s.return_rows, s.ret_code, s.event, s.elapsed_time, s.queue_time, s.execute_time, round(s.request_memory_used/1024/1024,2) req_mem_mb, plan_type, is_executor_rpc, is_inner_sql FROM gv$sql_audit s WHERE s.tenant_id=<TENANT_ID> AND user_name='<USER_NAME>' AND svr_ip IN ('<IP_ADDRESS>') ORDER BY request_time DESC LIMIT 100;
obclient> SELECT tenant_id, ip, round(active/1024/1024) active_mb, round(total/1024/1024) total_mb, round(freeze_trigger/1024/1024) freeze_trg_mb, round(mem_limit/1024/1024) mem_limit_mb , freeze_cnt , round((active/freeze_trigger),2) freeze_pct, round(total/mem_limit, 2) mem_usage FROM `gv$memstore` WHERE $tenant_id IN (1001) ORDER BY tenant_id, ip;
复制代码
查看合并进度
可以通过以下 SQL 查看合并进度。
其中查询结果中的 merge_process 列表示当前合并进度的百分比。
SELECT ZONE,svr_ip,major_version,min_version,ss_store_count,merged_ss_store_count,modified_ss_store_count,merge_start_time,merge_finish_time,merge_process FROM __all_virtual_partition_sstable_image_info;