GBase 8a 资源管理

目录

检查cgconfig服务是否启动

创建资源消费组

资源消费组新增用户

创建静态资源池

创建资源计划

创建资源指令

激活资源管理

使用计划1进行sql查询

关闭资源管理


检查cgconfig服务是否启动

[root@localhost ~]# yum list installed | grep libcgroup
[root@localhost ~]# yum list installed | grep libcgroup-tools

[root@localhost ~]# yum list | grep libcgroup
libcgroup.x86_64                            0.41-21.el7                base        
libcgroup-devel.x86_64                      0.41-21.el7                base         
libcgroup-tools.x86_64                      0.41-21.el7                base  

[root@localhost ~]# yum install -y libcgroup
[root@localhost ~]# yum install -y libcgroup-tools

[root@localhost ~]# cgclear - unload the cgroup filesystem
[root@localhost ~]# systemctl start cgconfig.service
[root@localhost ~]# systemctl enable cgconfig.service
[root@localhost ~]# systemctl status cgconfig.service

创建资源消费组

use test;
create consumer group group1;

资源消费组新增用户

create user user1;
grant all on *.* to user1;
create user user2;
grant all on *.* to user2;
alter consumer group group1 add user user1;
alter consumer group group1 add user user2;

创建静态资源池

(资源池分为静态资源池与动态资源池两种,静态资源池为资源供给者,而动态资源池为资源管理者,约束任务对资源的使用)

创建静态资源池

create resource pool s_p1(
priority=1,
cpu_percent=100,
max_memory=8796093022207,
max_temp_diskspace=8796093022207,
max_disk_space=8796093022207,
max_disk_writeio=8796093022207,
max_disk_readio=8796093022207)type static;

创建动态资源池

create resource pool d_p1(
priority=1,
cpu_percent=10,
max_memory=1024000000000,  
max_temp_diskspace=10240000000,
max_disk_space=307200000000,
max_disk_writeio=2796093022207,
max_disk_readio=1024000000)
type dynamic base on s_p1;

create resource pool d_p2(
priority=1,
cpu_percent=90,
max_memory=1024000000000,
max_temp_diskspace=10240000000,
max_disk_space=307200000000,
max_disk_writeio=2796093022207,
max_disk_readio=1024000000)
type dynamic base on s_p1;

创建资源计划

(资源计划会将资源消费组挂接到合理的资源池中)

create resource plan plan1;
create resource plan plan2;

创建资源指令

(指定在资源计划中资源消费组与动态资源池的挂接关系)

create resource directive directive1(
pool_name='d_p1',
plan_name='plan1',
group_name='group1');

create resource directive directive2(
pool_name='d_p1',
plan_name='plan1',
group_name='default_consumer_group');

create resource directive directive3(
pool_name='d_p2',
plan_name='plan2',
group_name='group1');

create resource directive directive4(
pool_name='d_p2',
plan_name='plan2',
group_name='default_consumer_group');

激活资源管理

gbase> show vcs;
+---------+--------------+---------+
| id      | name         | default |
+---------+--------------+---------+
| vc00001 | vcname000001 | Y       |
+---------+--------------+---------+

gbase> active resource plan plan1 on vc vcname000001;

使用计划1进行sql查询

gccli -uuser1
use vcname000001.test;
select
        l_returnflag,
        l_linestatus,
        sum(l_quantity) as sum_qty,
        sum(l_extendedprice) as sum_base_price,
        sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
        sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
        avg(l_quantity) as avg_qty,
        avg(l_extendedprice) as avg_price,
        avg(l_discount) as avg_disc,
        count(*) as count_order
from
        lineitem
where
        l_shipdate <= date '1998-12-01' - interval '106' day
group by
        l_returnflag,
        l_linestatus
order by
        l_returnflag,
        l_linestatus;

关闭资源管理

gbase> deactive resource plan on vc vcname000001;

--使用计划2进行查询 与资源计划1对比执行计划的差异
--启动plan2
active resource plan plan2 on vc vcname000001;
--执行查询
gccli -uuser2
use vc1.test;
select
        l_returnflag,
        l_linestatus,
        sum(l_quantity) as sum_qty,
        sum(l_extendedprice) as sum_base_price,
        sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
        sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
        avg(l_quantity) as avg_qty,
        avg(l_extendedprice) as avg_price,
        avg(l_discount) as avg_disc,
        count(*) as count_order
from
        lineitem
where
        l_shipdate <= date '1998-12-01' - interval '106' day
group by
        l_returnflag,
        l_linestatus
order by
        l_returnflag,
        l_linestatus;
--关闭资源管理
deactive resource plan  on vc vcname000001;		

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值