hive基本知识
hive的模式
1.内嵌模式
使用hive内嵌的数据库,正常情况下不会使用
内嵌数据库 derdy2.本地模式
hive.metastore.local => true3.远程模式
明确指定metastore的位置
hive.metastore.uris
hive.metastore.local false
hive 安装配置
mysql中创建用户的方法
在mysql中创建hive用户
create user ‘hive’ identified by ‘hive’;
给hive用户授权
grant all privileges on . to ‘hive’@’%’ with grant option;
create database hive;
alter database hive character set latin1;
hive解压
hive配置
conf/hive-site.xml
<property>
<name>hive.metastore.uris</name>
<value>thrift://dev-hadoop-single.com:9083</value>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://dev-hadoop-single.com:3306/local_db?createDatabaseIfNotExist=true</value>
<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>123456</value>
</property>
ps
配置hiveserver2
配置文件hive-site.xml里hive.server2.long.polling.timeout这个参数是5000L,改成5000
hive客户端 待后续
[hadoop@dev-hadoop-single ~]$ beeline
Beeline version 0.13.1-cdh5.3.6 by Apache Hive
beeline> !connect jdbc:hive2://dev-hadoop-single.com:10000/default
scan complete in 9ms
Connecting to jdbc:hive2://dev-hadoop-single.com:10000/default
Enter username for jdbc:hive2://dev-hadoop-single.com:10000/default: root
Enter password for jdbc:hive2://dev-hadoop-single.com:10000/default: ******
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/modules/hadoop-2.5.0-cdh5.3.6/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/modules/hbase-0.98.6-cdh5.3.6/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
Connected to: Apache Hive (version 0.13.1-cdh5.3.6)
Driver: Hive JDBC (version 0.13.1-cdh5.3.6)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://dev-hadoop-single.com:10000/d> show databases;