LoginSignup
4
4

More than 5 years have passed since last update.

HDPをAmbari + blueprintでインストール

Last updated at Posted at 2016-06-24

HORTONWORKS DATA PLATFORM(HDP™)をApache Ambari + Blueprintで!

AmbariにはBlueprintという、事前にjsonで定義された情報(Blueprint)に基づいてHDP Clusterをセットアップする機能があります。これをやってみたいと思います。
基本的には、AmbariのAPIですべて行っていく形ですが、APIをコールするのも面倒なので、今回はAmbari Shell(AmabariのClientの一つで、WebUIとほぼ同じ事が出来ます。)を利用してみたいと思います。

前準備

AmabriでBlueprintを使ったCluster構築を行うためには、以下の条件がそろっている必要があります。

  • Ambari Server構築済み
  • Clusterメンバーの各ホストへAmbari Agentがインストールされていて、Amabri Serverが各Hostを認識している。

といことで、Ambari Serverを先ずは構築してください。前回の記事が参考になるでしょう。

こちらの記事の「Ambari Serverの起動」まで行うイメージです。
前回の記事ではOracle JDKを使いましたが、面倒だったのでOpenJDKの1.8.0を利用しました。(yum install java-1.8.0-openjdk-develで行ける。)
それ以外は、基本的に同じで「IDCF Cloud + CentOS 7.2 + Ambari 2.2.2.0」となります。

クラスターメンバーにする各ノードは下記を参照に手動で登録しておきます。

基本的には、yumのレポジトリの登録とambari-agentのインストールと設定と起動をやる感じです。

# yum -y update
# yum -y install java-1.8.0-openjdk-devel
# localectl set-locale LANG=en_US.UTF-8

# wget -nv http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.2.2.0/ambari.repo -O /etc/yum.repos.d/ambari.repo
# yum -y install ambari-agent
# sed -i -e 's/hostname=localhost/hostname=ambari-server_hostname/' /etc/ambari-agent/conf/ambari-agent.ini
# LANG=C ambari-agent start

ちなみに、私は最初にやった時にJAVAのインストールをすっかり忘れてしまい、プロセス起動に軒並み失敗すると言う間抜けな事をやりましたので、ご注意ください。(WebUIでのセットアップの場合、最初の段階で各ノードの互換性チェックが動いて、JAVA入ってないよ!とか教えてくれるけど、Blueprintではそんなのやってくれない。いや、もしかしたらできるかも。調べてみよう。)

Ambari Shell

Ambari APIを直接叩くのは面倒なので、今回はAmbari Shellを使います。

Ambari ShellはHowtonworkが買収したSequenceIQが出しています。SequenceIQのメインはCloudbreakと言うツールですが、今回は割愛。すでにHowtonworksのHDPのラインナップの一つになっています。興味がある人は調べてみても良いと思います。

Ambari Shellですが、自分でビルドしても良いですが、面倒なのでビルド済みを利用させてもらいましょう。
レポジトリにあるlatest-snap.shを実行することで、最新版ビルド済みバイナリーが取得できます。

# wget -nv https://raw.githubusercontent.com/sequenceiq/ambari-shell/master/latest-snap.sh
2016-06-23 17:44:04 URL:https://raw.githubusercontent.com/sequenceiq/ambari-shell/master/latest-snap.sh [603/603] -> "latest-snap.sh" [1]

# bash latest-snap.sh
latest jar version is 0.1.31 ...
downloading exetuable jar into /tmp/ambari-shell.jar ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 37.9M  100 37.9M    0     0  1289k      0  0:00:30  0:00:30 --:--:-- 4997k
To start ambari-shell type:
=========================================
java -jar /tmp/ambari-shell.jar
=========================================
# java -jar /tmp/ambari-shell.jar 

Ambari Shell: Interactive command line tool for managing Apache Ambari.

Usage:
  java -jar ambari-shell.jar                  : Starts Ambari Shell in interactive mode.
  java -jar ambari-shell.jar --cmdfile=<FILE> : Ambari Shell executes commands read from the file.

