hive + hadoop 环境搭建
机器规划:
| 主机 | ip | 进程 |
| hadoop1 | 10.183.225.158 | hive server |
| hadoop2 | 10.183.225.166 | hive client |
前置条建:
kerberos部署:http://www.cnblogs.com/kisf/p/7473193.html
Hadoop HA + kerberos部署:http://www.cnblogs.com/kisf/p/7477440.html
mysql安装:略
添加hive用户名,及数据库。mysql -uhive -h10.112.28.179 -phive123456
hive使用2.3.0版本:
wget http://mirror.bit.edu.cn/apache/hive/hive-2.3.0/apache-hive-2.3.0-bin.tar.gz
添加环境变量:
export HIVE_HOME=/letv/soft/apache-hive-2.3.0-bin
export HIVE_CONF_DIR=$HIVE_HOME/conf
export PATH=\$PATH:\$HIVE_HOME/bin
同步至master2,并 source /etc/profile
解压:
tar zxvf apache-hive-2.3.0-bin.tar.gz
kerberos生成keytab:
addprinc -randkey hive/hadoop1@JENKIN.COM
addprinc -randkey hive/hadoop2@JENKIN.COM xst -k /var/kerberos/krb5kdc/keytab/hive.keytab hive/hadoop1@JENKIN.COM
xst -k /var/kerberos/krb5kdc/keytab/hive.keytab hive/hadoop2@JENKIN.COM
拷贝至hadoop2
scp /var/kerberos/krb5kdc/keytab/hive.keytab hadoop1:/var/kerberos/krb5kdc/keytab/
scp /var/kerberos/krb5kdc/keytab/hive.keytab hadoop2:/var/kerberos/krb5kdc/keytab/
(使用需要kinit)
hive server 配置:
hive server hive-env.sh增加:
HADOOP_HOME=/xxx/soft/hadoop-2.7.3
export HIVE_CONF_DIR=/xxx/soft/apache-hive-2.3.0-bin/conf
export HIVE_AUX_JARS_PATH=/xxx/soft/apache-hive-2.3.0-bin/lib
hive server上增加hive-site.xml:
<configuration>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
<description>
Enforce metastore schema version consistency.
True: Verify that version information stored in metastore matches with one from Hive jars. Also disable automatic
schema migration attempt. Users are required to manully migrate schema after Hive upgrade which ensures
proper metastore schema migration. (Default)
False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
</description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
<property>
<name>hive.querylog.location</name>
<value>/xxx/soft/apache-hive-2.3.0-bin/log</value>
<description>Location of Hive run time structured log file</description>
</property>
<property>
<name>hive.downloaded.resources.dir</name>
<value>/xxx/soft/apache-hive-2.3.0-bin/tmp</value>
<description>Temporary local directory for added resources in the remote file system.</description>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://10.112.28.179:3306/hive?createDatabaseIfNotExist=true&iuseUnicode=true&characterEncoding=utf-8&useSSL=false</value<configuration>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property> <property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive123456</value>
<description>password to use against metastore database</description>
</property>
<!-- kerberos config -->
<property>
<name>hive.server2.authentication</name>
<value>KERBEROS</value>
</property>
<property>
<name>hive.server2.authentication.kerberos.principal</name>
<value>hive/_HOST@JENKIN.COM</value>
</property>
<property>
<name>hive.server2.authentication.kerberos.keytab</name>
<value>/var/kerberos/krb5kdc/keytab/hive.keytab</value>
<!-- value>/xxx/soft/apache-hive-2.3.0-bin/conf/keytab/hive.keytab</value -->
</property> <property>
<name>hive.metastore.sasl.enabled</name>
<value>true</value>
</property>
<property>
<name>hive.metastore.kerberos.keytab.file</name>
<value>/var/kerberos/krb5kdc/keytab/hive.keytab</value>
</property>
<property>
<name>hive.metastore.kerberos.principal</name>
<value>hive/_HOST@JENKIN.COM</value>
</property>
hadoop namenode core-site.xml增加配置:
<!-- hive congfig -->
<property>
<name>hadoop.proxyuser.hive.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.hive.groups</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.hdfs.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.hdfs.groups</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.HTTP.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.HTTP.groups</name>
<value>*</value>
</property>
同步是其他机器。
scp etc/hadoop/core-site.xml master2:/xxx/soft/hadoop-2.7.3/etc/hadoop/
scp etc/hadoop/core-site.xml slave2:/xxx/soft/hadoop-2.7.3/etc/hadoop/
JDBC下载:
wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.44.tar.gz
tar zxvf mysql-connector-java-5.1.44.tar.gz
复制到hive lib目录:
cp mysql-connector-java-5.1.44/mysql-connector-java-5.1.44-bin.jar apache-hive-2.3.0-bin/lib/
客户端配置:
将hive拷贝至hadoop2
scp -r apache-hive-2.3.0-bin/ hadoop2:/xxx/soft/
在hadoop2上(client):
hive-site.xml
<configuration>
<property>
<name>hive.metastore.uris</name>
<value>thrift://hadoop1:9083</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>false</value>
</property>
<!-- kerberos config -->
<property>
<name>hive.server2.authentication</name>
<value>KERBEROS</value>
</property>
<property>
<name>hive.server2.authentication.kerberos.principal</name>
<value>hive/_HOST@JENKIN.COM</value>
</property>
<property>
<name>hive.server2.authentication.kerberos.keytab</name>
<value>/var/kerberos/krb5kdc/keytab/hive.keytab</value>
<!-- value>/xxx/soft/apache-hive-2.3.0-bin/conf/keytab/hive.keytab</value -->
</property> <property>
<name>hive.metastore.sasl.enabled</name>
<value>true</value>
</property>
<property>
<name>hive.metastore.kerberos.keytab.file</name>
<value>/var/kerberos/krb5kdc/keytab/hive.keytab</value>
</property>
<property>
<name>hive.metastore.kerberos.principal</name>
<value>hive/_HOST@JENKIN.COM</value>
</property> </configuration>
启动hive:
初始化数据:
./bin/schematool -dbType mysql -initSchema
获取票据:
kinit -k -t /var/kerberos/krb5kdc/keytab/hive.keytab hive/hadoop1@JENKIN.COM
启动server:
hive --service metastore &
验证:
[root@hadoop1 conf]# netstat -nl | grep 9083
tcp 0 0 0.0.0.0:9083 0.0.0.0:* LISTEN
ps -ef | grep metastore hive hive>
启动thrift (hive server)
hive --service hiveserver2 &
验证thrift(hive server是否启动)
[root@hadoop1 conf]# netstat -nl | grep 10000
tcp 0 0 0.0.0.0:10000 0.0.0.0:* LISTEN
hive客户端hql操作:
DML参考:https://cwiki.apache.org//confluence/display/Hive/LanguageManual+DML
通过hive建的database,tables, 在hdfs 上都能看到。参考hive-site.xml location配置。
hadoop fs -ls /usr/hive/warehouse
beeline客户端连接hive:
beeline -u "jdbc:hive2://hadoop1:10000/;principal=hive/_HOST@JENKIN.COM"
执行sql:
0: jdbc:hive2://hadoop1:10000/> show databases;
+----------------+
| database_name |
+----------------+
| default |
| hivetest |
+----------------+
2 rows selected (0.318 seconds)
hive> create database jenkintest;
OK
Time taken: 0.968 seconds
hive> show databases;
OK
default
hivetest
jenkintest
Time taken: 0.033 seconds, Fetched: 3 row(s)
hive> use jenkintest
> ;
OK
Time taken: 0.108 seconds
hive> create table test1(columna int, columnb string);
OK
Time taken: 0.646 seconds
hive> show tables;
OK
test1
Time taken: 0.084 seconds, Fetched: 1 row(s)
hive数据导入:(通过文件导入,在本地建立文件,列按“table”键分开)
[root@hadoop2 ~]# vim jenkindb.txt
1 jenkin
2 jenkin.k
3 anne [root@hadoop2 ~]#hive hive> create table jenkintb (id int, name string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' STORED AS TEXTFILE; hive> load data local inpath 'jenkindb.txt' into table jenkintb; hive> select * from jenkintb;
OK
1 jenkin
2 jenkin.k
3 anne
show create table jenkintb;
hive + hadoop 环境搭建的更多相关文章
- Linux集群搭建与Hadoop环境搭建
今天是8月19日,距离开学还有15天,假期作业完成还是遥遥无期,看来开学之前的恶补是躲不过了 今天总结一下在Linux环境下安装Hadoop的过程,首先是对Linux环境的配置,设置主机名称,网络设置 ...
- 转 史上最详细的Hadoop环境搭建
GitChat 作者:鸣宇淳 原文:史上最详细的Hadoop环境搭建 关注公众号:GitChat 技术杂谈,一本正经的讲技术 [不要错过文末活动哦] 前言 Hadoop在大数据技术体系中的地位至关重要 ...
- 【转】RHadoop实践系列之一:Hadoop环境搭建
RHadoop实践系列之一:Hadoop环境搭建 RHadoop实践系列文章,包含了R语言与Hadoop结合进行海量数据分析.Hadoop主要用来存储海量数据,R语言完成MapReduce 算法,用来 ...
- hadoop环境搭建之关于NAT模式静态IP的设置 ---VMware12+CentOs7
很久没有更新了,主要是没有时间,今天挤出时间验证了一下,果然还是有些问题的,不过已经解决了,就发上来吧. PS:小豆腐看仔细了哦~ 关于hadoop环境搭建,从单机模式,到伪分布式,再到完全分布式,我 ...
- eclipse工具下hadoop环境搭建
eclipse工具下hadoop环境搭建: window10操作系统中搭建eclipse64开发系统,配置hadoop的eclipse插件,让eclipse可以查看Hdfs中的文件内容. ...
- 大数据学习之Hadoop环境搭建
一.Hadoop的优势 1)高可靠性:因为Hadoop假设计算元素和存储会出现故障,因为它维护多个工作数据副本,在出现故障时可以对失败的节点重新分布处理. 2)高扩展性:在集群间分配任务数据,可方便的 ...
- Hadoop环境搭建、启动和管理界面查看
一.hadoop环境搭建: 1. hadoop 6个核心配置文件的作用:core-site.xml:核心配置文件,主要定义了我们文件访问的格式 hdfs://hadoop-env.sh:主要配置我们的 ...
- Ubuntu中Hadoop环境搭建
Ubuntu中Hadoop环境搭建 JDK安装 方法一:通过命令行直接安装(不建议) 有两种java可以安装oracle-java8-installer以及openjdk (1)安装oracle-ja ...
- Hadoop环境搭建(centos)
Hadoop环境搭建(centos) 本平台密码83953588abc 配置Java环境 下载JDK(本实验从/cgsrc 文件中复制到指定目录) mkdir /usr/local/java cp / ...
随机推荐
- css从中挖去一个圆
始终居中: width: 300px; position: fixed; /*在可视区域的上下左右居中*/ top: calc(50vh - 200px); left: calc(50vw - 150 ...
- poj 1386
Play on Words Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11312 Accepted: 3862 De ...
- FluentNhibernate 不支持存储过程
一直以为没有使用FN进行存储过程的操作,这次因为后台首页想统计下数据,就利用了存储过程,但在使用中却发现FN目前还不支持存储过程(点击查看官方),没有办法,只能利用Fluent Configurati ...
- 『SharePoint 2010』Sharepoint 2010 Form 身份认证的实现(基于AD)
一.进管理中心,创建一个应用程序,配置如下: 二.填端口号,和选择form身份认证,以及填写成员和角色,其他都默认就可以了 三.使用SharePoint 2010 Management Shell在里 ...
- iOS 按钮文字加划掉线
UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(, , , )]; NSDictionary *normalTitleAttribu ...
- 170427、centos6.5配置duboo
IP: 192.168.0.111 部署容器:apache-tomcat-7.0.57 端口:8080 1. 下载最新版的 Tomcat7: $wget http://mirrors.hust.edu ...
- 爬虫用到的库Beautiful Soup
Beautiful Soup 是一个可以从HTML或XML文件中提取数据的Python库.它能够通过你喜欢的转换器实现惯用的文档导航,查找,修改文档的方式.Beautiful Soup会帮你节省数小时 ...
- EIT: where is it now and what lies ahead?
EIT: where is it now and what lies ahead? Electrical impedance tomography (EIT) is an emerging clini ...
- Zipline Data Bundles
Data Bundles A data bundle is a collection of pricing data, adjustment data, and an asset database. ...
- 剑指Offer——孩子们的游戏(圆圈中最后剩下的数)
题目描述: 每年六一儿童节,牛客都会准备一些小礼物去看望孤儿院的小朋友,今年亦是如此.HF作为牛客的资深元老,自然也准备了一些小游戏.其中,有个游戏是这样的:首先,让小朋友们围成一个大圈.然后,他随机 ...