LoginSignup
11
11

More than 5 years have passed since last update.

CDH5版Hiveのインストール手順

Last updated at Posted at 2015-12-17

CDH版Hiveのインストール手順を今後のためにまとめておきます。
そのうち自動化したい。

前提条件

  • 擬似分散環境
  • OSはCentOS 7
  • Javaはインストール済み
  • PostgreSQLはインストール済み(Hive Metastore用)

Clouderaのレポジトリ登録

# wget http://archive.cloudera.com/cdh5/redhat/7/x86_64/cdh/cloudera-cdh5.repo
# mv cloudera-cdh5.repo /etc/yum.repos.d/

インストールしたいCDHのバージョンを最新から変えたい場合は、
cloudera-cdh5.repoを編集する。

baseurl=https://archive.cloudera.com/cdh5/sles/11/x86_64/cdh/5/

baseurl= https://archive.cloudera.com/cdh5/sles/11/x86_64/cdh/5.3.3/

というようにすればよい。

Hadoop擬似分散環境のインストール

パッケージインストール

# yum clean all
# yum install hadoop-conf-pseudo

HDFSのフォーマット&起動

# sudo -u hdfs hdfs namenode -format
# service hadoop-hdfs-namenode start
# service hadoop-hdfs-datanode start
# service hadoop-hdfs-secondarynamenode start
# /usr/lib/hadoop/libexec/init-hdfs.sh

YARNクラスタの起動

# service hadoop-yarn-resourcenamager start
# service hadoop-yarn-nodemanager start

Hiveインストール

パッケージインストール

# yum install hive hive-metastore hive-server2

Hiveメタストアの設定

別途インストールしたPostgreSQLを利用します。バージョンは9.5RC1。

PostgreSQLの設定

postgresql.conf

postgresql.conf
listen_addresses = '*'
standard_conforming_strings = off
pg_hba.conf
host    all             all             0.0.0.0/32              md5

PostgreSQL JDBC Driverのインストール

# wget https://jdbc.postgresql.org/download/postgresql-9.4-1206-jdbc42.jar
# mv postgresql-9.4-1206-jdbc42.jar /usr/lib/hive/lib/

Hive用ユーザ、データベースの作成

# su - postgres
$ psql
psql (9.5rc1)
Type "help" for help.

[local] 34253 postgres=# CREATE USER hive WITH PASSWORD 'password';
CREATE ROLE
[local] 34253 postgres=# CREATE DATABASE metastore;
CREATE DATABASE
[local] 34253 postgres=# \q

Hiveが使うテーブルやインデックスなどを作成するスクリプトを流す。
このスクリプトは相対パスを使っているので、スクリプトが置いてあるディレクトリに移動してから実行する必要がある。

$ cd /usr/lib/hive/scripts/metastore/upgrade/postgres/
$ psql -d metastore -f hive-schema-1.1.0.postgres.sql

作成したテーブルやインデックスへのアクセス権限を上で作成したユーザに与える。

$ psql metastore
psql (9.5rc1)
Type "help" for help.

metastore=# \pset tuples_only on
Tuples only is on.
metastore=# \o /tmp/grant-privs
metastore=#  SELECT 'GRANT SELECT,INSERT,UPDATE,DELETE ON "'  || schemaname || '". "' ||tablename ||'" TO hive ;'
FROM pg_tables
 WHERE tableowner = CURRENT_USER and schemaname = 'public';
metastore=# \o
metastore=# \pset tuples_only off
Tuples only is off.
metastore=# \i /tmp/grant-privs

Hiveの設定

hive-site.xml
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:postgresql://localhost:5432/metastore</value>
</property>

<property>
  <name>javax.jdo.option.ConnectionDriverName</name>
  <value>org.postgresql.Driver</value>
</property>

<property>
  <name>javax.jdo.option.ConnectionUserName</name>
  <value>hive</value>
</property>

<property>
  <name>javax.jdo.option.ConnectionPassword</name>
  <value>password</value>
</property>

<property>
  <name>datanucleus.autoCreateSchema</name>
  <value>false</value>
</property>

<property>
  <name>hive.metastore.uris</name>
  <value>thrift://localhost:9083</value>
  <description>IP address (or fully-qualified domain name) and port of the metastore host</description>
</property>

<property>
  <name>hive.support.concurrency</name>
  <description>Enable Hive's Table Lock Manager Service</description>
  <value>true</value>
</property>

<property>
  <name>hive.zookeeper.quorum</name>
  <description>Zookeeper quorum used by Hive's Table Lock Manager</description>
  <value>localhost:2181</value>
</property>

</configuration>

Hive Metastoreの起動

# service hive-metastore start

HiveServer2のインストール

ZooKeeperのインストール&起動

# yum install zookeeper-server
# service zookeeper-server init --myid=1
Using myid of 1
# service zookeeper-server start

HiveServer2の起動

# start hive-server2 start

beelineからの接続確認

# su - hive
$ beeline
Beeline version 1.1.0-cdh5.5.1 by Apache Hive
beeline> !connect jdbc:hive2://localhost:10000 hive password org.apache.hive.jdbc.HiveDriver
Connecting to jdbc:hive2://localhost:10000
Connected to: Apache Hive (version 1.1.0-cdh5.5.1)
Driver: Hive JDBC (version 1.1.0-cdh5.5.1)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://localhost:10000>
0: jdbc:hive2://localhost:10000> SHOW TABLES;
+-----------+--+
| tab_name  |
+-----------+--+
+-----------+--+
No rows selected (3.6 seconds)
0: jdbc:hive2://localhost:10000> !quit
Closing: 0: jdbc:hive2://localhost:10000

以上。
長すぎ。

11
11
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
11
11