安装Hive

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

cd /usr/local
tar -zxvf apache-hive-2.1.0-bin.tar.gz
mv apache-hive-2.1.0-bin hive

2. config path

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

3 install mysql

yum install -y mysql-server
service mysqld start  #start service mysqld
chkconfig mysqld on  #make service mysqld start on server restart
mysql  #check result
exit;    #exit mysql

4 instal mysql-connector lib

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

5. create database hive_metadata on mysql

mysql
create 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.sh
vi /usr/local/hive/bin/hive-config.sh
export HADOOP_HOME=/usr/local/hadoop-2.6.5

8 start hive and test

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

猜你喜欢

转载自oracle-api.iteye.com/blog/2372673