blueprint通过API方式实现集群的部署, 相较于可视化部署, 可以轻松实现静默安装, 进一步简化部署步骤
2 创建BlueprintAmbari Blueprints provide an API to perform cluster installations.
You can build a reusable “blueprint” that defines which Stack to use, how Service Components should be laid out across a cluster and what configurations to set.
blueprint定义主机组host_group_1, 组内又定义了一系列基础组件 (zookeeper, hdfs, yarn)
组件要安装到哪台服务器呢, 所以还需要主机组与主机的映射关系, 见第4节
新建文件: cluster.json
{
"Blueprints": {
"blueprint_name": "N1-hdp26",
"stack_name": "HDP",
"stack_version": "2.6"
},
"configurations": [],
"host_groups": [
{
"name": "host_group_1",
"components": [
{
"name": "NAMENODE"
},
{
"name": "SECONDARY_NAMENODE"
},
{
"name": "DATANODE"
},
{
"name": "HDFS_CLIENT"
},
{
"name": "RESOURCEMANAGER"
},
{
"name": "NODEMANAGER"
},
{
"name": "YARN_CLIENT"
},
{
"name": "HISTORYSERVER"
},
{
"name": "APP_TIMELINE_SERVER"
},
{
"name": "MAPREDUCE2_CLIENT"
},
{
"name": "ZOOKEEPER_SERVER"
},
{
"name": "ZOOKEEPER_CLIENT"
}
],
"cardinality": "1"
}
]
}
3 注册Blueprint
curl -H "X-Requested-By: ambari" -X POST -u admin:admin http://:8080/api/v1/blueprints/?validate_topology=false -d @cluster.json
validate_topology=false, 表示不校验集群拓扑, 规避单节点限制
注册成功后, 通过http://:8080/api/v1/blueprints/查看注册结果
4 创建主机组映射第2节创建了主机组host_group_1, 这里定义host_group_1组对应的主机h199
因为是单节点部署, 所以只有1个节点
新建文件: hostmapping.json
- blueprint名称与注册的blueprint_name一致
{
"blueprint" : "N1-hdp26",
"host_groups" :[
{
"name" : "host_group_1",
"hosts" : [
{
"fqdn" : "h199"
}
]
}
]
}
5 修改HDP源
修改repo文件 /var/lib/ambari-server/resources/stacks/HDP/2.6/repos/repoinfo.xml, 安装时直接走本地yum源, 修改后重启ambari-server
- 因为blueprint指定stack_version=2.6, 所以只需要修改2.6的源文件
- 由于我使用的操作系统为centos7, 选择os=redhat7的配置进行修改
6 创建集群http://<本地yum源地址>/HDP/centos7/2.6.4.0-91 HDP-2.6 HDP true http://<本地yum源地址>/HDP-UTILS/centos7/1.1.0.22 HDP-UTILS-1.1.0.21 HDP-UTILS false
curl -H "X-Requested-By: ambari" -X POST -u admin:admin http://:8080/api/v1/clusters/<集群名> -d @hostmapping.json
登录ambari UI, 可以观察安装过程



