安装Hive

来源:互联网 发布:安大略国际学院 知乎 编辑:程序博客网 时间:2024/06/01 12:32

1. download apache-hive-2.1.0-bin.tar.gz, copy this file to /usr/local

cd /usr/localtar -zxvf apache-hive-2.1.0-bin.tar.gzmv apache-hive-2.1.0-bin hive

 

2. config path

vi ~/.bashrcexport HIVE_HOME=/usr/local/hive  #add new line  export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HIVE_HOME/binsource  ~/.bashrc

 

3 install mysql

yum install -y mysql-serverservice mysqld start  #start service mysqldchkconfig mysqld on  #make service mysqld start on server restartmysql  #check resultexit;    #exit mysql

 

4 instal mysql-connector lib

yum install -y mysql-connector-javacp /usr/share/java/mysql-connector-java-5.1.17.jar  /usr/local/hive/lib

 

5. create database hive_metadata on mysql

mysqlcreate database if not exists hive_metadata;grant all privileges on hive_metadata.* to 'hive'@'%' identified by 'hive';grant all privileges on hive_metadata.* to 'hive'@'localhost' identified by 'hive';grant all privileges on hive_metadata.* to 'hive'@'centos1' identified by 'hive';flush privileges;use hive_metadata;  #check result

 

 

6 config hive-site.xml

cd /usr/local/hive/conf

cp hive-default.xml.template hive-site.xml

vi hive-site.xml

<property><name>system:java.io.tmpdir</name><value>/usr/local/hive/tmp</value><description/></property><property><name>system:user.name</name><value>peter</value><description/></property><property><name>javax.jdo.option.ConnectionURL</name><value>jdbc:mysql://centos1:3306/hive_metadata?createDatabaseIfNotExist=true</value><description>JDBC connect string for a JDBC metastore</description></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>hive</value><description>username to use against metastore database</description></property><property><name>javax.jdo.option.ConnectionPassword</name><value>hive</value><description>password to use against metastore database</description></property><property><name>hive.metastore.warehouse.dir</name><value>/user/hive/warehouse</value><description>location of default database for the warehouse</description></property>

 

7 config  hive-env.sh

cp hive-env.sh.template hive-env.shvi /usr/local/hive/bin/hive-config.shexport HADOOP_HOME=/usr/local/hadoop-2.6.5

 

8 start hive and test

/usr/local/hive/bin/schematool -initSchema -dbType mysql   #init mysql databasehive    #start hivehive>use hive_metadata;  hive>create table ti(id int);hive>select * from t1;hive>drop table t1;hive>exit;