1、安装hive
在将hive-*-tar拷贝到hadoop集群的namenode上的hive安装目录,然后执行
tar -zxf hive-*.gz
2、配置hive
在/etc/profile中设置JAVA_HOME,HADOOP_HOME, HIVE_HOME环境变量.
将$HIVE_HOME/conf下的*.templete文件修改为配置文件。
cp $HIVE_HOME/conf/hive-default.xml $HIVE_HOME/conf。hive-site.xml
vi $HIVE_HOME/conf/hive-site.xml 配置如下
<property>
<name>hive.exec.scratchdir</name>
<value>/tmp/hive/scratchdir</value>
<description>Scratch space for Hive jobs</description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
执行hive命令行测show tables;
如果返回OK及配置成功。
3、安装mysql服务
4、修改metadatedb配置
加入$HIVE_HOME/lib中加入mysql-connector-java-*-bin.jar,否则执行hive命令行时报reflecte exception。
vi $HIVE_HOME/conf/hive-site.xml 配置如下
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.0.100:3306/hive</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>
5、执行hive后进入cli
当执行show tables时,出现ERROR exec.DDLTask: FAILED: Error in metadata: java.lang.IllegalArgumentException: URI: does not have a scheme
请确保jdbc URL填写正确,hadoop集群已经启动,并且hive能使用HADOOP_HOME环境变量。
Error in metadata: javax.jdo.JDOFatalDataStoreException: Access denied for user 'hive'@'master' (using password: YES)
说明root用户从主机master登录是出现问题,执行如下命令:
mysql -u root -p
CREATE USER 'hive'@'master' IDENTIFIED BY 'hive';
GRANT all hive.* TO 'hive'@'%';
6、启用HWI服务
vi $HIVE_HOME/conf/hive-site.xml 配置如下
<property>
<name>hive.hwi.listen.host</name>
<value>192.168.0.100</value>
<description>This is the host address the Hive Web Interface will listen on</description>
</property>
<property>
<name>hive.hwi.listen.port</name>
<value>60003</value>
<description>This is the port the Hive Web Interface will listen on</description>
</property>
<property>
<name>hive.hwi.war.file</name>
<value>lib/hive-hwi-0.8.1.war</value>
<description>This is the WAR file with the jsp content for Hive Web Interface</description>
</property>
执行hive --service hwi, 出现以下类似信息,则表示启动hwi服务成功。
INFO hwi.HWIServer: HWI is starting up
。。。。
INFO mortbay.log: Started SocketConnector@192.168.0.100:60003
通过http://192.168.0.100:60003/hwi访问启动的web服务。