设为首页 收藏本站
查看: 4766|回复: 0

[经验分享] docker安装hive笔记

[复制链接]

尚未签到

发表于 2015-4-17 11:10:13 | 显示全部楼层 |阅读模式
  前两篇文章介绍了docker的基本命令如何安装hadoop
  那么大家会比较了解docker的基本语法的安装过程。那么咱们今天来一起安装一下hive。

安装
  1、下载gitHub,地址:https://github.com/prasanthj/docker-hive-on-tez。如果背墙了,可以选择下载zip。进入目录之后就能看见如下内容:



@~/git/github/docker-hive-on-tez-master $ ls
Dockerfile        datagen.py        hive-log4j.properties    store_sales.sql
LICENSE            hive-0.14        hive-site.xml        store_sales.txt
README.md        hive-bootstrap.sh    postgresql.conf
  2、安装:



docker build --no-cache=true -t local-hive-on-tez .
  这是一个漫长的过程,喝一杯咖啡,该干嘛干嘛,几个小时之后回来......
  3、进入系统



docker --tls run -i -t -P local-hive-on-tez /etc/hive-bootstrap.sh -bash
Starting postgresql server...
/
2014-12-15 23:12:56 GMT LOG:  database system was interrupted; last known up at 2014-12-15 23:10:11 GMT
2014-12-15 23:12:56 GMT LOG:  database system was not properly shut down; automatic recovery in progress
2014-12-15 23:12:56 GMT LOG:  redo starts at 0/1782A58
  4、查看hive



root@2c1282c522bf:/# hive -f /opt/files/store_sales.sql
Logging initialized using configuration in file:/usr/local/hive-dist/apache-hive-0.15.0-SNAPSHOT-bin/conf/hive-log4j.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hadoop-2.5.2/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  5、端口映射
  如果你只想登录虚拟机玩玩,这个就足够了,可是还想看看这个hadoop运行的怎么样,需要在页面查看一下



@~/VirtualBox VMs/boot2docker-vm $ docker ps -a
CONTAINER ID        IMAGE                      COMMAND                CREATED             STATUS                      PORTS                                                                                                                                                                                                                                                                                                                                                              NAMES     
2c1282c522bf        local-hive-on-tez:latest   "/etc/hive-bootstrap   39 hours ago        Up 6 hours                  0.0.0.0:49181->8032/tcp, 0.0.0.0:49182->50075/tcp, 0.0.0.0:49183->50010/tcp, 0.0.0.0:49184->50090/tcp, 0.0.0.0:49185->8031/tcp, 0.0.0.0:49186->8040/tcp, 0.0.0.0:49187->8088/tcp, 0.0.0.0:49188->22/tcp, 0.0.0.0:49189->50020/tcp, 0.0.0.0:49190->8030/tcp, 0.0.0.0:49191->49707/tcp, 0.0.0.0:49192->8033/tcp, 0.0.0.0:49193->8042/tcp, 0.0.0.0:49194->50070/tcp   kickass_galileo     
  发现上面的一个端口是49194对应虚拟机的50070端口。
  这还不够,需要知道自己的boot2docker的ip是什么?默认是192.168.59.103
  那么需要在自己的浏览器输入:http://192.168.59.103:49194/ 就会看见hadoop的运行状态了。

备注:
  为什么下载github?
  因为需要获取他的Dockerfile,好让docker知道它依赖docker-tez,然后在虚拟机执行下载和安装hive,内容如下:



FROM prasanthj/docker-tez:tez-0.5.2  #这是说明依赖什么,下面是安装命令
MAINTAINER Prasanth Jayachandran
# to configure postgres as hive metastore backend
RUN apt-get update
RUN apt-get -yq install vim postgresql-9.3 libpostgresql-jdbc-java
# having ADD commands will invalidate the cache forcing hive build from trunk everytime
# copy config, sql, data files to /opt/files
RUN mkdir /opt/files
ADD hive-site.xml /opt/files/
ADD hive-log4j.properties /opt/files/
ADD store_sales.* /opt/files/
ADD datagen.py /opt/files/
# clone and compile hive
ENV HIVE_VERSION 0.15.0-SNAPSHOT
RUN cd /usr/local && git clone https://github.com/apache/hive.git #在天朝这可能被墙,所以速度非常慢
RUN cd /usr/local/hive && /usr/local/maven/bin/mvn clean install -DskipTests -Phadoop-2,dist
RUN mkdir /usr/local/hive-dist && tar -xf /usr/local/hive/packaging/target/apache-hive-${HIVE_VERSION}-bin.tar.gz -C /usr/local/hive-dist
# set hive environment
ENV HIVE_HOME /usr/local/hive-dist/apache-hive-${HIVE_VERSION}-bin
ENV HIVE_CONF $HIVE_HOME/conf
ENV PATH $HIVE_HOME/bin:$PATH
ADD hive-site.xml $HIVE_CONF/hive-site.xml
ADD hive-log4j.properties $HIVE_CONF/hive-log4j.properties
# zookeeper pulls jline 0.9.94 and hive pulls jline2. This workaround is from HIVE-8609
RUN rm $HADOOP_PREFIX/share/hadoop/yarn/lib/jline-0.9.94.jar
# add postgresql jdbc jar to classpath
RUN ln -s /usr/share/java/postgresql-jdbc4.jar $HIVE_HOME/lib/postgresql-jdbc4.jar
# set permissions for hive bootstrap file
ADD hive-bootstrap.sh /etc/hive-bootstrap.sh
RUN chown root:root /etc/hive-bootstrap.sh
RUN chmod 700 /etc/hive-bootstrap.sh
# to avoid psql asking password, set PGPASSWORD
ENV PGPASSWORD hive
# 下面是安装postgresql,这个在国外很流行
# To overcome the bug in AUFS that denies postgres permission to read /etc/ssl/private/ssl-cert-snakeoil.key file.
# https://github.com/Painted-Fox/docker-postgresql/issues/30
# https://github.com/docker/docker/issues/783
# To avoid this issue lets disable ssl in postgres.conf. If we really need ssl to encrypt postgres connections we have to fix permissions to /etc/ssl/private directory everytime until AUFS fixes the issue
ENV POSTGRESQL_MAIN /var/lib/postgresql/9.3/main/
ENV POSTGRESQL_CONFIG_FILE $POSTGRESQL_MAIN/postgresql.conf
ENV POSTGRESQL_BIN /usr/lib/postgresql/9.3/bin/postgres
ADD postgresql.conf $POSTGRESQL_MAIN
RUN chown postgres:postgres $POSTGRESQL_CONFIG_FILE
USER postgres
# create metastore db, hive user and assign privileges
RUN /etc/init.d/postgresql start &&\
psql --command "CREATE DATABASE metastore;" &&\
psql --command "CREATE USER hive WITH PASSWORD 'hive';" && \
psql --command "ALTER USER hive WITH SUPERUSER;" && \
psql --command "GRANT ALL PRIVILEGES ON DATABASE metastore TO hive;" && \
cd $HIVE_HOME/scripts/metastore/upgrade/postgres/ &&\
psql -h localhost -U hive -d metastore -f hive-schema-0.15.0.postgres.sql
# revert back to root user
USER root
  
  参考:
  https://github.com/prasanthj/docker-hive-on-tez
  https://github.com/prasanthj/docker-hadoop
  https://github.com/prasanthj/docker-tez

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-58126-1-1.html 上篇帖子: docker 练习 下篇帖子: Mac OS X 下安装使用 Docker
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表