hive安装
wget http://mirrors.hust.edu.cn/apache/hive/hive-2.3.6/apache-hive-2.3.6-bin.tar.gz
tar -zxvf apache-hive-2.3.6-bin.tar.gz
2. 环境配置
vi /etc/profile
#Hive
export HIVE_HOME=/usr/local/src/apache-hive-2.3.6-bin
export PATH=$PATH:$HIVE_HOME/bin
source /etc/profile
#配置mysql
vi $HIVE_HOME/conf/hive-site.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3308/hive?createDatabaseIfNotExist=true</value>
<description>JDBC connect string for a JDBC metastore</description>
<!-- 如果 mysql 和 hive 在同一个服务器节点,那么请更改 hadoop02 为 localhost -->
</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>admin</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
<description>password to use against metastore database</description>
</property>
</configuration>
#添加mysql.jar包至lib
cp mysql-connector-java-5.1.27.jar /usr/local/src/apache-hive-2.3.6-bin/lib
3.hive 初始化
schematool -dbType mysql -initSchema
4.启动 Hive 客户端,测试
mkdir /usr/local/src/apache-hive-2.3.6-bin/test
cd test
vi student.txt
95002,刘晨,女,19,IS
95017,王风娟,女,18,IS
95018,王一,女,19,IS
hive
create database myhive;
use myhive;
select current_database();
create table student(id int, name string, sex string, age int, department string) row format delimited fields terminated by ",";
load data local inpath "/usr/local/src/apache-hive-2.3.6-bin/test/student.txt" into table student;
select * from student;
desc student;
desc formatted student;
网友评论