1.创建测试用户:创建一个用户名为test,密码为test 的用户:
bash
create user 'test'@'%' IDENTIFIED BY 'test';
- 给测试用户赋权:给用户test赋予数据库test.* 权限
bash
grant SELECT_PRIV,LOAD_PRIV,CREATE_PRIV,ALTER_PRIV ON test.* TO test;
- 开启 experimental_enable_workload_group 配置项,在fe.conf中添加如下设置,并重启FE:
bash
experimental_enable_workload_group=true
- 开启pipline,workload_group只在新优化器上生效
bash
set experimental_enable_pipeline_engine = true;
- 创建workload group
bash
create workload group if not exists test_query
properties (
"cpu_share"="10",
"memory_limit"="10%",
"enable_memory_overcommit"="true",
"max_concurrency" = "1",
"max_queue_size" = "2",
"queue_timeout" = "3000"
);
6.给用户赋予WORKLOAD权限
bash
GRANT USAGE_PRIV ON WORKLOAD GROUP 'test_query' TO 'test'@'%';
- 使用test用户登录mysql客户端端
bash
mysql -utest -h127.0.0.1 -P9030 -ptest
- 设置test用户默认workload_group 为test_query,如果不设置默认是normal
bash
set property 'default_workload_group'='test_query';
- 使用test执行并发查询。验证workload group功能。发现当并发超过2后会报
ERROR : errCode = 2, detailMessage = queue failed, reason=query waiting queue is full, queue length=2
bash
mysqlslap -h127.0.0.1 -P9030 -utest --concurrency=300 --iterations=1 --create-schema=test --query=test.sql