hive 安装 max key length is 767 bytes

hive安装,并使用mysql数据库为元数据库

使用hive-0.8.0

安装hive前,事先安装mysql用于保存元数据,安装ant用于启用HWI

1、在namenode安装hive。下载并解压hive文件后,进入hive/bin/下,配置hive-config.sh文件:

exportHADOOP_HOME=/home/hadoop/hadoop-0.20.203.0

exportPATH=.:$HADOOP_HOME/bin:$PATH

exportHIVE_HOME=/home/hadoop/hive-0.8.0

exportPATH=$HIVE_HOME/bin:$PATH

exportJAVA_HOME=/usr/java/jdk1.7.0_01

exportJRE_HOME=/usr/java/jdk1.7.0_01/jre

exportCLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH

exportPATH=.:$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

2、将hive加入到环境变量中:

exportHIVE_HOME=/home/hadoop/hive-0.8.0

3、在mysql中创建hadoop的用户,密码也为hadoop,并创建元数据库:

mysql

mysql>CREATEUSER'hadoop'@'master'IDENTIFIEDBY'hadoop';

mysql>GRANTALLPRIVILEGESON*.*TO'hadoop'@'master'WITHGRANTOPTION;

mysql>exit

4、下载文件mysql-connector-java-5.1.15-bin.jar,保存到lib文件目录下。

否则出现错误:

hive>showtables;

FAILED:Errorinmetadata:javax.jdo.JDOFatalInternalException:Errorcreatingtransactionalconnectionfactory

NestedThrowables:

java.lang.reflect.InvocationTargetException

FAILED:ExecutionError,returncode1fromorg.apache.hadoop.hive.ql.exec.DDLTask

5、在hive/conf/文件夹中,新建hive-site.xml文件,并复制进hive-default.xml.template的全部内容,作以下修改:

(使用mysql为元数据库)

<property>

<name>hive.metastore.local</name>

<value>true</value>

</property>

<property>

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

<!--<value>jdbc:derby:;databaseName=metastore_db;create=true</value>-->

<value>jdbc:mysql://master:3306/metastore</value>

<description>JDBCconnectstringforaJDBCmetastore</description>

</property>

<property>

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

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

<description>DriverclassnameforaJDBCmetastore</description>

</property>

<property>

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

<value>hadoop</value>

<description>usernametouseagainstmetastoredatabase</description>

</property>

<property>

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

<value>hadoop</value>

<description>passwordtouseagainstmetastoredatabase</description>

</property>

6、在hdfs中创建几个目录

$HADOOP_HOME/bin/hadoopfs-mkdir/tmp

$HADOOP_HOME/bin/hadoopfs-mkdir/user/hive/warehouse

$HADOOP_HOME/bin/hadoopfs-chmodg+w/tmp

$HADOOP_HOME/bin/hadoopfs-chmodg+w/user/hive/warehouse

7、启动hive

启动hive:$HIVE_HOME/bin/hive

8、启动hwi界面:

exportANT_LIB=/opt/ant/lib

bin/hive--servicehwi

bin/hive--servicehwi--help

9、在hive命令行模式下,使用showtables;测试mysql连接是否正确。

用mysql做元数据

alterdatabasehivecharactersetlatin1

这样才不会报maxkeylengthis767bytes

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:Specifiedkeywastoolong;maxkeylengthis767bytes

这个异常

相关推荐