1、安装MySQL,此处略
2、在MySQL上创建数据库,并创建Hive需要的相关表
创建表报错了,应该是路径不对
在次执行就没有报错了
3、配置hive-env.sh
4、配置hive-site.xml
5、下载MySQL连接的JAR文件,并放在lib目录
6、复制Hbase和Zookeeper的JAR文件到Hive的lib目录
7、启动Hive报错解决方法
7.1 报错Exception in thread "main" java .lang .NoSuchMethodError : org .apache .hadoop .conf .Configuration .unset (Ljava/lang/String ; )
更改hive-env.sh
7.2 报错Exception
in thread
"main" java
.lang
.RuntimeException
: java
.lang
.RuntimeException
: The root scratch dir
: /tmp/hive on HDFS should be writable
此报错是说在hdfs里没有/tmp/hive目录,这是默认值,可更改hive-site.xml配置
7.3 报错Exception
in thread
"main" java
.lang
.RuntimeException
: java
.lang
.RuntimeException
: The root scratch dir
: /data/tmp on HDFS should be writable
此报错是/data/tmp目录没权限
8、正常启动Hive
2、在MySQL上创建数据库,并创建Hive需要的相关表
- grid@master1:~$ mysql -uroot -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 3
- Server version: 5.6.19-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)
-
- Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
-
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
-
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
-
- mysql> create database metastore;
- Query OK, 1 row affected (0.00 sec)
-
- mysql> use metastore
- Database changed
-
- mysql> source /usr/local/hive/scripts/metastore/upgrade/mysql/hive-schema-1.2.0.mysql.sql
-
- Query OK, 0 rows affected (0.01 sec)
-
- Query OK, 0 rows affected (0.01 sec)
-
- Query OK, 0 rows affected (0.01 sec)
-
- ERROR:
- Failed to open file 'hive-txn-schema-0.13.0.mysql.sql', error: 2
- Query OK, 1 row affected (0.01 sec)
- grid@master1:~$ cd /usr/local/hive/scripts/metastore/upgrade/mysql
3、配置hive-env.sh
- HADOOP_HOME=/usr/local/hadoop
- grid@master1:/usr/local/hive/conf$ cat hive-site.xml
- <?xml version="1.0"?>
- <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
- <configuration>
- <property>
- <name>javax.jdo.option.ConnectionURL</name>
- <value>jdbc:mysql://master1:3306/metastore</value>
- </property>
-
- <property>
- <name>javax.jdo.option.ConnectionDriverName</name>
- <value>com.mysql.jdbc.Driver</value>
- </property>
-
- <property>
- <name>javax.jdo.option.ConnectionUserName</name>
- <value>root</value>
- </property>
-
- <property>
- <name>javax.jdo.option.ConnectionPassword</name>
- <value>111</value>
- </property>
-
- <property>
- <name>datanucleus.autoCreateSchema</name>
- <value>false</value>
- </property>
-
- <property>
- <name>datanucleus.fixedDatastore</name>
- <value>true</value>
- </property>
-
- <property>
- <name>hbase.zookeeper.quorum</name>
- <value>master1.slave1,slave2,salve3</value>
- </property>
-
- </configuration>
- grid@master1:~$ mv mysql-connector-java-5.1.36.jar /usr/local/hive/lib/
- grid@master1:/usr/local/hive/lib$ cp /usr/local/hbase/hbase-0.94.27.jar .
-
- grid@master1:/usr/local/hive/lib$ cp /usr/local/zookeeper/zookeeper-3.4.5.jar .
7.1 报错Exception in thread "main" java .lang .NoSuchMethodError : org .apache .hadoop .conf .Configuration .unset (Ljava/lang/String ; )
- grid@master1:/usr/local/hive/conf$ hive
-
- Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-1.2.1.jar!/hive-log4j.properties
- Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.conf.Configuration.unset(Ljava/lang/String;)V
- at org.apache.hadoop.hive.ql.exec.Utilities.resetUmaskInConf(Utilities.java:3694)
- at org.apache.hadoop.hive.ql.exec.Utilities.createDirsWithPermission(Utilities.java:3679)
- at org.apache.hadoop.hive.ql.session.SessionState.createRootHDFSDir(SessionState.java:597)
- at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:554)
- at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:508)
- at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:677)
- at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.lang.reflect.Method.invoke(Method.java:606)
- at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
- export HIVE_CONF_DIR=/usr/local/hive/conf
-
- export HIVE_AUX_JARS_PATH=/usr/local/hive/lib
- grid@master1:/usr/local/hive/conf$ hive
-
- Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-1.2.1.jar!/hive-log4j.properties
- 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
- at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)
- at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:677)
- at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.lang.reflect.Method.invoke(Method.java:606)
- at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
- Caused by: java.lang.RuntimeException: The root scratch dir: /tmp/hive on HDFS should be writable. Current permissions are: rwx--x--x
- at org.apache.hadoop.hive.ql.session.SessionState.createRootHDFSDir(SessionState.java:612)
- at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:554)
- at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:508)
- ... 7 more
- <property>
- <name>hive.metastore.warehouse.dir</name>
- <value>/data/hive/wh</value>
- </property>
-
- <property>
- <name>hive.exec.scratchdir</name>
- <value>/data/tmp</value>
- </property>
- grid@master1:/usr/local/hive/conf$ hive
-
- Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-1.2.1.jar!/hive-log4j.properties
- 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
- at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)
- at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:677)
- at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.lang.reflect.Method.invoke(Method.java:606)
- at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
- Caused by: java.lang.RuntimeException: The root scratch dir: /data/tmp on HDFS should be writable. Current permissions are: rwxr-xr-x
- at org.apache.hadoop.hive.ql.session.SessionState.createRootHDFSDir(SessionState.java:612)
- at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:554)
- at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:508)
- ... 7 more
- grid@master1:/usr/local/hive/conf$ hadoop fs -chmod 777 /data/tmp
- grid@master1:/usr/local/hive/conf$ hive
-
- Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-1.2.1.jar!/hive-log4j.properties
- hive>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12219480/viewspace-1795661/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/12219480/viewspace-1795661/