思維導(dǎo)圖
是什么
Ambari Blueprints 是用來(lái)自動(dòng)化安裝hdp組件的配置文件侧馅,它告訴ambari:要安裝什么service/component爸吮,安裝在哪里剥险。
它通過(guò)REST API與ambari交互纺涤,上傳和更新配置五垮。
前提
Ambari server/agent已經(jīng)安裝完成
步驟
-
Step 1: 手工寫(xiě)或者下載現(xiàn)有hdp系統(tǒng)的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 下載下來(lái),如此就獲取了一個(gè)真實(shí)的配置文件抑党,可以在這個(gè)文件的基礎(chǔ)上做修改包警。
下面就是這個(gè)配置文件的簡(jiǎn)化版,介紹它的框架結(jié)構(gòu)底靠。
Blueprint Structure
{
"configurations" : [
### 定義hdp里面各個(gè)組件的配置害晦,也可以不寫(xiě),使用默認(rèn)配置暑中。
],
"host_groups" : [
{
"configurations" : [ ],
"components" : [
{ "name": "NODEMANAGER" },
{ "name": "DATANODE" },
{ "name" : "METRICS_MONITOR" }
],
"name" : "slavenode",
"cardinality" : "5"
},
{
### 定義哪個(gè)host group 安裝什么component壹瘟。
} ...
],
"settings" : [
### 其它設(shè)置,比如component自啟動(dòng)鳄逾〉竟欤可以不寫(xiě)。
],
"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
這個(gè)blueprint文件就是上一步生成的mybl.json
-
Step 3: Create Cluster Template
把 host 和 blueprint file 中的 host_group 對(duì)應(yīng)起來(lái)雕凹。
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告訴它用哪一個(gè)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