Options:
  --ambari.host=<HOSTNAME>       Hostname of the Ambari Server [default: localhost].
  --ambari.port=<PORT>           Port of the Ambari Server [default: 8080].
  --ambari.user=<USER>           Username of the Ambari admin [default: admin].
  --ambari.password=<PASSWORD>   Password of the Ambari admin [default: admin].

Note:
  At least one option is mandatory.
# java -jar /tmp/ambari-shell.jar --ambari.host=localhost
    _                _                   _  ____   _            _  _
   / \    _ __ ___  | |__    __ _  _ __ (_)/ ___| | |__    ___ | || |
  / _ \  | '_ ` _ \ | '_ \  / _` || '__|| |\___ \ | '_ \  / _ \| || |
 / ___ \ | | | | | || |_) || (_| || |   | | ___) || | | ||  __/| || |
/_/   \_\|_| |_| |_||_.__/  \__,_||_|   |_||____/ |_| |_| \___||_||_|

Welcome to Ambari Shell. For command and param completion press TAB, for assistance type 'hint'.
ambari-shell>

なお、Ambari Shellはhelpでヘルプを見る事ができます。

ambari-shell> help
* blueprint add - Add a new blueprint with either --url or --file
* blueprint defaults - Adds the default blueprints to Ambari
* blueprint list - Lists all known blueprints
* blueprint show - Shows the blueprint by its id
* cluster assign - Assign host to host group
* cluster autoAssign - Automatically assigns hosts to different host groups base on the provided strategy
* cluster build - Starts to build a cluster
* cluster create - Create a cluster based on current blueprint and assigned hosts
* cluster delete - Delete the cluster
* cluster preview - Shows the currently assigned hosts
* cluster reset - Clears the host - host group assignments
* configuration download - Downloads the desired configuration
* configuration modify - Modify the desired configuration
* configuration set - Sets the desired configuration
* configuration show - Prints the desired configuration
* debug off - Stops showing the URL of the API calls
* debug on - Shows the URL of the API calls
* exit - Exits the shell
* hello - Prints a simple elephant to the console
* help - List all commands usage
* hint - Shows some hints
* host components - Lists the components assigned to the selected host
* host focus - Sets the useHost to the specified host
* host list - Lists the available hosts
* quit - Exits the shell
* script - Parses the specified resource file and executes its commands
* services components - Lists all services with their components
* services list - Lists the available services
* services start - Starts a service/all the services
* services stop - Stops a service/all the running services
* tasks - Lists the Ambari tasks
* users changepassword - Change a user's password
* version - Displays shell version

ambari-shell> help blueprint
* blueprint add - Add a new blueprint with either --url or --file
* blueprint defaults - Adds the default blueprints to Ambari
* blueprint list - Lists all known blueprints
* blueprint show - Shows the blueprint by its id

ambari-shell> help blueprint add
Keyword:                   blueprint add
Description:               Add a new blueprint with either --url or --file
 Keyword:                  url
   Help:                   URL of the blueprint to download from
   Mandatory:              false
   Default if specified:   '__NULL__'
   Default if unspecified: '__NULL__'

 Keyword:                  file
   Help:                   File which contains the blueprint
   Mandatory:              false
   Default if specified:   '__NULL__'
   Default if unspecified: '__NULL__'

* blueprint add - Add a new blueprint with either --url or --file

あとは、こちらが参考になるでしょう。

Blueprintの準備

まずは、Blueprintを用意する必要があります。最初から自分でblueprintを作っても良いですが、まぁ最初なのでサンプルで行きましょう。SequenceIQがサンプルを用意してくれているので、今回はこれを使います。(なお、ambari-shellにもサンプルが付属して、ambari-shell上でblueprint defaultsと実行すると登録できるのですが、古いHDP用なのでやめておきましょう。)

なお、blueprintについては下記に詳細に記載されていますので、参照してください。自分でblueprintを作りたい強者はこちらです。

今回は、サンプルのhdp-small-defaultを使っていきたいと思います。

上記のBlueprintサンプルをblueprint addで登録します。

ambari-shell> blueprint add --url https://raw.githubusercontent.com/sequenceiq/cloudbreak/master/core/src/main/resources/defaults/blueprints/hdp-small-default.bp
Blueprint: 'hdp-small-default' has been added

ambari-shell> blueprint list
  BLUEPRINT              STACK
  ---------------------  -------
  hdp-small-default      HDP:2.4

Blueprintに従ってClusterセットアップ

それでは、さっそくBlueprintに従って、Clusterをセットアップしてみましょう。

何台必要?

ところで、このhdp-small-defaultのBlueprintは何台のサーバが必要なのでしょうか。

ambari-shell> blueprint show --id hdp-small-default
  HOSTGROUP            COMPONENT
  -------------------  -------------------
  host_group_master_1  NAMENODE
  host_group_master_1  YARN_CLIENT
  host_group_master_1  FALCON_SERVER
  host_group_master_1  OOZIE_CLIENT
  host_group_master_1  HISTORYSERVER
  host_group_master_1  METRICS_MONITOR
  host_group_master_1  TEZ_CLIENT
  host_group_master_1  MAPREDUCE2_CLIENT
  host_group_master_1  OOZIE_SERVER
  host_group_master_1  ZOOKEEPER_SERVER
  host_group_master_1  HDFS_CLIENT
  host_group_master_2  ZOOKEEPER_SERVER
  host_group_master_2  TEZ_CLIENT
  host_group_master_2  WEBHCAT_SERVER
  host_group_master_2  HIVE_CLIENT
  host_group_master_2  HIVE_METASTORE
  host_group_master_2  HDFS_CLIENT
  host_group_master_2  METRICS_MONITOR
  host_group_master_2  PIG
  host_group_master_2  HIVE_SERVER
  host_group_master_2  RESOURCEMANAGER
  host_group_master_2  YARN_CLIENT
  host_group_master_2  MYSQL_SERVER
  host_group_master_2  ZOOKEEPER_CLIENT
  host_group_master_2  MAPREDUCE2_CLIENT
  host_group_client_1  SQOOP
  host_group_client_1  ZOOKEEPER_CLIENT
  host_group_client_1  KNOX_GATEWAY
  host_group_client_1  TEZ_CLIENT
  host_group_client_1  OOZIE_CLIENT
  host_group_client_1  YARN_CLIENT
  host_group_client_1  METRICS_MONITOR
  host_group_client_1  HIVE_CLIENT
  host_group_client_1  FALCON_CLIENT
  host_group_client_1  PIG
  host_group_client_1  MAPREDUCE2_CLIENT
  host_group_client_1  HDFS_CLIENT
  host_group_client_1  HBASE_CLIENT
  host_group_client_1  METRICS_COLLECTOR
  host_group_client_1  HCAT
  host_group_client_1  SLIDER
  host_group_master_3  APP_TIMELINE_SERVER
  host_group_master_3  HBASE_MASTER
  host_group_master_3  HBASE_CLIENT
  host_group_master_3  YARN_CLIENT
  host_group_master_3  SECONDARY_NAMENODE
  host_group_master_3  TEZ_CLIENT
  host_group_master_3  MAPREDUCE2_CLIENT
  host_group_master_3  METRICS_MONITOR
  host_group_master_3  HDFS_CLIENT
  host_group_master_3  ZOOKEEPER_SERVER
  host_group_slave_1   HBASE_REGIONSERVER
  host_group_slave_1   METRICS_MONITOR
  host_group_slave_1   NODEMANAGER
  host_group_slave_1   DATANODE

ホストグループとして、
host_group_master_1,host_group_master_2,host_group_master_3,host_group_slave_1,host_group_client_1
なので、5台は必要そうです。smallって割には多い。。。しかもSlaveは1台か。まぁ、今回は5台のサーバを準備しました。Ambari Server入れると全部で6台ですね。前準備で説明した内容を忘れずに!

ビルドの宣言

まず、どのBlueprintを使って、Clusterを構築するかを宣言します。

ambari-shell> cluster build --blueprint hdp-small-default
  HOSTNAME                    STATE
  --------------------------  --------------------------
  hdp3.csdidcfcloud.internal  hdp3.csdidcfcloud.internal
  hdp4.csdidcfcloud.internal  hdp4.csdidcfcloud.internal
  hdp2.csdidcfcloud.internal  hdp2.csdidcfcloud.internal
  hdp5.csdidcfcloud.internal  hdp5.csdidcfcloud.internal
  hdp6.csdidcfcloud.internal  hdp6.csdidcfcloud.internal

  HOSTGROUP            COMPONENT
  -------------------  -------------------
  host_group_master_1  NAMENODE
  host_group_master_1  YARN_CLIENT
  host_group_master_1  FALCON_SERVER
  host_group_master_1  OOZIE_CLIENT
  host_group_master_1  HISTORYSERVER
  host_group_master_1  METRICS_MONITOR
  host_group_master_1  TEZ_CLIENT
  host_group_master_1  MAPREDUCE2_CLIENT
  host_group_master_1  OOZIE_SERVER
  host_group_master_1  ZOOKEEPER_SERVER
  host_group_master_1  HDFS_CLIENT
  host_group_master_2  ZOOKEEPER_SERVER
  host_group_master_2  TEZ_CLIENT
  host_group_master_2  WEBHCAT_SERVER
  host_group_master_2  HIVE_CLIENT
  host_group_master_2  HIVE_METASTORE
  host_group_master_2  HDFS_CLIENT
  host_group_master_2  METRICS_MONITOR
  host_group_master_2  PIG
  host_group_master_2  HIVE_SERVER
  host_group_master_2  RESOURCEMANAGER
  host_group_master_2  YARN_CLIENT
  host_group_master_2  MYSQL_SERVER
  host_group_master_2  ZOOKEEPER_CLIENT
  host_group_master_2  MAPREDUCE2_CLIENT
  host_group_client_1  SQOOP
  host_group_client_1  ZOOKEEPER_CLIENT
  host_group_client_1  KNOX_GATEWAY
  host_group_client_1  TEZ_CLIENT
  host_group_client_1  OOZIE_CLIENT
  host_group_client_1  YARN_CLIENT
  host_group_client_1  METRICS_MONITOR
  host_group_client_1  HIVE_CLIENT
  host_group_client_1  FALCON_CLIENT
  host_group_client_1  PIG
  host_group_client_1  MAPREDUCE2_CLIENT
  host_group_client_1  HDFS_CLIENT
  host_group_client_1  HBASE_CLIENT
  host_group_client_1  METRICS_COLLECTOR
  host_group_client_1  HCAT
  host_group_client_1  SLIDER
  host_group_master_3  APP_TIMELINE_SERVER
  host_group_master_3  HBASE_MASTER
  host_group_master_3  HBASE_CLIENT
  host_group_master_3  YARN_CLIENT
  host_group_master_3  SECONDARY_NAMENODE
  host_group_master_3  TEZ_CLIENT
  host_group_master_3  MAPREDUCE2_CLIENT
  host_group_master_3  METRICS_MONITOR
  host_group_master_3  HDFS_CLIENT
  host_group_master_3  ZOOKEEPER_SERVER
  host_group_slave_1   HBASE_REGIONSERVER
  host_group_slave_1   METRICS_MONITOR
  host_group_slave_1   NODEMANAGER
  host_group_slave_1   DATANODE

CLUSTER_BUILD:hdp-small-default>

ホスト(VM)とホストグループのマッピング

次に、ホスト(VM)とBlueprintのホストグループをマッピングします。

CLUSTER_BUILD:hdp-small-default> cluster assign --host hdp2.csdidcfcloud.internal --hostGroup host_group_master_1
hdp2.csdidcfcloud.internal has been added to host_group_master_1

CLUSTER_BUILD:hdp-small-default> cluster assign --host hdp3.csdidcfcloud.internal --hostGroup host_group_master_2
hdp3.csdidcfcloud.internal has been added to host_group_master_2

CLUSTER_BUILD:hdp-small-default> cluster assign --host hdp4.csdidcfcloud.internal --hostGroup host_group_master_3
hdp4.csdidcfcloud.internal has been added to host_group_master_3

CLUSTER_BUILD:hdp-small-default> cluster assign --host hdp5.csdidcfcloud.internal --hostGroup host_group_slave_1
hdp5.csdidcfcloud.internal has been added to host_group_slave_1

CLUSTER_BUILD:hdp-small-default> cluster assign --host hdp6.csdidcfcloud.internal --hostGroup host_group_client_1
hdp6.csdidcfcloud.internal has been added to host_group_client_1
CLUSTER_BUILD:hdp-small-default>

Ambari Shellにはcluster autoAssignと言ったオプションもあるのですが、slaveがどうのこうの(メモしてなかった)と言われて、できなかったです。また、autoAssign実行時にホストが足りない場合はAssigning hosts failed, cause: At least 5 host is requiredなどと表示されていました。親切ですね。

cluster previewで設定した情報を確認できます。

CLUSTER_BUILD:hdp-small-default> cluster preview
  HOSTGROUP            HOST
  -------------------  --------------------------
  host_group_master_1  hdp2.csdidcfcloud.internal
  host_group_master_2  hdp3.csdidcfcloud.internal
  host_group_client_1  hdp6.csdidcfcloud.internal
  host_group_master_3  hdp4.csdidcfcloud.internal
  host_group_slave_1   hdp5.csdidcfcloud.internal

Cluster Create!

ここまで揃ったら、後はcluster createするだけで自動的に構築してくれます。

CLUSTER_BUILD:hdp-small-default> cluster create
Successfully created the cluster

Ambari Shellの右上にInstallation: 15.78% =---------と進捗が表示されます。
また、tasksで各コンポーネントの状況確認が出来ます。WebUIにログインしても、同様に確認可能です。

CLUSTER:hdp-small-default> tasks
  TASK                         STATUS
  ---------------------------  -----------
  MYSQL_SERVER INSTALL         QUEUED
  KNOX_GATEWAY START           PENDING
  SECONDARY_NAMENODE INSTALL   QUEUED
  HBASE_MASTER START           PENDING
  FALCON_SERVER INSTALL        IN_PROGRESS
  TEZ_CLIENT INSTALL           QUEUED
  OOZIE_SERVER START           PENDING
  NAMENODE INSTALL             QUEUED
  OOZIE_SERVER INSTALL         QUEUED
  ZOOKEEPER_CLIENT INSTALL     QUEUED
  SLIDER INSTALL               QUEUED
  APP_TIMELINE_SERVER INSTALL  IN_PROGRESS
  APP_TIMELINE_SERVER START    PENDING
  WEBHCAT_SERVER START         PENDING
  RESOURCEMANAGER INSTALL      QUEUED
  YARN_CLIENT INSTALL          QUEUED
  METRICS_MONITOR INSTALL      QUEUED
  OOZIE_CLIENT INSTALL         QUEUED
  DATANODE INSTALL             IN_PROGRESS
  SQOOP INSTALL                QUEUED
  HCAT INSTALL                 QUEUED
  METRICS_COLLECTOR INSTALL    QUEUED
  NODEMANAGER START            PENDING
  PIG INSTALL                  QUEUED
  ZOOKEEPER_SERVER START       PENDING
  HIVE_SERVER INSTALL          QUEUED
  HIVE_CLIENT INSTALL          QUEUED
  HBASE_REGIONSERVER INSTALL   QUEUED
  ZOOKEEPER_SERVER INSTALL     QUEUED
  HDFS_CLIENT INSTALL          QUEUED
  NODEMANAGER INSTALL          QUEUED
  HISTORYSERVER START          PENDING
  MYSQL_SERVER START           PENDING
  HBASE_MASTER INSTALL         QUEUED
  METRICS_COLLECTOR START      PENDING
  HIVE_METASTORE INSTALL       QUEUED
  HIVE_METASTORE START         PENDING
  MAPREDUCE2_CLIENT INSTALL    QUEUED
  HIVE_SERVER START            PENDING
  RESOURCEMANAGER START        PENDING
  HISTORYSERVER INSTALL        QUEUED
  SECONDARY_NAMENODE START     PENDING
  WEBHCAT_SERVER INSTALL       QUEUED
  METRICS_MONITOR START        PENDING
  HBASE_CLIENT INSTALL         QUEUED
  NAMENODE START               PENDING
  DATANODE START               PENDING
  HBASE_REGIONSERVER START     PENDING
  FALCON_SERVER START          PENDING
  KNOX_GATEWAY INSTALL         QUEUED
  FALCON_CLIENT INSTALL        IN_PROGRESS

CLUSTER:hdp-small-default>

今回は、、、

今回のBlueprintでの実行ですが、最終的にはFAILDになりました。

CLUSTER:hdp-small-default> tasks
  TASK                         STATUS
  ---------------------------  ---------
  MYSQL_SERVER INSTALL         COMPLETED
  KNOX_GATEWAY START           COMPLETED
  SECONDARY_NAMENODE INSTALL   COMPLETED
  HBASE_MASTER START           COMPLETED
  FALCON_SERVER INSTALL        COMPLETED
  TEZ_CLIENT INSTALL           COMPLETED
  OOZIE_SERVER START           COMPLETED
  NAMENODE INSTALL             COMPLETED
  OOZIE_SERVER INSTALL         COMPLETED
  ZOOKEEPER_CLIENT INSTALL     COMPLETED
  SLIDER INSTALL               COMPLETED
  APP_TIMELINE_SERVER INSTALL  COMPLETED
  APP_TIMELINE_SERVER START    COMPLETED
  WEBHCAT_SERVER START         COMPLETED
  RESOURCEMANAGER INSTALL      COMPLETED
  YARN_CLIENT INSTALL          COMPLETED
  METRICS_MONITOR INSTALL      COMPLETED
  OOZIE_CLIENT INSTALL         COMPLETED
  DATANODE INSTALL             COMPLETED
  SQOOP INSTALL                COMPLETED
  HCAT INSTALL                 COMPLETED
  METRICS_COLLECTOR INSTALL    COMPLETED
  NODEMANAGER START            COMPLETED
  PIG INSTALL                  COMPLETED
  ZOOKEEPER_SERVER START       COMPLETED
  HIVE_SERVER INSTALL          COMPLETED
  HIVE_CLIENT INSTALL          COMPLETED
  HBASE_REGIONSERVER INSTALL   COMPLETED
  ZOOKEEPER_SERVER INSTALL     COMPLETED
  HDFS_CLIENT INSTALL          COMPLETED
  NODEMANAGER INSTALL          COMPLETED
  HISTORYSERVER START          COMPLETED
  MYSQL_SERVER START           COMPLETED
  HBASE_MASTER INSTALL         COMPLETED
  METRICS_COLLECTOR START      COMPLETED
  HIVE_METASTORE INSTALL       COMPLETED
  HIVE_METASTORE START         COMPLETED
  MAPREDUCE2_CLIENT INSTALL    COMPLETED
  HIVE_SERVER START            COMPLETED
  RESOURCEMANAGER START        COMPLETED
  HISTORYSERVER INSTALL        COMPLETED
  SECONDARY_NAMENODE START     COMPLETED
  WEBHCAT_SERVER INSTALL       COMPLETED
  METRICS_MONITOR START        COMPLETED
  HBASE_CLIENT INSTALL         COMPLETED
  NAMENODE START               COMPLETED
  DATANODE START               COMPLETED
  HBASE_REGIONSERVER START     COMPLETED
  FALCON_SERVER START          FAILED
  KNOX_GATEWAY INSTALL         COMPLETED
  FALCON_CLIENT INSTALL        COMPLETED

FALCON_SERVER STARTで失敗した事が原因のようです。WebUIからログなどを見てみましたが、
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.91-0.b14.el7_2.x86_64/jre/bin/java and/or /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.91-0.b14.el7_2.x86_64/jre/bin/jar not found on the system.
との事。実際にサーバに入って確認しましたが、javaはあるけど、jarは言ってるPathには無いですね。openjdkだからなのかな?取り急ぎ、安易に本来のjarへリンク張って解決しました。う〜ん。
また、WebUIでみると、HBASEのReginServerも起動していませんでした。こちらもログを確認するとCannot allocate memoryとの事。あらら。どうもコンフィグのメモリ指定がデカすぎるようです。推奨値よりでかい設定です。この辺のblueprintでのコンフィグ関連は今後要調査ですね。

まぁ、大体うまくいったということで。:smile:

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4