目录
欢迎来到活动中心!快速了解阿里云最新产品优惠和所有活动资讯
https://www.aliyun.com/activity?userCode=m4a0ywsh
-------------------------
SELECT @@version;
drop table if exists t_parttable;
create table t_parttable(
id bigint not null primary key,
name varchar(50) not NULL,
KEY name_ind(NAME) LOCAL
) DEFAULT CHARSET=utf8mb4 partition by hash(mod(id,1000)) partitions 8;
insert into t_parttable(id, name) values(1,'a'),(2,'A'),(3,'b'),(4,'B'),(5,'c'),(6,'C'),(7,'d'),(8,'D');
set session ob_query_timeout=1000000; select * from t_parttable where name='a';
explain select * from t_parttable where name='a';
select /*+read_consistency(weak)*/ * from t_parttable where name='a';
select * from t_parttable partition(p1);
select * from t_parttable partition(p2);
-------------------------
# 查看分区表的数据
SHOW CREATE TABLE db_bin.t_parttable;
SELECT /*+read_consistency(weak)*/ * FROM db_bin.t_parttable ORDER BY id ;
# 查看租户的资源单元(Unit)分布
SELECT tenant_name, unit_id,zone,svr_ip,max_cpu,round(max_memory/1024/1024/1024) max_mem_gb FROM gv$unit;
# 查看租户的负载均衡历史
SELECT str_to_date(h.gmt_create,'%Y-%m-%d %h:%i:%s') gmt_create, h.zone, t.database_name, t.tablegroup_name, t.table_name, t.part_num,h.partition_id,h.data_size, h.data_src_ip, h.dest_unit_id, h.dest_ip, h.result_code, h.COMMENT , h.rs_svr_ip
FROM gv$unit_load_balance_event_history h JOIN gv$TABLE t ON (h.table_id=t.table_id)
WHERE t.table_name NOT LIKE '%recycle%' AND t.database_name='db_bin'
ORDER BY gmt_create DESC LIMIT 100;
-------------------------
# 查看集群节点资源使用情况
SELECT svr_ip, s.zone, s.cpu_total, s.cpu_assigned, s.cpu_assigned_percent, round(s.mem_total/1024/1024/1024) mem_total_gb, round(s.mem_assigned/1024/1024/1024) mem_ass_gb, s.mem_assigned_percent
FROM __all_virtual_server_stat s
ORDER BY zone,svr_ip;
# 查看资源单元规格定义
SELECT NAME, max_cpu, min_cpu, round(max_memory/1024/1024/1024) max_mem_gb , round(min_memory/1024/1024/1024) min_mem_gb FROM __all_unit_config ORDER BY unit_config_id LIMIT 10;
# 查看已有租户及其资源池信息
SELECT t.tenant_name, p.name pool_name, c.name config_name, p.unit_count, p.zone_list, t.`locality`
FROM __all_resource_pool p JOIN __all_unit_config c ON (p.unit_config_id=c.unit_config_Id)
LEFT JOIN __all_tenant t ON (p.tenant_id=t.tenant_id)
WHERE p.NAME IN ('yq_Pool','app_pool') ORDER BY p.resource_pool_id;
-------------------------
# 清理已经创建的同名租户
DROP tenant IF EXISTS demo_t;
DROP resource pool demo_pool;
# 创建新的资源池(Resource Pool)
CREATE resource pool demo_pool unit='S0_unit_config', unit_num=2;
# 创建租户
CREATE tenant IF NOT EXISTS demo_t resource_pool_list=('demo_pool') SET VARIABLES ob_tcp_invited_nodes='%';
# 查看已有租户及其资源池信息
SELECT now() cur_time, str_to_date(t.gmt_create,'%Y-%m-%d %h:%i:%s') gmt_create, t.tenant_name, p.name pool_name, c.name config_name, p.unit_count, p.zone_list, t.`locality`
FROM __all_resource_pool p JOIN __all_unit_config c ON (p.unit_config_id=c.unit_config_Id)
LEFT JOIN __all_tenant t ON (p.tenant_id=t.tenant_id)
WHERE p.NAME IN ('demo_pool') ORDER BY p.resource_pool_id;
-------------------------
-------------------------
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。