ambariでhadoopクラスタ構築
Ambariとは
OSSで作られているHadoop管理プラットフォーム。セキュアな(Kerberosベースの) Hadoopクラスタのインストールをサポートし、ロールベースのユーザー認証と許可そして監査機能を提供し、ユーザー管理のために LDAPと Active Directoryとの統合も提供している。管理対象のホストにHDPのインストールを行うことができる。
HDPとは
Hortonworksが提供するHadoopエコシステムになります。
https://jp.hortonworks.com/ecosystems/
Ambariインストール
公式サイトを確認しAmbariインストール用のリポジトリをインストールする。
wget -nv http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.0.0/ambari.repo -O /etc/yum.repos.d/ambari.repo
Ambari-serverインストール
yum install ambari-server
[root@ambari01 ~]# yum search ambari-server 読み込んだプラグイン:fastestmirror Loading mirror speeds from cached hostfile * base: ftp.riken.jp * extras: ftp.riken.jp * updates: ftp.riken.jp ========================== N/S matched: ambari-server ========================== ambari-server.x86_64 : Ambari Server Name and summary matches only, use "search all" for everything. [root@ambari01 ~]# yum install ambari-server 読み込んだプラグイン:fastestmirror Loading mirror speeds from cached hostfile * base: ftp.riken.jp * extras: ftp.riken.jp * updates: ftp.riken.jp 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> パッケージ ambari-server.x86_64 0:2.2.2.0-460 を インストール --> 依存性の処理をしています: postgresql-server >= 8.1 のパッケージ: ambari-server-2.2.2.0-460.x86_64 --> トランザクションの確認を実行しています。 ---> パッケージ postgresql-server.x86_64 0:9.2.23-3.el7_4 を インストール --> 依存性の処理をしています: postgresql-libs(x86-64) = 9.2.23-3.el7_4 のパッケージ: postgresql-server-9.2.23-3.el7_4.x86_64 --> 依存性の処理をしています: postgresql(x86-64) = 9.2.23-3.el7_4 のパッケージ: postgresql-server-9.2.23-3.el7_4.x86_64 --> 依存性の処理をしています: libpq.so.5()(64bit) のパッケージ: postgresql-server-9.2.23-3.el7_4.x86_64 --> トランザクションの確認を実行しています。 ---> パッケージ postgresql.x86_64 0:9.2.23-3.el7_4 を インストール ---> パッケージ postgresql-libs.x86_64 0:9.2.23-3.el7_4 を インストール --> 依存性解決を終了しました。 依存性を解決しました ================================================================================ Package アーキテクチャー バージョン リポジトリー 容量 ================================================================================ インストール中: ambari-server x86_64 2.2.2.0-460 Updates-ambari-2.2.2.0 409 M 依存性関連でのインストールをします: postgresql x86_64 9.2.23-3.el7_4 updates 3.0 M postgresql-libs x86_64 9.2.23-3.el7_4 updates 234 k postgresql-server x86_64 9.2.23-3.el7_4 updates 3.8 M トランザクションの要約 ================================================================================ インストール 1 パッケージ (+3 個の依存関係のパッケージ) 総ダウンロード容量: 416 M インストール容量: 478 M
ambari-serverセットアップ
1.selinuxを無効化する
# vi /etc/sysconfig/selinxu SELINUX=disabled
2.ambari-server setupを実行する
[root@ambari01 ~]# ambari-server setup Using python /usr/bin/python Setup ambari-server Checking SELinux... SELinux status is 'disabled' Customize user account for ambari-server daemon [y/n] (n)? y Enter user account for ambari-server daemon (root):ambari Adjusting ambari-server permissions and ownership... Checking firewall status... Redirecting to /bin/systemctl status iptables.service Unit iptables.service could not be found. Checking JDK... [1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8 [2] Oracle JDK 1.7 + Java Cryptography Extension (JCE) Policy Files 7 [3] Custom JDK ============================================================================== Enter choice (1): 1 To download the Oracle JDK and the Java Cryptography Extension (JCE) Policy Files you must accept the license terms found at http://www.oracle.com/technetwork/java/javase/terms/license/index.html and not accepting will cancel the Ambari Server setup and you must install the JDK and JCE files manually. Do you accept the Oracle Binary Code License Agreement [y/n] (y)? y Downloading JDK from http://public-repo-1.hortonworks.com/ARTIFACTS/jdk-8u60-linux-x64.tar.gz to /var/lib/ambari-server/resources/jdk-8u60-linux-x64.tar.gz jdk-8u60-linux-x64.tar.gz... 22% (38.9 MB of 172.8 MB)
JavaにはJCEを利用しています。Javaがデフォルトで使っている暗号化の鍵はAESの128bitになるのですがkerberos認証を有効にする場合は256bitのAESが使えるJCEを利用します。
3.ambari-serverを起動する
ambari-server start
4.8080ポート解放
firewall-cmd --add-port=8080/tcp --zone=public --permanent
firewall-cmd --reload
5.起動状態確認
[ambari@ambari01 ~]$ ambari-server status Using python /usr/bin/python Ambari-server status Ambari Server running Found Ambari Server PID: 1756 at: /var/run/ambari-server/ambari-server.pid
以下のURLにアクセスしてambariにアクセスする。初期のユーザーID/パスワードはadmin/adminになっている。
http://ホスト名:8080/
初回のログイン後は以下のような画面が表示される
6.Launch Install Wizardを実行する
事前にambariサーバからambariの起動ユーザでhdpインストール先のホストにパスワードなしのssh鍵で接続できるようにしておく。confirm hostで止まる場合は 、host名を修正しhostsファイルで参照できるようになっているか 、hostsファイルの内容がクラスタ内で同一になっているか、ホスト名がトップレベルのドメインになっていないか、クラスタ内はntpで時間の同期が取れているかを確認する。それでも入らない場合は最新のAmbariがないか確認する。
1. cluster nameを入力する
2. HDPのバージョンを指定する
3. install option
- ホスト名の入力
- 秘密鍵と接続ユーザの登録
4. confirm hostは完了したらnextをクリックする
5. choose servicesはそのままnextをクリックする
6. Assign metricsもnextをクリックする
7. Assign service and clientsでnextをクリックする
8. customize serviceでは必須入力を入力してnextをクリックする
9. それから各ホストにhdpのインストール、テストが始まります。
インストール完了後のambariの画面は以下のようになります。とりあえずhdfsとhiveだけサービスを起動させているのでアラートがたくさん出ています。
hdfsにアクセスしてみる
hdpをインストールしたホストにて以下コマンドを実行してhdfsにアクセスできることを確認します。 ユーザはambariインストールに使用したユーザを使っています。
[ambari@hadoop-slave01 ~]$ hdfs dfs -ls / Found 11 items drwxrwxrwx - yarn hadoop 0 2018-04-28 21:22 /app-logs drwxr-xr-x - hdfs hdfs 0 2018-04-28 21:52 /apps drwxr-xr-x - yarn hadoop 0 2018-04-28 21:22 /ats drwxr-xr-x - hdfs hdfs 0 2018-04-28 21:22 /hdp drwxr-xr-x - mapred hdfs 0 2018-04-28 21:22 /mapred drwxrwxrwx - mapred hadoop 0 2018-04-28 21:23 /mr-history drwxrwxrwx - spark hadoop 0 2018-04-28 22:10 /spark-history drwxrwxrwx - spark hadoop 0 2018-04-28 22:10 /spark2-history drwxrwxrwx - hdfs hdfs 0 2018-04-28 21:56 /tmp drwxr-xr-x - hdfs hdfs 0 2018-04-28 21:52 /user drwxr-xr-x - hdfs hdfs 0 2018-04-28 21:23 /webhdfs
hiveにアクセスしてみる
beelineコマンドを実行してhiveにアクセスできることを確認してみます。
[ambari@hadoop-slave01 ~]$ beeline Beeline version 1.2.1000.2.6.3.0-235 by Apache Hive beeline> !connect jdbc:hive2://localhost:10000/default Connecting to jdbc:hive2://localhost:10000/default Enter username for jdbc:hive2://localhost:10000/default: ambari Enter password for jdbc:hive2://localhost:10000/default: ****** Connected to: Apache Hive (version 1.2.1000.2.6.3.0-235) Driver: Hive JDBC (version 1.2.1000.2.6.3.0-235) Transaction isolation: TRANSACTION_REPEATABLE_READ 0: jdbc:hive2://localhost:10000/default> show databases; +----------------+--+ | database_name | +----------------+--+ | default | +----------------+--+ 1 row selected (3.666 seconds) 0: jdbc:hive2://localhost:10000/default> use default; No rows affected (1.73 seconds) 0: jdbc:hive2://localhost:10000/default> show tables; +-----------+--+ | tab_name | +-----------+--+ +-----------+--+ No rows selected (0.71 seconds)
個別にhadoop, hiveのインストールを行うのは大変なのでambariなどでまとめて入れて管理するのが良さそうです。