1.简介
APACHE HIVE TM
The Apache Hive ™ data warehouse software facilitates reading, writing, and managing large datasets residing in distributed storage using SQL. Structure can be projected onto data already in storage. A command line tool and JDBC driver are provided to connect users to Hive.
数据仓库软件,支持使用SQL读取、写入和管理分布存储中的大型数据集。结构可以映射到存储中的数据。提供了一个命令行工具和JDBC驱动程序来将用户连接到Hive。
2.linux安装
tar -zvxf apache-hive-2.3.6-bin.tar.gz
export HIVE_HOME=/home/fcc/opt/hive/apache-hive-2.3.6-bin
就是个工具,不存在集群
bin/.hive 进入hive客户端
2.1hive的元数据库用mysql方式
2.1.1在服务器上安装mysql
2.1.3hive-site.xml
cp hive-default.xml.template hive-site.xml
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hadoop0:3306/hive?createDatabaseIfNotExist=true&useSSL=false</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>
2.2启动hive
bin/hive
Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
不能实例化一个类,lib/下没mysql的驱动包
Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
建议换版本
2.3HQL
要将数据库的编码格式改为 latin1
mysql> alter database hive character set latin1;
创建表
create table t_order(id int,name string, rongliang string,price double)
> row format delimited
> fields terminated by '\t'
> ;
插入数据
load data local inpath '/home/fcc/Desktop/hivetestdata/xxx.data' into table t_order;