Hive安装及配置

一、安装 

1、        下载安装hive

hive-0.11.0.tar.gz(稳定版)

目录:/data

 

tar –zxvf hive-0.11.0.tar.gz

 

2、        配置

 

把所有的模板文件copy一份

 

                     cd /opt/hive-0.11.0/conf

 

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

                     cp hive-env.sh.template   hive-env.sh

                     cp  hive-log4j.properties.template hive-log4j.properties

                     cp hive-exec-log4j.properties.template  hive-exec-log4j.properties

 

3、        修改hive-default.xml

<property>

 <name>javax.jdo.option.ConnectionURL</name>

 <value>jdbc:mysql://192.168.10.110:3306/hive? createDatabaseIfNotExist=true</value>

 <description>JDBC connect string for a JDBCmetastore</description>

</property>

                            <property>

 <name>javax.jdo.option.ConnectionDriverName</name>

 <value>com.mysql.jdbc.Driver</value>

 <description>Driver class name for a JDBCmetastore</description>

</property>

<property>

 <name>javax.jdo.option.ConnectionUserName</name>

 <value>hadoop</value>

 <description>username to use against metastoredatabase</description>

</property>

                            <property>

 <name>javax.jdo.option.ConnectionPassword</name>

 <value>hive</value>

 <description>password to use against metastoredatabase</description>

</property>

<property>

 <name>hive.metastore.schema.verification</name>

 <value>false</value>

  <description>

  Enforce metastore schema version consistency.

  True: Verify that version information stored in metastore matches withone from Hive jars.  Also disableautomatic

        schema migration attempt. Users are required to manully migrate schemaafter Hive upgrade which ensures

        proper metastore schema migration. (Default)

  False: Warn if the version information stored in metastore doesn't matchwith one from in Hive jars.

  </description>

</property>

 

4、        修改hive-env.sh

     # Set HADOOP_HOME to pointto a specific hadoop install directory

HADOOP_HOME=/home/hadoop/hadoop-2.2.0

 

              #Hive Configuration Directory can be controlled by:

exportHIVE_CONF_DIR=/home/hadoop/hive-0.11.0/conf

 

5、        安装mysql jdbc

下载mysql.jar,复制到hive0.11.0/lib下

6、        各项配置详解

http://blog.csdn.net/w13770269691/article/details/17232947

 

7、        创建mysql hive用户权限

grant all on hive.* to ‘hadoop’@’%’identified by  ‘hive’

8、        遇到的问题

 

                            始终不往mysql插入元数据,在hive-default.xml.template发现这么一句话” <!--WARNING!!! You must make your changes in hive-site.xml instead.       -->”,原来只是改成hive-default.xml,改完后又发现异常,

      FAILED:Error in metadata: java.lang.RuntimeException: Unable to instantiateorg.apache.hadoop.hive.metastore.HiveMetaStoreClient FAILED: Execution Error,return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask 

,原因是mysql的hadoop用户被拒绝了,把hive-site.xml里jdbc配置localhost改成IP地址后,又异常hive的Specified key was too long; max key length is 767 bytes,通过资料要把hive库的编码字符集修改成latin1,alterdatabase hive character set latin1;问题解决。

启动hive


#启动metastore服务
~ bin/hive --service metastore &
Starting Hive Metastore Server

#启动hiveserver服务
~ bin/hive --service hiveserver &
Starting Hive Thrift Server

#启动hive客户端
~ bin/hive shell
Logging initialized using configuration in file:/root/hive-0.9.0/conf/hive-log4j.properties
Hive history file=/tmp/root/hive_job_log_root_201211141845_1864939641.txt

hive> show tables
OK

 

你可能感兴趣的:(Hive安装及配置)