[英]How to copy redshift cluster parameter group workload management settings from existing one?
Is there a way to copy Redshift workload management settings from existing one?有没有办法从现有的 Redshift 工作负载管理设置中复制?
I have a complex WLM configuration in my redshift parameter group, which I want to copy to another configuration.我的 redshift 参数组中有一个复杂的 WLM 配置,我想将其复制到另一个配置中。 Doing it manually is error prone.手动执行很容易出错。 Is there a way to copy it automatically?有没有办法自动复制它?
Here is my WLM config JSON, which I copied from Redshift console's WLM config page:这是我从 Redshift 控制台的 WLM 配置页面复制的 WLM 配置 JSON:
[
{
"query_group": [
"defaulton",
"lab4on"
],
"query_group_wild_card": 0,
"user_group": [],
"user_group_wild_card": 0,
"concurrency_scaling": "off",
"priority": "normal",
"queue_type": "auto",
"auto_wlm": true
},
{
"query_group": [
"lab1",
"lab2",
"lab3normal",
"lab4off",
"lab5",
"lab6reads",
"defaultoff"
],
"query_group_wild_card": 0,
"user_group": [],
"user_group_wild_card": 0,
"concurrency_scaling": "off",
"priority": "normal",
"queue_type": "auto",
"auto_wlm": true
},
{
"query_group": [
"lab3highest"
],
"query_group_wild_card": 0,
"user_group": [],
"user_group_wild_card": 0,
"concurrency_scaling": "off",
"priority": "highest",
"queue_type": "auto",
"auto_wlm": true
},
{
"query_group": [
"lab3lowest"
],
"query_group_wild_card": 0,
"user_group": [],
"user_group_wild_card": 0,
"concurrency_scaling": "off",
"priority": "lowest",
"queue_type": "auto",
"auto_wlm": true
},
{
"query_group": [
"lab6writes"
],
"query_group_wild_card": 0,
"user_group": [],
"user_group_wild_card": 0,
"concurrency_scaling": "off",
"priority": "highest",
"queue_type": "auto",
"auto_wlm": true
},
{
"query_group": [],
"query_group_wild_card": 0,
"user_group": [],
"user_group_wild_card": 0,
"priority": "normal",
"queue_type": "auto",
"auto_wlm": true
},
{
"short_query_queue": false
}
]
I could copy it to a new parameter group following below steps, but would like to simplify it if possible.我可以按照以下步骤将它复制到一个新的参数组,但如果可能的话,我想简化它。
"
) with backslash doublequotes ( \\"
)更换所有双引号( "
)用双引号反斜线( \\"
)modify_pg.json
在我的本地创建下面的 json 文件,例如modify_pg.json
[
{
"ParameterName": "wlm_json_configuration",
"ParameterValue": "<input_formatted_json_here>"
}
]
<input_formatted_json_here>
above with the formatted text in my editor (created in step# 3 above)用我的编辑器中的格式化文本替换上面的<input_formatted_json_here>
(在上面的第 3 步中创建)myclusterparametergroup
在 Redshift 中创建一个新的参数组,例如myclusterparametergroup
aws redshift modify-cluster-parameter-group --parameter-group-name myclusterparametergroup --parameters file://modify_pg.json
Below is my final modify_pg.json
file, which I am able to use in my new parameter group.下面是我的最终modify_pg.json
文件,我可以在我的新参数组中使用它。 But is there a way to simplify this?但是有没有办法简化这个?
[
{
"ParameterName": "wlm_json_configuration",
"ParameterValue": "[{\"query_group\":[\"defaulton\",\"lab4on\"],\"query_group_wild_card\":0,\"user_group\":[],\"user_group_wild_card\":0,\"concurrency_scaling\":\"off\",\"priority\":\"normal\",\"queue_type\":\"auto\",\"auto_wlm\":true},{\"query_group\":[\"lab1\",\"lab2\",\"lab3normal\",\"lab4off\",\"lab5\",\"lab6reads\",\"defaultoff\"],\"query_group_wild_card\":0,\"user_group\":[],\"user_group_wild_card\":0,\"concurrency_scaling\":\"off\",\"priority\":\"normal\",\"queue_type\":\"auto\",\"auto_wlm\":true},{\"query_group\":[\"lab3highest\"],\"query_group_wild_card\":0,\"user_group\":[],\"user_group_wild_card\":0,\"concurrency_scaling\":\"off\",\"priority\":\"highest\",\"queue_type\":\"auto\",\"auto_wlm\":true},{\"query_group\":[\"lab3lowest\"],\"query_group_wild_card\":0,\"user_group\":[],\"user_group_wild_card\":0,\"concurrency_scaling\":\"off\",\"priority\":\"lowest\",\"queue_type\":\"auto\",\"auto_wlm\":true},{\"query_group\":[\"lab6writes\"],\"query_group_wild_card\":0,\"user_group\":[],\"user_group_wild_card\":0,\"concurrency_scaling\":\"off\",\"priority\":\"highest\",\"queue_type\":\"auto\",\"auto_wlm\":true},{\"query_group\":[],\"query_group_wild_card\":0,\"user_group\":[],\"user_group_wild_card\":0,\"priority\":\"normal\",\"queue_type\":\"auto\",\"auto_wlm\":true},{\"short_query_queue\":false}]"
}
]
I've done this several times for clients and you are nearly there.我已经为客户做过好几次了,你就快到了。 The same way you are modifying the PG using the AWS CLI, you can extract the JSON from the existing PG using the AWS CLI.与使用 AWS CLI 修改 PG 的方式相同,您可以使用 AWS CLI 从现有 PG 中提取 JSON。
aws redshift describe-cluster-parameters ...
You will get back a JSON that has the parameter value for a specified PG.您将返回一个 JSON,其中包含指定 PG 的参数值。 It is then just a matter of modifying the returned values to the string format you need.然后只需将返回值修改为您需要的字符串格式即可。 This requires some programming or scripting - I'll go with Linux scripting as this is a popular option.这需要一些编程或脚本编写 - 我将使用 Linux 脚本编写,因为这是一个流行的选项。 Command line tools you will likely want:您可能需要的命令行工具:
The process you will follow will be something like您将遵循的过程类似于
Now you can do this in python using boto3 or in java or ... This is just one path.现在你可以在 python 中使用 boto3 或在 java 或 ... 这只是一个路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.