Hive安装

1、安装MySQL,此处略
2、在MySQL上创建数据库,并创建Hive需要的相关表
  1. grid@master1:~$ mysql -uroot -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 3
  5. Server version: 5.6.19-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)

  6. Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.

  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  11. mysql> create database metastore;
  12. Query OK, 1 row affected (0.00 sec)

  13. mysql> use metastore
  14. Database changed

  15. mysql> source /usr/local/hive/scripts/metastore/upgrade/mysql/hive-schema-1.2.0.mysql.sql

  16. Query OK, 0 rows affected (0.01 sec)

  17. Query OK, 0 rows affected (0.01 sec)

  18. Query OK, 0 rows affected (0.01 sec)

  19. ERROR:
  20. Failed to open file 'hive-txn-schema-0.13.0.mysql.sql', error: 2
  21. Query OK, 1 row affected (0.01 sec)
创建表报错了,应该是路径不对
  1. grid@master1:~$ cd /usr/local/hive/scripts/metastore/upgrade/mysql
在次执行就没有报错了
3、配置hive-env.sh
  1. HADOOP_HOME=/usr/local/hadoop
4、配置hive-site.xml
  1. grid@master1:/usr/local/hive/conf$ cat hive-site.xml
  2. <?xml version="1.0"?>
  3. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  4. <configuration>
  5.         <property>
  6.                 <name>javax.jdo.option.ConnectionURL</name>
  7.                 <value>jdbc:mysql://master1:3306/metastore</value>
  8.         </property>

  9.         <property>
  10.                 <name>javax.jdo.option.ConnectionDriverName</name>
  11.                 <value>com.mysql.jdbc.Driver</value>
  12.         </property>

  13.         <property>
  14.                 <name>javax.jdo.option.ConnectionUserName</name>
  15.                 <value>root</value>
  16.         </property>

  17.         <property>
  18.                 <name>javax.jdo.option.ConnectionPassword</name>
  19.                 <value>111</value>
  20.         </property>

  21.         <property>
  22.                 <name>datanucleus.autoCreateSchema</name>
  23.                 <value>false</value>
  24.         </property>

  25.         <property>
  26.                 <name>datanucleus.fixedDatastore</name>
  27.                 <value>true</value>
  28.         </property>

  29.         <property>
  30.                 <name>hbase.zookeeper.quorum</name>
  31.                 <value>master1.slave1,slave2,salve3</value>
  32.         </property>

  33. </configuration>
5、下载MySQL连接的JAR文件,并放在lib目录
  1. grid@master1:~$ mv mysql-connector-java-5.1.36.jar /usr/local/hive/lib/
6、复制Hbase和Zookeeper的JAR文件到Hive的lib目录
  1. grid@master1:/usr/local/hive/lib$ cp /usr/local/hbase/hbase-0.94.27.jar .

  2. grid@master1:/usr/local/hive/lib$ cp /usr/local/zookeeper/zookeeper-3.4.5.jar .
7、启动Hive报错解决方法
7.1 报错Exception in thread "main" java .lang .NoSuchMethodError : org .apache .hadoop .conf .Configuration .unset (Ljava/lang/String ; )
  1. grid@master1:/usr/local/hive/conf$ hive

  2. Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-1.2.1.jar!/hive-log4j.properties
  3. Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.conf.Configuration.unset(Ljava/lang/String;)V
  4.         at org.apache.hadoop.hive.ql.exec.Utilities.resetUmaskInConf(Utilities.java:3694)
  5.         at org.apache.hadoop.hive.ql.exec.Utilities.createDirsWithPermission(Utilities.java:3679)
  6.         at org.apache.hadoop.hive.ql.session.SessionState.createRootHDFSDir(SessionState.java:597)
  7.         at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:554)
  8.         at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:508)
  9.         at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:677)
  10.         at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
  11.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  12.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  13.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  14.         at java.lang.reflect.Method.invoke(Method.java:606)
  15.         at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
更改hive-env.sh
  1. export HIVE_CONF_DIR=/usr/local/hive/conf

  2. export HIVE_AUX_JARS_PATH=/usr/local/hive/lib
7.2 报错Exception in thread "main" java .lang .RuntimeException : java .lang .RuntimeException : The root scratch dir : /tmp/hive on HDFS should be writable
  1. grid@master1:/usr/local/hive/conf$ hive

  2. Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-1.2.1.jar!/hive-log4j.properties
  3. Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: The root scratch dir: /tmp/hive on HDFS should be writable. Current permissions are: rwx--x--x
  4.         at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)
  5.         at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:677)
  6.         at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
  7.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  8.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  9.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  10.         at java.lang.reflect.Method.invoke(Method.java:606)
  11.         at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
  12. Caused by: java.lang.RuntimeException: The root scratch dir: /tmp/hive on HDFS should be writable. Current permissions are: rwx--x--x
  13.         at org.apache.hadoop.hive.ql.session.SessionState.createRootHDFSDir(SessionState.java:612)
  14.         at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:554)
  15.         at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:508)
  16.         ... 7 more
此报错是说在hdfs里没有/tmp/hive目录,这是默认值,可更改hive-site.xml配置
  1. <property>
  2.     <name>hive.metastore.warehouse.dir</name>
  3.     <value>/data/hive/wh</value>
  4.   </property>

  5.   <property>
  6.     <name>hive.exec.scratchdir</name>
  7.     <value>/data/tmp</value>
  8.   </property>
7.3 报错Exception in thread "main" java .lang .RuntimeException : java .lang .RuntimeException : The root scratch dir : /data/tmp on HDFS should be writable
  1. grid@master1:/usr/local/hive/conf$ hive

  2. Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-1.2.1.jar!/hive-log4j.properties
  3. Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: The root scratch dir: /data/tmp on HDFS should be writable. Current permissions are: rwxr-xr-x
  4.         at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)
  5.         at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:677)
  6.         at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
  7.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  8.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  9.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  10.         at java.lang.reflect.Method.invoke(Method.java:606)
  11.         at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
  12. Caused by: java.lang.RuntimeException: The root scratch dir: /data/tmp on HDFS should be writable. Current permissions are: rwxr-xr-x
  13.         at org.apache.hadoop.hive.ql.session.SessionState.createRootHDFSDir(SessionState.java:612)
  14.         at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:554)
  15.         at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:508)
  16.         ... 7 more
此报错是/data/tmp目录没权限
  1. grid@master1:/usr/local/hive/conf$ hadoop fs -chmod 777 /data/tmp
8、正常启动Hive
  1. grid@master1:/usr/local/hive/conf$ hive

  2. Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-1.2.1.jar!/hive-log4j.properties
  3. hive>

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12219480/viewspace-1795661/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/12219480/viewspace-1795661/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值