You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

HDP 2.6.0.3集群升级至2.6.3:CLI/REST API自动化可行性及API问询

Automating HDP 2.6.0.3 to 2.6.3 Upgrade via Ambari CLI/REST API

Absolutely, you can fully automate the HDP upgrade from 2.6.0.3 to 2.6.3 using Ambari's CLI or REST API—every action you perform in the Ambari GUI has a corresponding API endpoint or CLI command behind it. This lets you script the entire workflow without manual intervention. Below's a breakdown of how to do this with both methods:

Using Ambari REST API

The Ambari REST API provides granular control over every step of the upgrade process. Here's a step-by-step guide with example commands:

1. Authenticate to Ambari

First, get an authentication token to avoid passing credentials in every request:

curl -i -u admin:admin -X POST http://<AMBARI_SERVER>:8080/api/v1/users/admin/tokens -H "X-Requested-By: ambari"

Extract the token value from the response—you'll use this in the Authorization header for subsequent calls.

2. Verify Current Cluster Version

Confirm your cluster's current HDP version and check available stacks:

curl -H "Authorization: Bearer <TOKEN>" -H "X-Requested-By: ambari" -X GET "http://<AMBARI_SERVER>:8080/api/v1/clusters/<CLUSTER_NAME>/versions"

3. Add the HDP 2.6.3 Repository

Register the HDP 2.6.3 repository with Ambari (replace <HDP_2.6.3_REPO_URL> with the correct URL for your OS, e.g., CentOS 7 uses http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.3.0):

curl -H "Authorization: Bearer <TOKEN>" -H "X-Requested-By: ambari" -X POST "http://<AMBARI_SERVER>:8080/api/v1/stacks/HDP/versions/2.6.3/repositories" -d '{
  "Repositories": {
    "base_url": "<HDP_2.6.3_REPO_URL>",
    "verify_base_url": true,
    "repo_name": "HDP-2.6.3"
  }
}'

4. Initiate the Cluster Upgrade

Trigger the upgrade workflow by setting the cluster's desired version to HDP-2.6.3:

curl -H "Authorization: Bearer <TOKEN>" -H "X-Requested-By: ambari" -X PUT "http://<AMBARI_SERVER>:8080/api/v1/clusters/<CLUSTER_NAME>" -d '{
  "Clusters": {
    "desired_version": "HDP-2.6.3"
  }
}'

This starts the full upgrade process: stopping services, upgrading packages, restarting services, and running post-upgrade checks.

5. Monitor Upgrade Progress

Track the status of the upgrade request to ensure it completes successfully:

curl -H "Authorization: Bearer <TOKEN>" -H "X-Requested-By: ambari" -X GET "http://<AMBARI_SERVER>:8080/api/v1/clusters/<CLUSTER_NAME>/requests"

Look for the request with request_context containing "Upgrade Cluster". The status field will show IN_PROGRESS, COMPLETED, or FAILED. For detailed logs, use the request ID in:

curl -H "Authorization: Bearer <TOKEN>" -H "X-Requested-By: ambari" -X GET "http://<AMBARI_SERVER>:8080/api/v1/clusters/<CLUSTER_NAME>/requests/<REQUEST_ID>"

Using Ambari CLI

If you prefer a more streamlined interface, the Ambari CLI (a Python-based tool) simplifies these steps into easy commands:

1. Install and Log In

If not already installed, install the Ambari CLI via pip:

pip install ambari-shell

Then log in to your Ambari server:

ambari-shell --ambari-server <AMBARI_SERVER> --username admin --password admin

2. Select Your Cluster

Switch to the target cluster in the CLI:

cluster(<CLUSTER_NAME>)

3. Add the HDP 2.6.3 Repository

Register the repository:

add_repo --stack HDP --version 2.6.3 --repo-name HDP-2.6.3 --base-url <HDP_2.6.3_REPO_URL>

4. Start the Upgrade

Trigger the cluster upgrade:

upgrade_cluster --version HDP-2.6.3

5. Monitor Progress

List all ongoing requests to track the upgrade:

list_requests

To get details about a specific request:

show_request <REQUEST_ID>

Critical Pre-Upgrade Checks

Before automating the upgrade, make sure to:

  • Take full backups of HDFS metadata, HBase tables, and any external databases (like Ambari's PostgreSQL instance).
  • Verify all cluster services are in a healthy state (no alerts, all components running).
  • Test the upgrade workflow in a staging environment first to catch any compatibility issues.
  • Ensure all cluster nodes can access the HDP 2.6.3 repository.

内容的提问来源于stack exchange,提问作者enodmilvado

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:21:53