安装hive包
[CDH下载地址](http://archive.cloudera.com/cdh5/cdh/5/)
1、将hive-0.13.1-cdh5.3.10.tar.gz使用WinSCP上传到sparkproject1的/usr/local目录下。
2、解压缩hive安装包:tar -zxvf hive-0.13.1-cdh5.3.6.tar.gz
3、重命名hive目录:mv hive-0.13.1-cdh5.3.6 hive
4、配置hive相关的环境变量
vi /etc/profile
export HIVE_HOME=/usr/local/hive
export PATH=$HIVE_HOME/bin
source /etc/profile
安装mysql
1、在sparkproject1上安装mysql。
2、使用yum安装mysql server。
yum install -y mysql-server
service mysqld start
chkconfig mysqld on
3、使用yum安装mysql connector
yum install -y mysql-connector-java
4、将mysql connector拷贝到hive的lib包中
cp /usr/share/java/mysql-connector-java-5.1.17.jar /usr/local/hive/lib
5、在mysql上创建hive元数据库,创建hive账号,并进行授权
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'@'spark1' identified by 'hive';
flush privileges;
use hive_metadata;
配置hive-site.xml
mv hive-default.xml.template hive-site.xml
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://spark1:3306/hive_metadata?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
</property>
配置hive-env.sh和hive-config.sh
mv hive-env.sh.template hive-env.sh
vi /usr/local/hive/bin/hive-config.sh
export JAVA_HOME=/usr/java/latest
export HIVE_HOME=/usr/local/hive
export HADOOP_HOME=/usr/local/hadoop
验证hive是否安装成功
直接输入hive命令,可以进入hive命令行
create table users(id int, name string)
load data local inpath '/usr/local/users.txt' into table users
select name from users
users
1�leo
2�jack
3�jen
4�marry
5�tom