简体   繁体   English

如何从现有的红移集群参数组工作负载管理设置复制?

[英]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.我可以按照以下步骤将它复制到一个新的参数组,但如果可能的话,我想简化它。

  1. copy the json from existing param group as above to a nodepad editor将上述现有参数组中的 json 复制到 nodepad 编辑器
  2. remove all nextline and space characters from this json从此 json 中删除所有下一行和空格字符
  3. replace all doublequotes( " ) with backslash doublequotes ( \\" )更换所有双引号( " )用双引号反斜线( \\"
  4. create below json file in my local eg modify_pg.json在我的本地创建下面的 json 文件,例如modify_pg.json
[
    {
        "ParameterName": "wlm_json_configuration",
        "ParameterValue": "<input_formatted_json_here>"
    }
]
  1. replace <input_formatted_json_here> above with the formatted text in my editor (created in step# 3 above)用我的编辑器中的格式化文本替换上面的<input_formatted_json_here> (在上面的第 3 步中创建)
  2. create a new parameter group in Redshift, eg myclusterparametergroup在 Redshift 中创建一个新的参数组,例如myclusterparametergroup
  3. run below CLI command to modify WLM of this parameter group with the json file在 CLI 命令下运行以使用 json 文件修改此参数组的 WLM
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:您可能需要的命令行工具:

  • sed sed
  • tr tr
  • jq (tag line for this tool is "sed for json") jq(此工具的标记行是“sed for json”)

The process you will follow will be something like您将遵循的过程类似于

  1. extract parameters using aws cli使用 aws cli 提取参数
  2. create shell variable with the parameters you want and the values you want each to have.使用您想要的参数和您希望每个参数拥有的值创建 shell 变量。 jq is great for this jq 非常适合这个
  3. create the new PG if needed如果需要,创建新的 PG
  4. modify the JSON shell variable to remove \\n and spaces - replacement_text=$(echo $wlm_configuration | sed -e 's/"/\\\\"/g' | tr -d '\\n ') create top JSON for PG as a shell variable (same as your modify_pg.json)修改 JSON shell 变量以删除 \\n 和空格 - replacement_text=$(echo $wlm_configuration | sed -e 's/"/\\\\"/g' | tr -d '\\n ') 为 PG 创建顶级 JSON 作为shell 变量(与您的 modify_pg.json 相同)
  5. run aws cli to modify the new PG - combine these 2 JSONs right on the command line by using option: --parameters $(echo $modify_pg | tr -d '\\n ' | sed -e "s/<<WLM_CONFIGURATION>>/$replacement_text/g")运行 aws cli 以修改新的 PG - 通过使用选项在命令行上组合这两个 JSON: --parameters $(echo $modify_pg | tr -d '\\n ' | sed -e "s/<<WLM_CONFIGURATION>> /$replacement_text/g")

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.

相关问题 如何将所有数据从一个红移集群复制到另一个红移集群 - How to copy all the data from one redshift cluster to another redshift cluster 如何通过脚本将Redshift群集快照从一个帐户复制到另一个帐户 - How to copy redshift cluster snapshot from one account to another account through script AWS Redshift Workload Management 中的用户组和查询组有什么区别? - What's the difference between a user group and query group in AWS Redshift Workload Management? 无法将数据从 s3 复制到私有子网中的 redshift 集群 - Can not copy data from s3 to redshift cluster in a private subnet 将整个模式从一个红移集群复制到另一个 - Copying entire schema from one redshift cluster to another 如何从Kinesis - &gt; Redshift批量复制数据 - How to copy data in bulk from Kinesis -> Redshift 如何从另一个 AWS 账户的快照恢复 Redshift 集群 - How to restore Redshift cluster from another AWS Account's snapshot 如何从命令行关闭RedShift集群? - How can I shut down a RedShift cluster from the command line? 使用复制命令将数据从Amazon S3加载到Redshift-如何在Redshift中存储复制时间 - Data load from Amazon S3 to Redshift using Copy Command - How to store Time of copy in Redshift 从AWS集群外部的Linux服务器在Redshift数据库上执行COPY命令 - Execute COPY command on Redshift database from a Linux server outside AWS cluster
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM