LoginSignup
0
0

More than 3 years have passed since last update.

CI用 beeline コンテナの最新化と軽量化

Last updated at Posted at 2019-04-26

背景

我々のチームでは大容量データの分析のための基盤を運用しており,その中で Hadoop/hive での ETL を CI で廻す作業が多い.CI 用の beeline コンテナとして,当初 mapr のレポジトリを登録して beeline を apt-get で下記のように入れていたのだが,beeline のバージョンが低く,最近更改して hiveserver2 に冗長性を持たせた環境への接続が難しくなって困っていた.

RUN curl http://package.mapr.com/releases/pub/maprgpg.key | apt-key add -
RUN echo "deb http://package.mapr.com/releases/v5.2.0/ubuntu/ mapr optional" >> /etc/apt/sources.list
RUN echo "deb http://package.mapr.com/releases/ecosystem-5.x/ubuntu binary/" >> /etc/apt/sources.list
RUN apt-get update && apt install -y --no-install-recommends --allow-unauthenticated mapr-hive && \
        apt-get clean && rm -rf /var/lib/apt/lists/*
RUN ln -s /opt/mapr/hive/hive-1.2/bin/beeline /usr/bin/beeline

具体的にはこういうのが動かない.

beeline -n hive -u "jdbc:hive2://zk01.example.com:2181,zk02.example.com:2181,zk03.example.com:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2"

対処方針

ということで,dockerhub にあるものを試してみた.我々のクラスタは Hortonworks Hadoop (cloudera に社としては統合されたが,まだ製品ラインナップは別)なので,素直にやるとすると,github/akanto/beeline / dockerhubか.

で,サクっと動いた.もうこれでいいかとも思ったが,イメージサイズが2GBか…….上記でもともと使っていたのが debian ベースで 557MB.もうちょいなんとかならないかな,ということで今後も最新化に追従するためにも自分で素の Apache Hadoop から alpine ベースで作り直すことにした.

参照したのはこのへん

実装

FROM openjdk:8-jre-alpine

RUN apk add bash procps curl jq
RUN mkdir /opt/beeline \
        && curl -SL https://archive.apache.org/dist/hadoop/core/hadoop-3.2.0/hadoop-3.2.0.tar.gz \
        | tar -xzC /opt/beeline \
        && curl -SL https://archive.apache.org/dist/hive/hive-3.1.1/apache-hive-3.1.1-bin.tar.gz \
        | tar -xzC /opt/beeline

ENV HADOOP_HOME /opt/beeline/hadoop-3.2.0
ENV HIVE_HOME /opt/beeline/apache-hive-3.1.1-bin
ENV PATH $PATH:$HIVE_HOME/bin

結果

690MB.うーん,/opt/beeline/hadoop-3.2.0/share/doc だけでも 589M(圧縮前)とかになってるから,このへん削ればなんとかなりそうだけど,まぁとりあえずこれでいいか.

ref. https://hub.docker.com/r/skame/beeline

後日談

冗長化したほうのクラスタにつながるので一安心していたら,古いほうのクラスタにつながらずにCIがコケるという事態に.

org.apache.hive.org.apache.thrift.TApplicationException: Required field 'client_protocol' is unset! Struct:TOpenSessionReq(client_protocol:null, configuration:{use:database=default})

マジかー,といろいろ調べたところ,hive-jdbc-1.2.xhive-jdbc-2.x との間で下方互換性がない,ということのようだ.マジかー.ということで,skame/beeline:maprskame/beeline:latest を併用するという恰好悪い状況に.最新版の beeline で hive-jdbc だけ 1.2 にする手もあるかもしれないけど,面倒だからもうこれでいいや.早く hdp を 3 系に移行してしまおう.

https://community.hortonworks.com/questions/138021/getting-error-required-field-client-protocol-is-un.html
https://blog.suganoo.net/entry/2018/10/10/182058

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