大概记录一下hive安装步骤

1. rpm安装mysql

groupadd mysql

useradd -g mysql mysql

rpm -ivh MySQL-server-5.5.24-1.rhel5.i386.rpm 

rpm -ivh MySQL-client-5.5.24-1.rhel5.i386.rpm 

启动mysql:/etc/init.d/mysql start

添加系统启动:/sbin/chkconfig --add mysql

create database hive;

grant all on hive.* to hive@'%' identified by 'hive';

flush privileges;

2. 为hive建立相关的hdfs目录:

hadoop fs -mkdir /user/hive/

hadoop fs -chmod -R a+w /user/hive/

3. 安装配置hive:

tar -xzvf hive-0.7.1-bin.tar.gz

ln -s hive-0.7.1-bin hive-current

cd hive-current/conf

vi hive-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>

<property>
  <name>hive.exec.drop.ignorenonexistent</name>
  <value>true</value>
  <description>
    Do not report an error if DROP TABLE/VIEW specifies a non-existent table/view
  </description>
</property>

<property>
  <name>hive.metastore.local</name>
  <value>true</value>
  <description>controls whether to connect to remove metastore server or open a new metastore server in Hive Client JVM</description>
</property>

<property>
  <name>hive.exec.scratchdir</name>
  <value>/user/hive/${user.name}/meta/hive-exec</value>
  <description>Scratch space for Hive jobs</description>
</property>

<property>
  <name>hive.metastore.warehouse.dir</name>
  <value>/user/hive/${user.name}/meta/warehouse</value>
  <description>location of default database for the warehouse</description>
</property>

<property>
  <name>hive.exec.compress.output</name>
  <value>true</value>
  <description> This controls whether the final outputs of a query (to a local/hdfs file or a hive table) is compressed. The compression codec and other options are determined from hadoop config variables mapred.output.compress* </description>
</property>

<property>
  <name>hive.exec.compress.intermediate</name>
  <value>true</value>
  <description> This controls whether intermediate files produced by hive between multiple map-reduce jobs are compressed. The compression codec and other options are determined from hadoop config variables mapred.output.compress* </description>
</property>


<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://192.168.1.113:3306/hive?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.stats.dbclass</name>
  <value>jdbc:mysql</value>
  <description>The default database that stores temporary hive statistics.</description>
</property>

<property>
  <name>hive.stats.jdbcdriver</name>
  <value>com.mysql.jdbc.Driver</value>
  <description>The JDBC driver for the database that stores temporary hive statistics.</description>
</property>

<property>
  <name>hive.stats.dbconnectionstring</name>
  <value>jdbc:mysql://192.168.1.113:3306/HiveStats?createDatabaseIfNotExist=true&amp;user=hive&amp;password=hive</value>
  <description>The default connection string for the database that stores temporary hive statistics.</description>
</property>

<!-- -->
<property>
  <name>hive.cli.print.header</name>
  <value>false</value>
  <description>Whether to print the names of the columns in query output.</description>
</property>

</configuration>

4. 下载mysql-connector-java-5.0.3-bin.jar并放到hive-current/lib目录下;

注意:hive的日志一般在/tmp/${user.name}/hive.log中

5。 初始化的时候需要注意这几个参数的配置

<property>
<name>datanucleus.fixedDatastore</name>
<value>false</value> 
</property>

<property>
<name>datanucleus.autoCreateSchema</name>
<value>true</value>
</property>

<property>
<name>datanucleus.autoCreateTables</name>
<value>true</value>
</property>

<property>
<name>datanucleus.autoCreateColumns</name>
<value>true</value>
</property>

否则会报错:

FAILED: Hive Internal Error: org.apache.hadoop.hive.ql.metadata.HiveException(javax.jdo.JDODataStoreException: Required table missing : "`DBS`" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.autoCreateTables"
NestedThrowables:
org.datanucleus.store.rdbms.exceptions.MissingTableException: Required table missing : "`DBS`" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.autoCreateTables")
org.apache.hadoop.hive.ql.metadata.HiveException: javax.jdo.JDODataStoreException: Required table missing : "`DBS`" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.autoCreateTables"
NestedThrowables:
org.datanucleus.store.rdbms.exceptions.MissingTableException: Required table missing : "`DBS`" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.autoCreateTables"
        at org.apache.hadoop.hive.ql.metadata.Hive.getDatabase(Hive.java:1028)
        at org.apache.hadoop.hive.ql.Driver.doAuthorization(Driver.java:433)
        at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:393)
        at org.apache.hadoop.hive.ql.Driver.run(Driver.java:736)
        at org.apache.hadoop.hive.cli.NewCliDriver.processCmd(NewCliDriver.java:166)
        at org.apache.hadoop.hive.cli.NewCliDriver.processLine(NewCliDriver.java:243)
        at org.apache.hadoop.hive.cli.NewCliDriver.main(NewCliDriver.java:469)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:197)
Caused by: javax.jdo.JDODataStoreException: Required table missing : "`DBS`" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.autoCreateTables"
NestedThrowables:

相关推荐