Managing Hive replication policies using CDP CLI

You can use CDP CLI to perform various actions on a replication policy. You can suspend a running Hive replication policy job and then activate it. You can also delete a replication policy.

You can perform the following actions to manage a Hive replication policy:
  • Run the replication policy using the following command:
    cdp --profile [***profile name***] replicationmanager rerun-policy --cluster-crn [***target cluster crn***] --policy-name [***policy name***]
  • Abort a running policy job using the following command:
    cdp --profile [***profile name***] replicationmanager abort-policy --cluster-crn [***target cluster crn***] --policy-name [***policy name***]
  • Suspend a running policy job using the following command:
    cdp --profile [***profile name***] replicationmanager suspend-policy --cluster-crn [***source cluster crn***] --policy-name [***policy name***]
  • Activate a suspended policy job using the following command:
    cdp --profile [***profile name***] replicationmanager activate-policy --cluster-crn [***target cluster crn***] --policy-name [***policy name***]
  • Update the replication policy using the following command after you update the existing policy definition JSON file for the replication policy:
    cdp --profile [***profile name***] replicationmanager update-policy --cluster-crn [***target cluster crn***] --policy-name [***policy name***] --update-policy-definition [***policy definition***]
  • Run the following commands in the given sequence to download a diagnostic bundle for the specified replication policy:
    1. cdp --profile [***profile name***] replicationmanager collect-diagnostic-bundle --cluster-crn [***target cluster crn***] --policy-name [***policy name***]
      The command initiates the collection operation of the diagnostic bundle for the specified replication policy on the target Cloudera Manager.
      The following sample snippet shows the command output:
      {
          "commandId": 58747,
          "name": "Replication Diagnostics Collection",
          "active": true,
          "startTime": "2022-11-07T12:27:25.872Z"
      }
      
    2. cdp --profile [***profile name***] replicationmanager get-command-status --cluster-crn [***target cluster crn***] --policy-name [***policy name***]
      The command returns diagnostic bundle collection status as:
      • The diagnostic bundle collection is IN PROGRESS on the Cloudera Manager server.
      • The diagnostic bundle collection is complete and can be DOWNLOADABLE WITH URL using the URL specified in the resultDataUrl field in the command output.
      • The diagnostic bundle collection is complete and can be DOWNLOADABLE WITH CLI using the download-diagnostic-bundle CDP CLI operation in Step 3.
      • The diagnostic bundle collection FAILED on the server.
      The following sample snippet shows the command output when the bundleStatus is DOWNLOADABLE WITH CLI:
      {
          "commandId": 58741,
          "success": true,
          "active": false,
          "name": "Replication Diagnostics Collection",
          "resultDataUrl": "http://[***cm host***]:[***cm port***]/cmf/command/58741/download",
          "resultMessage": "Replication diagnostics collection succeeded.",
          "bundleStatus": "DOWNLOADABLE WITH CLI",
          "bundleStatusMessage": "The bundle can be downloaded with the download-diagnostic-bundle operation."
      }
      
    3. cdp --profile [***profile name***] replicationmanager download-diagnostic-bundle --cluster-crn [***target cluster crn***] --command-id [***command ID***]
    Run this command only if the bundleStatus shows DOWNLOADABLE WITH CLI in the Step 3 command output. The command output appears as a binary string in base64 encoded format on the screen.

    You can use any method to parse the response. Alternatively, you can also use one of the following commands to parse the response:

    • cdp --profile [***profile name***] replicationmanager download-diagnostic-bundle --cluster-crn [***target cluster crn***] --command-id [***command ID***] > [***<file>.json***]

      The diagnostic bundle is saved in the specified file in JSON format and downloaded to your machine.

    • cdp --profile [***profile name***] replicationmanager download-diagnostic-bundle --cluster-crn [***target cluster crn***] --command-id [***command ID***] > [***<filename>.json***] | jq -r ‘.bundleFile’ | base64 -D > [***<filename>.zip***]

      The diagnostic bundle is saved to the specified ZIP file and downloaded to your machine.

    • cdp --profile [***profile name***] replicationmanager download-diagnostic-bundle --cluster-crn [***target cluster crn***] --command-id [***command ID***] > [***<filename>.json***] | jq -r ‘.bundleFile’ | base64 -D >| bsdtar -xcf -f [***location***]

      The diagnostic bundle is saved as a ZIP file and extracted to the specified location on your machine automatically.

  • Delete the replication policy using the following command:
    cdp --profile [***profile name***] replicationmanager delete-policy --cluster-crn [***target cluster crn***] --policy-name [***policy name***]