hive安装

hive安装

1. 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 


        
                javax.jdo.option.ConnectionURL
                jdbc:mysql://localhost:3308/hive?createDatabaseIfNotExist=true
                JDBC connect string for a JDBC metastore
                
        
        
                javax.jdo.option.ConnectionDriverName
                com.mysql.jdbc.Driver
                Driver class name for a JDBC metastore
        
        
                javax.jdo.option.ConnectionUserName
                admin
                username to use against metastore database
        
        
                javax.jdo.option.ConnectionPassword
                123456
        password to use against metastore database
        


#添加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;


你可能感兴趣的:(hive安装)