使用Cloudera Manager模板创建CDH群集
您可以通过从Cloudera Manager管理的现有CDH群集导出群集模板来创建新的CDH群集。然后,您可以修改模板并使用它在新的主机集上创建具有相同配置的新集群。使用群集模板:
- 用于开发人员,测试和生产环境的重复群集。
- 快速为特定工作负载创建集群。
- 重现生产群集以进行测试和调试。
导出群集配置
要创建群集模板,首先要从源群集导出配置。群集必须由Cloudera Manager 5.7或更高版本运行和管理。
要导出配置:
- 您创建的任何主机模板都用于导出配置。如果您不想在新群集中使用这些模板,请将其删除。在Cloudera Manager中,转到“ 主机” >“ 主机模板”,然后单击要 删除的主机模板旁边的“删除”。
- 删除Cloudera Manager安装向导创建的所有主机模板。他们通常有一个名字模板 - 1)。
- 运行以下命令将JSON配置文件下载到方便的位置进行编辑:
curl -u :
“http:// / api / v12 / clusters / / export”>
/ .json例如:
curl -u adminuser:adminpass“http://myCluster-1.myDomain.com:7180/api/v12/clusters/Cluster1/export”> myCluster1-template.json
注意:添加?exportAutoConfig = TRUE上述命令的参数,包括自动配置所做的配置。这些配置仅供参考,在将模板导入新群集时不会使用。例如:
curl -u :
“http:// / api / v12 / clusters / / export”>
/ .json?exportAutoConfig = true
准备新群集
导入群集模板的新群集必须满足以下要求:
- 已安装并配置Cloudera Manager数据库。
- 已安装并运行Cloudera Manager 5.7或更高版本。
- 安装了所有必需的CDH服务数据库。请参阅步骤4:安装和配置数据库。
- JDK安装在所有群集主机上。
- Cloudera Manager Agent已在所有群集主机上安装和配置。
- 如果源群集使用Kerberos,则新群集必须具有在Cloudera Manager中配置的KDC属性和权限。
- 如果源群集使用程序包来安装CDH和托管服务,请在导入模板之前手动安装这些程序包。请参阅使用Cloudera Manager管理软件安装。
创建模板
要创建模板,请修改 实例化您下载的JSON文件的一部分。包含字符串的行<changeme>需要一个你必须提供的值。这是一个样本实例化 部分:
"instantiator" : {
"clusterName" : "<changeme>",
"hosts" : [ {
"hostName" : "<changeme>",
"hostTemplateRefName" : "<changeme>",
"roleRefNames" : [ "HDFS-1-NAMENODE-0be88b55f5dedbf7bc74d61a86c0253e" ]
}, {
"hostName" : "<changeme>",
"hostTemplateRefName" : "<changeme>"
}, {
"hostNameRange" : "<HOST[0001-0002]>",
"hostTemplateRefName" : "<changeme>"
} ],
"variables" : [ {
"name" : "HDFS-1-NAMENODE-BASE-dfs_name_dir_list",
"value" : "/dfs/nn"
}, {
"name" : "HDFS-1-SECONDARYNAMENODE-BASE-fs_checkpoint_dir_list",
"value" : "/dfs/snn"
}, {
"name" : "HIVE-1-hive_metastore_database_host",
"value" : "myCluster-1.myDomain.com"
}, {
"name" : "HIVE-1-hive_metastore_database_name",
"value" : "hive1"
}, {
"name" : "HIVE-1-hive_metastore_database_password",
"value" : "<changeme>"
}, {
"name" : "HIVE-1-hive_metastore_database_port",
"value" : "3306"
}, {
"name" : "HIVE-1-hive_metastore_database_type",
"value" : "mysql"
}, {
"name" : "HIVE-1-hive_metastore_database_user",
"value" : "hive1"
}, {
"name" : "HUE-1-database_host",
"value" : "myCluster-1.myDomain.com"
}, {
"name" : "HUE-1-database_name",
"value" : "hueserver0be88b55f5dedbf7bc74d61a86c0253e"
}, {
"name" : "HUE-1-database_password",
"value" : "<changeme>"
}, {
"name" : "HUE-1-database_port",
"value" : "3306"
}, {
"name" : "HUE-1-database_type",
"value" : "mysql"
}, {
"name" : "HUE-1-database_user",
"value" : "hueserver0be88b5"
}, {
"name" : "IMPALA-1-IMPALAD-BASE-scratch_dirs",
"value" : "/impala/impalad"
}, {
"name" : "KUDU-1-KUDU_MASTER-BASE-fs_data_dirs",
"value" : "/var/lib/kudu/master"
}, {
"name" : "KUDU-1-KUDU_MASTER-BASE-fs_wal_dir",
"value" : "/var/lib/kudu/master"
}, {
"name" : "KUDU-1-KUDU_TSERVER-BASE-fs_data_dirs",
"value" : "/var/lib/kudu/tserver"
}, {
"name" : "KUDU-1-KUDU_TSERVER-BASE-fs_wal_dir",
"value" : "/var/lib/kudu/tserver"
}, {
"name" : "MAPREDUCE-1-JOBTRACKER-BASE-jobtracker_mapred_local_dir_list",
"value" : "/mapred/jt"
}, {
"name" : "MAPREDUCE-1-TASKTRACKER-BASE-tasktracker_mapred_local_dir_list",
"value" : "/mapred/local"
}, {
"name" : "OOZIE-1-OOZIE_SERVER-BASE-oozie_database_host",
"value" : "myCluster-1.myDomain.com:3306"
}, {
"name" : "OOZIE-1-OOZIE_SERVER-BASE-oozie_database_name",
"value" : "oozieserver0be88b55f5dedbf7bc74d61a86c0253e"
}, {
"name" : "OOZIE-1-OOZIE_SERVER-BASE-oozie_database_password",
"value" : "<changeme>"
}, {
"name" : "OOZIE-1-OOZIE_SERVER-BASE-oozie_database_type",
"value" : "mysql"
}, {
"name" : "OOZIE-1-OOZIE_SERVER-BASE-oozie_database_user",
"value" : "oozieserver0be88"
}, {
"name" : "YARN-1-NODEMANAGER-BASE-yarn_nodemanager_local_dirs",
"value" : "/yarn/nm"
}, {
"name" : "YARN-1-NODEMANAGER-BASE-yarn_nodemanager_log_dirs",
"value" : "/yarn/container-logs"
} ]
}
"clusterName" : "<changeme>",
"hosts" : [ {
"hostName" : "<changeme>",
"hostTemplateRefName" : "<changeme>",
"roleRefNames" : [ "HDFS-1-NAMENODE-0be88b55f5dedbf7bc74d61a86c0253e" ]
}, {
"hostName" : "<changeme>",
"hostTemplateRefName" : "<changeme>"
}, {
"hostNameRange" : "<HOST[0001-0002]>",
"hostTemplateRefName" : "<changeme>"
} ],
"variables" : [ {
"name" : "HDFS-1-NAMENODE-BASE-dfs_name_dir_list",
"value" : "/dfs/nn"
}, {
"name" : "HDFS-1-SECONDARYNAMENODE-BASE-fs_checkpoint_dir_list",
"value" : "/dfs/snn"
}, {
"name" : "HIVE-1-hive_metastore_database_host",
"value" : "myCluster-1.myDomain.com"
}, {
"name" : "HIVE-1-hive_metastore_database_name",
"value" : "hive1"
}, {
"name" : "HIVE-1-hive_metastore_database_password",
"value" : "<changeme>"
}, {
"name" : "HIVE-1-hive_metastore_database_port",
"value" : "3306"
}, {
"name" : "HIVE-1-hive_metastore_database_type",
"value" : "mysql"
}, {
"name" : "HIVE-1-hive_metastore_database_user",
"value" : "hive1"
}, {
"name" : "HUE-1-database_host",
"value" : "myCluster-1.myDomain.com"
}, {
"name" : "HUE-1-database_name",
"value" : "hueserver0be88b55f5dedbf7bc74d61a86c0253e"
}, {
"name" : "HUE-1-database_password",
"value" : "<changeme>"
}, {
"name" : "HUE-1-database_port",
"value" : "3306"
}, {
"name" : "HUE-1-database_type",
"value" : "mysql"
}, {
"name" : "HUE-1-database_user",
"value" : "hueserver0be88b5"
}, {
"name" : "IMPALA-1-IMPALAD-BASE-scratch_dirs",
"value" : "/impala/impalad"
}, {
"name" : "KUDU-1-KUDU_MASTER-BASE-fs_data_dirs",
"value" : "/var/lib/kudu/master"
}, {
"name" : "KUDU-1-KUDU_MASTER-BASE-fs_wal_dir",
"value" : "/var/lib/kudu/master"
}, {
"name" : "KUDU-1-KUDU_TSERVER-BASE-fs_data_dirs",
"value" : "/var/lib/kudu/tserver"
}, {
"name" : "KUDU-1-KUDU_TSERVER-BASE-fs_wal_dir",
"value" : "/var/lib/kudu/tserver"
}, {
"name" : "MAPREDUCE-1-JOBTRACKER-BASE-jobtracker_mapred_local_dir_list",
"value" : "/mapred/jt"
}, {
"name" : "MAPREDUCE-1-TASKTRACKER-BASE-tasktracker_mapred_local_dir_list",
"value" : "/mapred/local"
}, {
"name" : "OOZIE-1-OOZIE_SERVER-BASE-oozie_database_host",
"value" : "myCluster-1.myDomain.com:3306"
}, {
"name" : "OOZIE-1-OOZIE_SERVER-BASE-oozie_database_name",
"value" : "oozieserver0be88b55f5dedbf7bc74d61a86c0253e"
}, {
"name" : "OOZIE-1-OOZIE_SERVER-BASE-oozie_database_password",
"value" : "<changeme>"
}, {
"name" : "OOZIE-1-OOZIE_SERVER-BASE-oozie_database_type",
"value" : "mysql"
}, {
"name" : "OOZIE-1-OOZIE_SERVER-BASE-oozie_database_user",
"value" : "oozieserver0be88"
}, {
"name" : "YARN-1-NODEMANAGER-BASE-yarn_nodemanager_local_dirs",
"value" : "/yarn/nm"
}, {
"name" : "YARN-1-NODEMANAGER-BASE-yarn_nodemanager_log_dirs",
"value" : "/yarn/container-logs"
} ]
}
要修改模板:
- 更新 hosts 部分。如果您在源群集中定义了主机模板,它们将显示在 hostTemplatesJSON模板的一部分。对于不使用主机模板的主机,导出过程会根据角色分配创建主机模板,以便于创建新群集。在任何一种情况下,您必须匹配中的项目hostTemplates 部分与 hosts 中的部分 instantiator 部分。这是一个样本 hostTemplates 来自与JSON文件相同的部分 instantiator 部分,上面:
"hostTemplates" : [ {
"refName" : "HostTemplate-0-from-myCluster-1.myDomain.com",
"cardinality" : 1,
"roleConfigGroupsRefNames" : [ "FLUME-1-AGENT-BASE", "HBASE-1-GATEWAY-BASE", "HBASE-1-HBASETHRIFTSERVER-BASE", "HBASE-1-MASTER-BASE", "HDFS-1-BALANCER-BASE", "HDFS-1-GATEWAY-BASE", "HDFS-1-NAMENODE-BASE", "HDFS-1-NFSGATEWAY-BASE", "HDFS-1-SECONDARYNAMENODE-BASE", "HIVE-1-GATEWAY-BASE", "HIVE-1-HIVEMETASTORE-BASE", "HIVE-1-HIVESERVER2-BASE", "HUE-1-HUE_LOAD_BALANCER-BASE", "HUE-1-HUE_SERVER-BASE", "IMPALA-1-CATALOGSERVER-BASE", "IMPALA-1-STATESTORE-BASE", "KAFKA-1-KAFKA_BROKER-BASE", "KS_INDEXER-1-HBASE_INDEXER-BASE", "KUDU-1-KUDU_MASTER-BASE", "MAPREDUCE-1-GATEWAY-BASE", "MAPREDUCE-1-JOBTRACKER-BASE", "OOZIE-1-OOZIE_SERVER-BASE", "SOLR-1-SOLR_SERVER-BASE", "SPARK_ON_YARN-1-GATEWAY-BASE", "SPARK_ON_YARN-1-SPARK_YARN_HISTORY_SERVER-BASE", "SQOOP-1-SQOOP_SERVER-BASE", "SQOOP_CLIENT-1-GATEWAY-BASE", "YARN-1-GATEWAY-BASE", "YARN-1-JOBHISTORY-BASE", "YARN-1-RESOURCEMANAGER-BASE", "ZOOKEEPER-1-SERVER-BASE" ]
}, {
"refName" : "HostTemplate-1-from-myCluster-4.myDomain.com",
"cardinality" : 1,
"roleConfigGroupsRefNames" : [ "FLUME-1-AGENT-BASE", "HBASE-1-REGIONSERVER-BASE", "HDFS-1-DATANODE-BASE", "HIVE-1-GATEWAY-BASE", "IMPALA-1-IMPALAD-BASE", "KUDU-1-KUDU_TSERVER-BASE", "MAPREDUCE-1-TASKTRACKER-BASE", "SPARK_ON_YARN-1-GATEWAY-BASE", "SQOOP_CLIENT-1-GATEWAY-BASE", "YARN-1-NODEMANAGER-BASE" ]
}, {
"refName" : "HostTemplate-2-from-myCluster-[2-3].myDomain.com",
"cardinality" : 2,
"roleConfigGroupsRefNames" : [ "FLUME-1-AGENT-BASE", "HBASE-1-REGIONSERVER-BASE", "HDFS-1-DATANODE-BASE", "HIVE-1-GATEWAY-BASE", "IMPALA-1-IMPALAD-BASE", "KAFKA-1-KAFKA_BROKER-BASE", "KUDU-1-KUDU_TSERVER-BASE", "MAPREDUCE-1-TASKTRACKER-BASE", "SPARK_ON_YARN-1-GATEWAY-BASE", "SQOOP_CLIENT-1-GATEWAY-BASE", "YARN-1-NODEMANAGER-BASE" ]
} ]
"refName" : "HostTemplate-0-from-myCluster-1.myDomain.com",
"cardinality" : 1,
"roleConfigGroupsRefNames" : [ "FLUME-1-AGENT-BASE", "HBASE-1-GATEWAY-BASE", "HBASE-1-HBASETHRIFTSERVER-BASE", "HBASE-1-MASTER-BASE", "HDFS-1-BALANCER-BASE", "HDFS-1-GATEWAY-BASE", "HDFS-1-NAMENODE-BASE", "HDFS-1-NFSGATEWAY-BASE", "HDFS-1-SECONDARYNAMENODE-BASE", "HIVE-1-GATEWAY-BASE", "HIVE-1-HIVEMETASTORE-BASE", "HIVE-1-HIVESERVER2-BASE", "HUE-1-HUE_LOAD_BALANCER-BASE", "HUE-1-HUE_SERVER-BASE", "IMPALA-1-CATALOGSERVER-BASE", "IMPALA-1-STATESTORE-BASE", "KAFKA-1-KAFKA_BROKER-BASE", "KS_INDEXER-1-HBASE_INDEXER-BASE", "KUDU-1-KUDU_MASTER-BASE", "MAPREDUCE-1-GATEWAY-BASE", "MAPREDUCE-1-JOBTRACKER-BASE", "OOZIE-1-OOZIE_SERVER-BASE", "SOLR-1-SOLR_SERVER-BASE", "SPARK_ON_YARN-1-GATEWAY-BASE", "SPARK_ON_YARN-1-SPARK_YARN_HISTORY_SERVER-BASE", "SQOOP-1-SQOOP_SERVER-BASE", "SQOOP_CLIENT-1-GATEWAY-BASE", "YARN-1-GATEWAY-BASE", "YARN-1-JOBHISTORY-BASE", "YARN-1-RESOURCEMANAGER-BASE", "ZOOKEEPER-1-SERVER-BASE" ]
}, {
"refName" : "HostTemplate-1-from-myCluster-4.myDomain.com",
"cardinality" : 1,
"roleConfigGroupsRefNames" : [ "FLUME-1-AGENT-BASE", "HBASE-1-REGIONSERVER-BASE", "HDFS-1-DATANODE-BASE", "HIVE-1-GATEWAY-BASE", "IMPALA-1-IMPALAD-BASE", "KUDU-1-KUDU_TSERVER-BASE", "MAPREDUCE-1-TASKTRACKER-BASE", "SPARK_ON_YARN-1-GATEWAY-BASE", "SQOOP_CLIENT-1-GATEWAY-BASE", "YARN-1-NODEMANAGER-BASE" ]
}, {
"refName" : "HostTemplate-2-from-myCluster-[2-3].myDomain.com",
"cardinality" : 2,
"roleConfigGroupsRefNames" : [ "FLUME-1-AGENT-BASE", "HBASE-1-REGIONSERVER-BASE", "HDFS-1-DATANODE-BASE", "HIVE-1-GATEWAY-BASE", "IMPALA-1-IMPALAD-BASE", "KAFKA-1-KAFKA_BROKER-BASE", "KUDU-1-KUDU_TSERVER-BASE", "MAPREDUCE-1-TASKTRACKER-BASE", "SPARK_ON_YARN-1-GATEWAY-BASE", "SQOOP_CLIENT-1-GATEWAY-BASE", "YARN-1-NODEMANAGER-BASE" ]
} ]
的价值 cardinality 表示为源群集中的主机模板分配了多少主机。
的价值 roleConfigGroupsRefNames 指示将哪些角色组分配给主机。
对于每个主机模板执行以下操作 hostTemplates 部分:
- 找到中的条目 hosts 部分 instantiator 您希望安装角色的位置。
- 复制的值 refName 为了价值 hostTemplateRefName。
- 在新集群中输入主机名作为值 主机名。某些主机部分可能会改为使用hostNameRange对于具有多个具有相同角色集的主机的群集。使用以下方法之一指示一系列主机:
- 括号; 例如, myhost[1-4].foo.com
- 逗号分隔的主机名字符串; 例如,host-1.domain,host-2.domain,host-3.domain
这是一个例子 hostTemplates 和 hosts 部分 instantiator 正确完成:
"hostTemplates" : [ {
"refName" : "HostTemplate-0-from-myCluster-1.myDomain.com",
"cardinality" : 1,
"roleConfigGroupsRefNames" : [ "FLUME-1-AGENT-BASE", "HBASE-1-GATEWAY-BASE", "HBASE-1-HBASETHRIFTSERVER-BASE", "HBASE-1-MASTER-BASE", "HDFS-1-BALANCER-BASE", "HDFS-1-GATEWAY-BASE", "HDFS-1-NAMENODE-BASE", "HDFS-1-NFSGATEWAY-BASE", "HDFS-1-SECONDARYNAMENODE-BASE", "HIVE-1-GATEWAY-BASE", "HIVE-1-HIVEMETASTORE-BASE", "HIVE-1-HIVESERVER2-BASE", "HUE-1-HUE_LOAD_BALANCER-BASE", "HUE-1-HUE_SERVER-BASE", "IMPALA-1-CATALOGSERVER-BASE", "IMPALA-1-STATESTORE-BASE", "KAFKA-1-KAFKA_BROKER-BASE", "KS_INDEXER-1-HBASE_INDEXER-BASE", "KUDU-1-KUDU_MASTER-BASE", "MAPREDUCE-1-GATEWAY-BASE", "MAPREDUCE-1-JOBTRACKER-BASE", "OOZIE-1-OOZIE_SERVER-BASE", "SOLR-1-SOLR_SERVER-BASE", "SPARK_ON_YARN-1-GATEWAY-BASE", "SPARK_ON_YARN-1-SPARK_YARN_HISTORY_SERVER-BASE", "SQOOP-1-SQOOP_SERVER-BASE", "SQOOP_CLIENT-1-GATEWAY-BASE", "YARN-1-GATEWAY-BASE", "YARN-1-JOBHISTORY-BASE", "YARN-1-RESOURCEMANAGER-BASE", "ZOOKEEPER-1-SERVER-BASE" ]
}, {
"refName" : "HostTemplate-1-from-myCluster-4.myDomain.com",
"cardinality" : 1,
"roleConfigGroupsRefNames" : [ "FLUME-1-AGENT-BASE", "HBASE-1-REGIONSERVER-BASE", "HDFS-1-DATANODE-BASE", "HIVE-1-GATEWAY-BASE", "IMPALA-1-IMPALAD-BASE", "KUDU-1-KUDU_TSERVER-BASE", "MAPREDUCE-1-TASKTRACKER-BASE", "SPARK_ON_YARN-1-GATEWAY-BASE", "SQOOP_CLIENT-1-GATEWAY-BASE", "YARN-1-NODEMANAGER-BASE" ]
}, {
"refName" : "HostTemplate-2-from-myCluster-[2-3].myDomain.com",
"cardinality" : 2,
"roleConfigGroupsRefNames" : [ "FLUME-1-AGENT-BASE", "HBASE-1-REGIONSERVER-BASE", "HDFS-1-DATANODE-BASE", "HIVE-1-GATEWAY-BASE", "IMPALA-1-IMPALAD-BASE", "KAFKA-1-KAFKA_BROKER-BASE", "KUDU-1-KUDU_TSERVER-BASE", "MAPREDUCE-1-TASKTRACKER-BASE", "SPARK_ON_YARN-1-GATEWAY-BASE", "SQOOP_CLIENT-1-GATEWAY-BASE", "YARN-1-NODEMANAGER-BASE" ]
} ],
"instantiator" : {
"clusterName" : "myCluster_new",
"hosts" : [ {
"hostName" : "myNewCluster-1.myDomain.com",
"hostTemplateRefName" : "HostTemplate-0-from-myCluster-1.myDomain.com",
"roleRefNames" : [ "HDFS-1-NAMENODE-c975a0b51fd36e914896cd5e0adb1b5b" ]
}, {
"hostName" : "myNewCluster-5.myDomain.com",
"hostTemplateRefName" : "HostTemplate-1-from-myCluster-4.myDomain.com"
}, {
"hostNameRange" : "myNewCluster-[3-4].myDomain.com",
"hostTemplateRefName" : "HostTemplate-2-from-myCluster-[2-3].myDomain.com"
} ],
"refName" : "HostTemplate-0-from-myCluster-1.myDomain.com",
"cardinality" : 1,
"roleConfigGroupsRefNames" : [ "FLUME-1-AGENT-BASE", "HBASE-1-GATEWAY-BASE", "HBASE-1-HBASETHRIFTSERVER-BASE", "HBASE-1-MASTER-BASE", "HDFS-1-BALANCER-BASE", "HDFS-1-GATEWAY-BASE", "HDFS-1-NAMENODE-BASE", "HDFS-1-NFSGATEWAY-BASE", "HDFS-1-SECONDARYNAMENODE-BASE", "HIVE-1-GATEWAY-BASE", "HIVE-1-HIVEMETASTORE-BASE", "HIVE-1-HIVESERVER2-BASE", "HUE-1-HUE_LOAD_BALANCER-BASE", "HUE-1-HUE_SERVER-BASE", "IMPALA-1-CATALOGSERVER-BASE", "IMPALA-1-STATESTORE-BASE", "KAFKA-1-KAFKA_BROKER-BASE", "KS_INDEXER-1-HBASE_INDEXER-BASE", "KUDU-1-KUDU_MASTER-BASE", "MAPREDUCE-1-GATEWAY-BASE", "MAPREDUCE-1-JOBTRACKER-BASE", "OOZIE-1-OOZIE_SERVER-BASE", "SOLR-1-SOLR_SERVER-BASE", "SPARK_ON_YARN-1-GATEWAY-BASE", "SPARK_ON_YARN-1-SPARK_YARN_HISTORY_SERVER-BASE", "SQOOP-1-SQOOP_SERVER-BASE", "SQOOP_CLIENT-1-GATEWAY-BASE", "YARN-1-GATEWAY-BASE", "YARN-1-JOBHISTORY-BASE", "YARN-1-RESOURCEMANAGER-BASE", "ZOOKEEPER-1-SERVER-BASE" ]
}, {
"refName" : "HostTemplate-1-from-myCluster-4.myDomain.com",
"cardinality" : 1,
"roleConfigGroupsRefNames" : [ "FLUME-1-AGENT-BASE", "HBASE-1-REGIONSERVER-BASE", "HDFS-1-DATANODE-BASE", "HIVE-1-GATEWAY-BASE", "IMPALA-1-IMPALAD-BASE", "KUDU-1-KUDU_TSERVER-BASE", "MAPREDUCE-1-TASKTRACKER-BASE", "SPARK_ON_YARN-1-GATEWAY-BASE", "SQOOP_CLIENT-1-GATEWAY-BASE", "YARN-1-NODEMANAGER-BASE" ]
}, {
"refName" : "HostTemplate-2-from-myCluster-[2-3].myDomain.com",
"cardinality" : 2,
"roleConfigGroupsRefNames" : [ "FLUME-1-AGENT-BASE", "HBASE-1-REGIONSERVER-BASE", "HDFS-1-DATANODE-BASE", "HIVE-1-GATEWAY-BASE", "IMPALA-1-IMPALAD-BASE", "KAFKA-1-KAFKA_BROKER-BASE", "KUDU-1-KUDU_TSERVER-BASE", "MAPREDUCE-1-TASKTRACKER-BASE", "SPARK_ON_YARN-1-GATEWAY-BASE", "SQOOP_CLIENT-1-GATEWAY-BASE", "YARN-1-NODEMANAGER-BASE" ]
} ],
"instantiator" : {
"clusterName" : "myCluster_new",
"hosts" : [ {
"hostName" : "myNewCluster-1.myDomain.com",
"hostTemplateRefName" : "HostTemplate-0-from-myCluster-1.myDomain.com",
"roleRefNames" : [ "HDFS-1-NAMENODE-c975a0b51fd36e914896cd5e0adb1b5b" ]
}, {
"hostName" : "myNewCluster-5.myDomain.com",
"hostTemplateRefName" : "HostTemplate-1-from-myCluster-4.myDomain.com"
}, {
"hostNameRange" : "myNewCluster-[3-4].myDomain.com",
"hostTemplateRefName" : "HostTemplate-2-from-myCluster-[2-3].myDomain.com"
} ],
2.对于具有。的主机部分 roleRefNamesline,确定角色类型并为角色分配适当的主机。如果有多个角色实例,则必须选择正确的主机。要确定角色类型,请在模板文件中搜索值roleRefNames。
例如:对于名为的角色引用 HDFS-1的NameNode,0be88b55f5dedbf7bc74d61a86c0253e,如果搜索该字符串,则会找到类似于以下内容的部分:
"roles": [
{
"refName": "HDFS-1-NAMENODE-0be88b55f5dedbf7bc74d61a86c0253e",
"roleType": "NAMENODE"
}
]
{
"refName": "HDFS-1-NAMENODE-0be88b55f5dedbf7bc74d61a86c0253e",
"roleType": "NAMENODE"
}
]
在这种情况下,角色类型是 的NameNode。
3. 修改variables 部分。此部分包含源群集中的各种属性。您可以在新群集中将这些值中的任何值更改为不同,也可以将值保留为从源复制的值。对于显示为的任何值<changeme>,您必须提供正确的值。注意:其中许多变量包含有关Hive Metastore和其他CDH组件使用的数据库的信息。更改这些变量的值以匹配为新群集配置的数据库。
4. 在行上输入新群集的内部名称 “clusterName”:“<changeme>”。例如:
"clusterName" : "QE_test_cluster"
- (可选)更改群集的显示名称。编辑以。开头的行“显示名称”(靠近JSON文件的顶部); 例如:
“displayName”:“myNewCluster”,
将模板导入新群集
要导入群集模板:
- 以root身份登录Cloudera Manager服务器。
- 运行以下命令以导入模板。如果在源群集中配置了远程存储库URL,请附加命令 ?addRepositories=true。
curl -X POST -H "Content-Type: application/json" -d
@/.json
http://:@:/api/v12/cm/importClusterTemplate
@/.json
http://:@:/api/v12/cm/importClusterTemplate
You should see a response similar to the following:
{
"id" : 17,
"name" : "ClusterTemplateImport",
"startTime" : "2016-03-09T23:44:38.491Z",
"active" : true,
"children" : {
"items" : [ ]
}
Examples:
curl -X POST -H "Content-Type: application/json" -d @myTemplate.json http://admin:[email protected]:7182/api/v12/cm/importClusterTemplate
curl -X POST -H "Content-Type: application/json" -d @myTemplate.json http://admin:[email protected]:7182/api/v12/cm/importClusterTemplate?addRepositories=true
If there is no response, or you receive an error message, the JSON file may be malformed, or the template may have invalid hostnames or invalid references. Inspect the JSON file, correct any errors, and then re-run the command.
- 在Web浏览器中打开新群集的Cloudera Manager,然后单击Cloudera Manager徽标转到主页。
- 单击“ 所有最近的命令”选项卡。
如果导入正在进行,您应该看到标记为“ 导入群集模板”的链接。单击链接以查看导入的进度。
如果任何命令失败,请更正问题并单击“ 重试”。您可能需要在Cloudera Manager中编辑一些属性。
导入模板后,Cloudera Manager将应用自动配置规则,为各种角色设置内存和CPU分配等属性。如果新群集具有不同的硬件或操作要求,则可能需要修改这些值。
示例Python代码
您可以使用以Python或其他语言编写的客户端以编程方式执行导出和导入集群模板的步骤。(你也可以使用卷曲 上面提供的命令。)
Python导出示例:
resource = ApiResource(“myCluster-1.myDomain.com”,7180,“admin”,“admin”,version = 12)
cluster = resource.get_cluster(“Cluster1”);
template = cluster.export(False)
pprint(template)
Python导入示例:
resource = ApiResource(“localhost”,8180,“admin”,“admin”,version = 12)
,打开('〜/ cluster-template.json')作为data_file:
data = json.load(data_file)
template = ApiClusterTemplate(资源).from_json_dict(data,resource)
cms = ClouderaManager(资源)
cms.import_cluster_template(模板)
,打开('〜/ cluster-template.json')作为data_file:
data = json.load(data_file)
template = ApiClusterTemplate(资源).from_json_dict(data,resource)
cms = ClouderaManager(资源)
cms.import_cluster_template(模板)