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:
  • Suspend a running policy job:
    cdp --profile [***PROFILE NAME***] replicationmanager suspend-policy --cluster-crn  [***SOURCE CLUSTER CRN***] --policy-name [***PROFILE NAME***]
  • Activate a suspended policy job:
    cdp --profile [***PROFILE NAME***] replicationmanager activate-policy --cluster-crn [***TARGET CLUSTER CRN***] --policy-name [***PROFILE NAME***]
  • Download the diagnostic bundle for the specified replication policy:
    1. Initiate the diagnostic bundle collection operation for the specified replication policy on the target Cloudera Manager.
      cdp --profile [***PROFILE NAME***] replicationmanager collect-diagnostic-bundle --cluster-crn [***TARGET CLUSTER CRN***] --policy-name [***POLICY NAME***]
      The following sample snippet shows the command output:
      {
          "commandId": 58747,
          "name": "Replication Diagnostics Collection",
          "active": true,
          "startTime": "2022-11-07T12:27:25.872Z"
      }
      
    2. View the diagnostic bundle collection status. Optionally, you can use the following command to get the current status of any Cloudera Manager command.
      cdp --profile [***PROFILE NAME***] replicationmanager get-command-status --cluster-crn [***TARGET CLUSTER CRN***] --policy-name [***POLICY NAME***] 

      The command returns the following responses:

      • The diagnostic bundle collection is IN PROGRESS on the Cloudera Manager server.
      • The diagnostic bundle collection is complete, and is DOWNLOADABLE WITH URL using the URL specified in the resultDataUrl field in the command output.
      • The diagnostic bundle collection is complete, and is DOWNLOADABLE WITH CLI using the download-diagnostic-bundle CDP CLI operation in Step 3.
      • The diagnostic bundle collection has FAILED on the Cloudera Manager 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. Run the following command only if the bundleStatus shows DOWNLOADABLE WITH CLI in the Step 2 command output. The command output appears as a binary string in base64 encoded format on the screen.
      cdp --profile [***PROFILE NAME***] replicationmanager download-diagnostic-bundle --cluster-crn [***TARGET CLUSTER CRN***] --command-id [***COMMAND ID***]
      You can use any method to parse the response. Alternatively, you can also use one of the following methods to parse the response:
    MethodCommand
    Save the diagnostic bundle in the specified file in JSON format and download to your machine
     cdp --profile [***PROFILE NAME***] replicationmanager download-diagnostic-bundle --cluster-crn [***TARGET CLUSTER CRN***] --command-id [***COMMAND ID***] > [***<FILE>.JSON***]
    Save the diagnostic bundle to the specified ZIP file and download 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***]
    Save the diagnostic bundle as a ZIP file and extract it to the specified location on your machine automatically.
    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***]
  • Delete the replication policy:
    cdp --profile [***PROFILE NAME***] replicationmanager delete-policy --cluster-crn [***SOURCE CLUSTER CRN***] --policy-name [***POLICY NAME***]