部分文章内容为公开资料查询整理,原文出处可能未标注,如有侵权,请联系我,谢谢。邮箱地址:gnivor@163.com ►►►需要气球么?请点击我吧!

Hive笔记--配置以及遇到的问题

ubuntu安装mysql  http://www.2cto.com/database/201401/273423.html

Hive安装:
http://www.aboutyun.com/forum.php?mod=viewthread&tid=6902  (aboutyun)
http://wangqiaowqo.iteye.com/blog/1618565
http://www.it165.net/admin/html/201403/2528.html   (解释详细)
http://www.linuxidc.com/Linux/2014-07/104302p2.htm
http://gaoxianwei.iteye.com/blog/2028401
http://blog.csdn.net/babydavic/article/details/26616309   (原则上可以安装在任一节点)

Hive解释,最后附链接
http://www.csdn.net/article/2014-01-07/2818052-about-hive

 

Hive兼容性问题:http://blog.csdn.net/u014729236/article/details/44963551

 

1. 在mysql里创建hive用户,并赋予其足够权限
[root@node01 mysql]# mysql -u root -p
Enter password:

mysql> create user 'hive' identified by 'hive';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to 'hive' with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

 

2. 下载mysql连接java的驱动 并拷入hive home的lib下
mv mysql-connector-java-5.1.24-bin.jar /usr/local/hadoop/hive-1.1.1/lib


3. 修改环境变量,把Hive加到PATH
/etc/profile
export HIVE_HOME=/usr/local/hadoop/hive-1.1.1
export PATH=$PATH:$HIVE_HOME/bin


4. 修改hive-env.sh
[hadoop@node01 conf]$ cp hive-env.sh.template hive-env.sh
[hadoop@node01 conf]$ vi hive-env.sh


5. Hive配置文件修改:

<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://localhost: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>
View Code

 

6.启动 bin>  ./hive
--------------------------------------

 

Hive Web接口:链接 localhost:9999/hwi/

启动hive的时候 添加参数:

./hive --service hwi 

默认配置无法启动web接口

http://www.open-open.com/lib/view/open1433318284791.html
http://blog.csdn.net/wulantian/article/details/38271803
解决方法:下载源码,将web页面打包,放到./hive/lib中

tar xf apache-hive-1.1.1-src.tar.gz
cd apache-hive-1.1.1-src/hwi
jar cfM hive-hwi-1.1.1.war -C web .

将hive-hwi-1.1.1.war放到lib中
然后修改配置文件:

hive-site.xml

<property>
    <name>hive.hwi.war.file</name>
    <value>lib/hive-hwi-1.1.1.war</value>
    <description>This sets the path to the HWI war file, relative to ${HIVE_HOME}. </description>
</property>
<property>
    <name>hive.hwi.listen.host</name>
    <value>0.0.0.0</value>
    <description>This is the host address the Hive Web Interface will listen on</description>
</property>
<property>
    <name>hive.hwi.listen.port</name>
    <value>9999</value>
    <description>This is the port the Hive Web Interface will listen on</description>
</property>
View Code

启动即可 ./hive --service hwi

 

 

错误1:
Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D

Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
        at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:472)
        at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:671)
        at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:615)
        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.run(RunJar.java:221)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
        at org.apache.hadoop.fs.Path.initialize(Path.java:206)
        at org.apache.hadoop.fs.Path.<init>(Path.java:172)
        at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:515)
        at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:458)
        ... 8 more
Caused by: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
        at java.net.URI.checkPath(URI.java:1804)
        at java.net.URI.<init>(URI.java:752)
        at org.apache.hadoop.fs.Path.initialize(Path.java:203)
        ... 11 more
View Code

解决方案:替换${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D为绝对路径

vim conf/hive-site.xml

  <property>
    <name>hive.exec.local.scratchdir</name>
    <value>/tmp/hive</value>
    <description>Local scratch space for Hive jobs</description>
  </property>
  <property>
    <name>hive.downloaded.resources.dir</name>
    <value>/tmp/${hive.session.id}_resources</value>
    <description>Temporary local directory for added resources in the remote file system.</description>
  </property>
  <property>
    <name>hive.querylog.location</name>
    <value>/tmp/hive</value>
    <description>Location of Hive run time structured log file</description>
  </property>
<property>
    <name>hive.server2.logging.operation.log.location</name>
    <value>/tmp/hive/operation_logs</value>
    <description>Top level directory where operation logs are stored if logging functionality is enabled</description>
  </property>
View Code

 

错误2:

Hive启动时,遇到java.net.URISyntaxException: Relative path in absolute URI

解决方案如下:
1.查看hive-site.xml配置,会看到配置值含有"system:java.io.tmpdir"的配置项
2.新建文件夹/home/grid/hive-0.14.0-bin/iotmp
3.将含有"system:java.io.tmpdir"的配置项的值修改为如上地址
启动hive,成功!

 

错误3:
Hive启动时,遇到 [ERROR] Terminal initialization failed; falling back to unsupported

参考:http://blog.csdn.net/olfisher/article/details/48730229 

Logging initialized using configuration in jar:file:/hive/apache-hive-1.1.0-bin/lib/hive-common-1.1.0.jar!/hive-log4j.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/hadoop-2.5.2/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/hive/apache-hive-1.1.0-bin/lib/hive-jdbc-1.1.0-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
[ERROR] Terminal initialization failed; falling back to unsupported
java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
        at jline.TerminalFactory.create(TerminalFactory.java:101)
        at jline.TerminalFactory.get(TerminalFactory.java:158)
        at jline.console.ConsoleReader.<init>(ConsoleReader.java:229)
        at jline.console.ConsoleReader.<init>(ConsoleReader.java:221)
        at jline.console.ConsoleReader.<init>(ConsoleReader.java:209)
        at org.apache.hadoop.hive.cli.CliDriver.getConsoleReader(CliDriver.java:773)
        at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:715)
        at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:675)
        at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:615)
        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:212)
View Code

原因是hadoop目录下存在老版本jline:

/hadoop-2.5.2/share/hadoop/yarn/lib:
-rw-r--r-- 1 root root   87325 Mar 10 18:10 jline-0.9.94.jar
 
解决方法是:
将hive下的新版本jline的JAR包拷贝到hadoop下:
cp /hive/apache-hive-1.1.0-bin/lib/jline-2.12.jar ./hadoop-2.5.2/share/hadoop/yarn/lib
修改原来的jar包名,这样默认就使用新的了。
-rw-r--r-- 1 root root   87325 Mar 10 18:10 jline-0.9.94.jar.bak
-rw-r--r-- 1 root root  213854 Mar 11 22:22 jline-2.12.jar
 
hive cli启动成功:

root@ubuntu:/hive# hive

 

posted @ 2015-11-29 19:51  流了个火  阅读(1485)  评论(0编辑  收藏  举报
►►►需要气球么?请点击我吧!►►►
View My Stats