Created
December 19, 2014 08:33
-
-
Save azurecube/3bb827db631e9d51c7a2 to your computer and use it in GitHub Desktop.
Install CDH with CM API using Local Parcel Repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script checked on CM5.2.1 and CDH5.2.1 | |
# This assumes cm agents started up on each nodes | |
# Properties | |
CMNODE="node3.cloudera.com" | |
TARGET="node4.cloudera.com node3.cloudera.com" | |
CLUSTER="Cluster1" | |
ROOT_PASS="cloudera" | |
BASE=http://$CMNODE:7180/api/v8 | |
CDH_VER=5.2.1 | |
CDH_MAJOR=`echo $CDH_VER | cut -d'.' -f1` | |
PARCEL_REP="node3.cloudera.com" | |
# Start Trial | |
curl -X POST -u "admin:admin" -i $BASE/cm/trial/begin | |
# Setting MGMT | |
## Create mgmt service | |
curl -X PUT -u "admin:admin" -i \ | |
-H "content-type:application/json" \ | |
-d '{ "name": "mgmt" }' \ | |
$BASE/cm/service | |
## Assign and Configure Roles | |
curl -X PUT -u "admin:admin" -i $BASE/cm/service/autoAssignRoles | |
curl -X PUT -u "admin:admin" -i $BASE/cm/service/autoConfigure | |
## Setting Report Manager DB | |
### Report Manager password | |
rman_pass=`sudo grep com.cloudera.cmf.REPORTSMANAGER.db.password /etc/cloudera-scm-server/db.mgmt.properties | cut -d= -f2` | |
### Configuration | |
curl -X PUT -u "admin:admin" -i \ | |
-H "content-type:application/json" \ | |
-d '{ "items": [{"name": "headlamp_database_host", "value": "'$CMNODE':7432"}, | |
{"name": "headlamp_database_name", "value": "rman"}, | |
{"name": "headlamp_database_password", "value": "'$rman_pass'"}, | |
{"name": "headlamp_database_user", "value": "rman"}, | |
{"name": "headlamp_database_type", "value": "postgresql"} | |
]}' \ | |
$BASE/cm/service/roleConfigGroups/mgmt-REPORTSMANAGER-BASE/config | |
## Delete Navigator Entry | |
curl -X DELETE -u "admin:admin" -i \ | |
$BASE/cm/service/roles/`curl -sS -X GET -u "admin:admin" -i $BASE/cm/service/roles | grep -B1 '"type" : "NAVIGATORMETASERVER"' | grep name | cut -d'"' -f4` | |
curl -X DELETE -u "admin:admin" -i \ | |
$BASE/cm/service/roles/`curl -sS -X GET -u "admin:admin" -i $BASE/cm/service/roles | grep -B1 '"type" : "NAVIGATOR"' | grep name | cut -d'"' -f4` | |
# Startup | |
curl -X POST -u "admin:admin" -i $BASE/cm/service/commands/start | |
# Setting Cluster | |
## Create Cluster | |
curl -X POST -u "admin:admin" -i \ | |
-H "content-type:application/json" \ | |
-d '{ "items": [ | |
{ | |
"name": "'$CLUSTER'", | |
"version": "CDH'$CDH_MAJOR'" | |
} | |
] }' \ | |
$BASE/clusters | |
## Assign Hosts | |
host_ids=`curl -sS -X GET -u "admin:admin" -i $BASE/hosts | grep '"hostId" :' | cut -d'"' -f 4` | |
for i in $host_ids | |
do | |
curl -X POST -u "admin:admin" -i \ | |
-H "content-type:application/json" \ | |
-d '{ "items": [ {"hostId": "'$i'"} ]}' \ | |
$BASE/clusters/$CLUSTER/hosts | |
done | |
## Assign Service | |
curl -X POST -u "admin:admin" -i \ | |
-H "content-type:application/json" \ | |
-d '{ "items": [ {"name": "zookeeper", "type": "ZOOKEEPER"}, | |
{"name": "hive" , "type": "HIVE"}, | |
{"name": "sqoop" , "type": "SQOOP"}, | |
{"name": "yarn" , "type": "YARN"}, | |
{"name": "hdfs" , "type": "HDFS"} | |
] }' \ | |
$BASE/clusters/$CLUSTER/services | |
## Assign and Configure Roles | |
curl -X PUT -u "admin:admin" -i $BASE/clusters/$CLUSTER/autoAssignRoles | |
curl -X PUT -u "admin:admin" -i $BASE/clusters/$CLUSTER/autoConfigure | |
## Parcel Operation | |
### Getting CDH Parcel name | |
CDH=`curl -sS -X GET -u "admin:admin" -i $BASE/clusters/$CLUSTER/parcels | grep -A1 '"product" : "CDH"' | grep '"version" : "'$CDH_MAJOR | cut -d'"' -f4` | |
### Setting Parcel Repository | |
curl -X PUT -u "admin:admin" -i \ | |
-H "content-type:application/json" \ | |
-d '{ "items": [ {"name" : "REMOTE_PARCEL_REPO_URLS", | |
"value": "http://'$PARCEL_REP'/archive/cdh'$CDH_MAJOR'/'$CDH_VER',http://archive.cloudera.com/cdh4/parcels/latest/,http://archive.cloudera.com/impala/parcels/latest/,http://archive.cloudera.com/search/parcels/latest/,http://archive.cloudera.com/spark/parcels/latest/,http://archive.cloudera.com/navigator-keytrustee5/parcels/latest/,http://archive.cloudera.com/sqoop-connectors/parcels/latest/,http://archive.cloudera.com/accumulo/parcels/1.4/,http://archive.cloudera.com/accumulo-c5/parcels/latest/" | |
}]}' \ | |
$BASE/cm/config | |
### short function to wait previous operation | |
parcel_wait_for () { | |
while [ 1 ] | |
do | |
curl -sS -X GET -u "admin:admin" -i $BASE/clusters/$CLUSTER/parcels/products/CDH/versions/$CDH | grep '"stage" : "'$1'"' && break | |
sleep 5 | |
done | |
} | |
### Download Parcel | |
curl -X POST -u "admin:admin" -i $BASE/clusters/$CLUSTER/parcels/products/CDH/versions/$CDH/commands/startDownload | |
parcel_wait_for DOWNLOADED | |
### Distribute Parcel | |
curl -X POST -u "admin:admin" -i $BASE/clusters/$CLUSTER/parcels/products/CDH/versions/$CDH/commands/startDistribution | |
parcel_wait_for DISTRIBUTED | |
### Activate Parcel | |
curl -X POST -u "admin:admin" -i $BASE/clusters/$CLUSTER/parcels/products/CDH/versions/$CDH/commands/activate | |
parcel_wait_for ACTIVATED | |
## Configuring Hive metastore DB | |
curl -X PUT -u "admin:admin" -i \ | |
-H "content-type:application/json" \ | |
-d '{ "items": [{"name": "hive_metastore_database_host", "value": "'$CMNODE'"}, | |
{"name": "hive_metastore_database_name", "value": "hive"}, | |
{"name": "hive_metastore_database_password", "value": "hive"}, | |
{"name": "hive_metastore_database_port", "value": "7432"}, | |
{"name": "hive_metastore_database_type", "value": "postgresql"} | |
]}' \ | |
$BASE/clusters/$CLUSTER/services/hive/config | |
## FirstRun | |
curl -X POST -u "admin:admin" -i $BASE/clusters/$CLUSTER/commands/firstRun |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment