您的位置:首页 > 运维架构

【Hadoop】Hadoop2.7.3安装Hive 2.1.0

2016-11-30 13:32 549 查看
原创文章,转载请标注来自http://blog.csdn.net/lsttoy/article/details/53406710

第一步

下载最新的hive,直接去apache 里面找hive2.1.0下载就行。

第二步,解压到服务器

tar zxvf apache-hive-2.0.0-bin.tar.gz
mv apache-hive-2.0.0-bin /home/hive
cd /home/hive


第三步,修改conf。这里只关心hadoop和hive的配置,其他JAVA HBASE的配置根据自己来

vi /etc/profile

#for hadoop
export HADOOP_HOME=/home/hadoop/hadoop-2.7.3
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"
export PATH=$PATH:/home/hadoop/hadoop-2.7.3/bin
export PATH=$PATH:/home/hadoop/hadoop-2.7.3/sbin

#for hive
export HIVE_HOME=/home/hive                               export PATH=$HADOOP_HOME/bin:$JAVA_HOME/bin:$HBASE_HOME/bin:$HIVE_HOME/bin:$PATH


第四步,下载并设置好jdbc connector

我这里使用了最新的mysql-connector-java-5.1.40.tar.gz

记住,将解压出来的jar放入hive 的lib中

cp mysql-connector-java-5.1.36-bin.jar $HIVE_HOME/lib/


第五步,配置hive-site.xml文件

文件来源于hive-default.xml.template



cp hive-default.xml.template hive-site.xml


然后找到

<name>javax.jdo.option.ConnectionURL</name>


修改其value

<value>jdbc:mysql://139.196.xxx.xxx:3306/hive?characterEncoding=UTF8&useSSL=false&createDatabaseIfNotExist=true</value>


同时,注意修改对应数据库的账号密码,否则会在执行hive时出错

<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>


第六步 运行hive客户端

cd /home/hive/bin
hive


第七步,初始化DB

schematool -initSchema -dbType mysql

第八步,查看成功后的元数据

可以看到对应数据库hive中,有了各种初始的表

第九步,启动master,node节点

启动单机

hive

启动集群

hive -hiveconf hbase.zookeeper.quorum=slave1,slave2,slave3

————————————————————————————————————————————

以下是可能出现的错误:

一,如果执行hive时候出现报出账号密码的错误

那么记得修改hive-site.xml中账号密码,参考第五步中的内容。

二,如果出现db没有初始化,如

Exception in thread "main" java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: org.apache.hadoop.hive.ql.metadata.HiveException: MetaException(message:Hive metastore database is not initialized. Please use schematool (e.g. ./schematool -initSchema -dbType ...) to create the schema. If needed, don't forget to include the option to auto-create the underlying database in your JDBC connection string (e.g. ?createDatabaseIfNotExist=true for mysql))


这种错误的时候,请先执行初始化DB。

三,如果提示

SSL相关的内容,请在配置jdbc链接的时候设置ssl为false

jdbc:mysql://139.196.xxx.xxx:3306/hive?useSSL=false&createDatabaseIfNotExist=true

Wed Nov 30 14:24:50 CST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Wed Nov 30 14:24:55 CST 2016 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.


四,遇到hive出错的时候

[Fatal Error] hive-site.xml:26:5: The element type "value" must be terminated by the matching end-tag "</value>".
Exception in thread "main" java.lang.RuntimeException: org.xml.sax.SAXParseException; systemId: file:/home/hive/conf/hive-site.xml; lineNumber: 26; columnNumber: 5; The element type "value" must be terminated by the matching end-tag "</value>".


Logging initialized using configuration in jar:file:/home/hive/lib/hive-common-2.1.0.jar!/hive-log4j2.properties Async: true
Exception in thread "main" java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D


这里就是配置文件Hive-site.xml中,修改system:java.io.tmpdir,指定一个系统存在的目录即可。

这里追加两种启动方式,方便各位用来进行hive测试。

hive提供了四种运行hive的方式,分别是:

**Hive CLI

HiveServer2 和 Beeline**

HCatalog

WebHCat (Templeton)

这里主要介绍前两种

第一种,hive CLI

因为hive的bin目录已经添加了path变量, 因此, 可以直接使用hive命令启动:

hive


输入完命令后可以,直接可以进行hive操作。

第二种HiveServer2 和 Beeline

beeline提供多用户, 更加安全的服务, 因此beeline用得比较多.

hiveserver2启动时默认的地址是”localhost:10000”, 因此, 在使用beeline连接的时候, 需要使用” jdbc:hive2://localhost:10000”作为参数.

相关的命令如下:

hiveserver2
beeline -u jdbc:hive2://localhost:10000


同时也可以将 Beeline和HiveServer2在同一个进程里启动, 用于测试:

beeline -u jdbc:hive2://

但是,这里如果用到自定义账号密码,必须在配置文件hive-site.xml中进行相关配置。

上文第五步已经进行了相关介绍,可以参照。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  hbase hive hadoop