概述
下载Hive安装包
http://hive.apache.org/downloads.html
2、将hive文件上传到HADOOP集群,并解压
将文件上传到:/export/software
tar -zxvf apache-hive-1.2.1-bin.tar.gz -C /export/servers/
cd /export/servers/
ln -s apache-hive-1.2.1-bin hive
3、配置环境变量,编辑/etc/profile
#set hive env
export HIVE_HOME=/export/servers/hive
export PATH=${HIVE_HOME}/bin:$PATH
#让环境变量生效
source /etc/profile
4、修改hive配置文件
- 进入配置文件的目录
cd /export/servers/hive/conf/
- 修改hive-env.sh文件
cp hive-env.sh.template hive-env.sh
将以下内容写入到hive-env.sh文件中
export JAVA_HOME=/export/servers/jdk
export HADOOP_HOME=/export/servers/hadoop
export HIVE_HOME=/export/servers/hive
- 修改log4j文件
cp hive-log4j.properties.template hive-log4j.properties
将EventCounter修改成org.apache.hadoop.log.metrics.EventCounter
#log4j.appender.EventCounter=org.apache.hadoop.hive.shims.HiveEventCounter
log4j.appender.EventCounter=org.apache.hadoop.log.metrics.EventCounter
- 配置远程登录模式
touch hive-site.xml
将以下信息写入到hive-site.xml文件中
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hadoop02:3306/hivedb?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
</property>
</configuration>
5、安装mysql并配置hive数据库及权限
- 安装mysql数据库及客户端
yum install mysql-server
yum install mysql
servicemysqld start
- 配置hive元数据库
mysql-u root -p
create database hivedb;
- 对hive元数据库进行赋权,开放远程连接,开放localhost连接
grant all privileges on *.* to root@"%" identified by "root" with grant option;
grant all privileges on *.* to root@"localhost" identified by "root" with grant option;
6、运行hive命令即可启动hive
hive>
附录1:如果报错Terminal initialization failed; falling back tounsupported
将/export/servers/hive/lib里面的jline2.12替换了hadoop 中/export/servers/hadoop/hadoop-2.6.1/share/hadoop/yarn/lib/jline-0.09*.jar
附录2:jdbc驱动类
附录3:异常信息
Logging initialized using configuration in jar:file:/export/servers/apache-hive-2.0.0-bin/lib/hive-common-2.0.0.jar!/hive-log4j2.properties
Exception in thread "main" java.lang.RuntimeException: 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)
处理方法:
schematool -dbType mysql -initSchema
最后
以上就是舒服泥猴桃为你收集整理的hive安装的全部内容,希望文章能够帮你解决hive安装所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复