思维导图
是什么
Ambari Blueprints 是用来自动化安装hdp组件的配置文件,它告诉ambari:要安装什么service/component,安装在哪里。
它通过REST API与ambari交互,上传和更新配置。
前提
Ambari server/agent已经安装完成
步骤
-
Step 1: 手工写或者下载现有hdp系统的blueprint文件。
下载方法:
GET /api/v1/clusters/:clusterName?format=blueprint
e.g.
$ curl -H "X-Requested-By: ambari" --user admin:admin \ > -X GET http://localhost:8080/api/v1/clusters/RoyCLUSTER?format=blueprint > mybl.json
可以先手工安装HDP,再用上面的办法把blueprint 下载下来,如此就获取了一个真实的配置文件,可以在这个文件的基础上做修改。
下面就是这个配置文件的简化版,介绍它的框架结构。
Blueprint Structure
{
"configurations" : [
### 定义hdp里面各个组件的配置,也可以不写,使用默认配置。
],
"host_groups" : [
{
"configurations" : [ ],
"components" : [
{ "name": "NODEMANAGER" },
{ "name": "DATANODE" },
{ "name" : "METRICS_MONITOR" }
],
"name" : "slavenode",
"cardinality" : "5"
},
{
### 定义哪个host group 安装什么component。
} ...
],
"settings" : [
### 其它设置,比如component自启动。可以不写。
],
"Blueprints" : {
"stack_name" : "HDP",
"stack_version" : "2.6"
### Blueprint and stack information
}
}
-
Step 2: Register Blueprint with Ambari
POST /api/v1/blueprints/:blueprintName
e.g.
$ curl -H "X-Requested-By: ambari" --user admin:admin \ > -X POST http://localhost:8080/api/v1/blueprints/cluster_blueprint \ > -d@mybl.json
这个blueprint文件就是上一步生成的mybl.json
-
Step 3: Create Cluster Template
把 host 和 blueprint file 中的 host_group 对应起来。
File: hostmapping-3.json
{ "blueprint" : "cluster_blueprint", "repository_version_id": 1, # local repo 需要,否则删除。 "default_password" : "admin", "configurations" : [ ], "host_groups" :[ { "name" : "host_group_1", "hosts" : [ { "fqdn" : "roy-vm-hdp-1" } ] }, { "name" : "host_group_2", "hosts" : [ { "fqdn" : "roy-vm-hdp-2" } ] }, { "name" : "host_group_3", "hosts" : [ { "fqdn" : "roy-vm-hdp-3" } ] } ] }
-
Step 4: Create Cluster (让ambari安装hdp组件)
POST /api/v1/clusters/:clusterName
e.g.
$ curl -H "X-Requested-By: ambari" -X POST -u admin:admin \ > http://localhost:8080/api/v1/clusters/roycluster -d@/tmp/hostmapping-3.json
hostmap告诉它用哪一个blueprint。
-
Step 5: Monitor Cluster Creation Progress
GET /api/v1/clusters/:clusterName/requests/1
e.g.
$ curl -H "X-Requested-By: ambari" --user admin:admin \ > -X GET http://localhost:8080/api/v1/clusters/EEACLUSTER/requsts/1 | more % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 19305 100 19305 0 0 417k 0 --:--:-- --:--:-- --:--:-- 418k { "href" : "http://localhost:8080/api/v1/clusters/EEACLUSTER/requests/1";, "Requests" : { "aborted_task_count" : 0, "cluster_name" : "EEACLUSTER", "completed_task_count" : 75, "create_time" : 1518333235226, "end_time" : -1, "exclusive" : false, "failed_task_count" : 0, "id" : 1, "inputs" : null, "operation_level" : null, "progress_percent" : 100.0, "queued_task_count" : 0, "request_context" : "Logical Request: Provision Cluster 'EEACLUSTER'", "request_schedule" : null, "request_status" : "COMPLETED", "resource_filters" : null, "start_time" : -1, "task_count" : 75, "timed_out_task_count" : 0, "type" : null }, ...
参考文档:
https://cwiki.apache.org/confluence/display/AMBARI/Blueprints