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 / ...
随机推荐
- ORACLE WITH AS 用法,创建临时表
语法: with tempName as (select ....) select ... –针对一个别名with tmp as (select * from tb_name) –针对多个别名with ...
- Hibernate如何执行存储过程?
Hibernate如何执行存储过程? @Overridepublic Boolean setVarValue(final String processInstanceId, final String ...
- Storm基础概念与单词统计示例
Storm基本概念 Storm是一个分布式的.可靠地.容错的数据流处理系统.Storm分布式计算结构称为Topology(拓扑)结构,顾名思义,与拓扑图十分类似.该拓扑图主要由数据流Stream.数据 ...
- Spring的泛型依赖注入
Spring 4.x 中可以为子类注入子类对应的泛型类型的成员变量的引用,(这样子类和子类对应的泛型类自动建立关系)具体说明: 泛型注入:就是Bean1和Bean2注入了泛型,并且Bean1和Bean ...
- Zabbix监控主动模式
接上篇:Zabbix监控web,MySQL,TCP状态,Nginx 参考官方文档:https://www.zabbix.com/documentation/3.4/zh/manual zabbix默认 ...
- Exception in thread "main" java.lang.IllegalArgumentException: System memory 202768384 must be at least 4.718592E8. Please use a larger heap size.
Spark-submit 提交任务时候报错 Exception in thread "main" java.lang.IllegalArgumentException: Syste ...
- xpath-grab english name
from scrapy.spider import Spider from scrapy.crawler import CrawlerProcess import pymysql conn = pym ...
- container,algorith,iterate
\ http://morningspace.51.net/resource/stlintro/stlintro.html 标准容器 C++标准容器分为序列容器和关联容器,对于序列容器,C++提供的基本 ...
- arcgis server 无法手动删除切片
背景 问题 场景如下: 切片放置在专门的文件服务器上,通过unc共享路径对外共享.文件服务器的OS为windows server2008R2 想手动更新切片服务的切片.发现同一切片服务,有的比例级别文 ...
- java基础03变量和基本数据类型
package cn.bdqn.test; /** * * @author 小豆腐 * * 变量:会变化的量?? * 一个数据在内存中存储空间的表示!在运行期间可以动态改变! * * 关键字:在jav ...