hive在centos上安裝

suifeng2316發表於2015-04-16
1,解壓
tar -zxvf apache-hive-1.1.0-bin.tar.gz 
mv apache-hive-1.1.0-bin /usr/local/hive1.1
chown -R hadoop:hadoop hive1.1/
2,匯入環境變數
export HIVE_HOME=/usr/local/hive1.1
export PATH=$HIVE_HOME/bin:$PATH
3,建立目錄
必須建立 /tmp 和 /user/hive/warehouse,而且相對於HDFS,賦予g+w許可權
 $HADOOP_HOME/bin/hadoop fs -mkdir       /tmp
 $HADOOP_HOME/bin/hadoop fs -mkdir       /user/hive/warehouse
 $HADOOP_HOME/bin/hadoop fs -chmod g+w   /tmp
 $HADOOP_HOME/bin/hadoop fs -chmod g+w   /user/hive/warehouse

[hadoop@dbsrv1 ~]$ hive
Logging initialized using configuration in jar:file:/usr/local/hive1.1/lib/hive-common-1.1.0.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: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.main(RunJar.java:160)
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:557)
        at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:506)
        at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:458)
        ... 7 more
解決辦法:
[hadoop@dbsrv1 tmp]$ hadoop fs -chmod -R 777 /tmp
--hive配置mysql資料庫儲存資料來源
cp hive-default.xml.template hive-site.xml
cp hive-log4j.properties.template hive-log4j.properties
--登入mysql新建使用者,建立資料庫 
mysql> create database hive default character set gbk;
grant all privileges on hive.* to 'zhong'@'%' identified by  'zhong#123' with grant option;
修改hive-default.xml檔案

  javax.jdo.option.ConnectionURL
  jdbc:mysql://192.168.1.151:3306/hive?createDatabaseIfNotExist=true
  JDBC connect string for a JDBC metastore


  javax.jdo.option.ConnectionDriverName
  com.mysql.jdbc.Driver
  Driver class name for a JDBC metastore

  javax.jdo.option.ConnectionUserName
  zhong
  username to use against metastore database


  javax.jdo.option.ConnectionPassword
  zhong#123
  password to use against metastore database


  hive.metastore.local
  true
  controls whether to connect to remove metastore server or open a new metastore server in Hive Client JVM

--上傳mysql的jdbc庫到hive/lib
啟動hive
#啟動metastore服務
~ bin/hive --service metastore &
Starting Hive Metastore Server
#啟動hiveserver服務
~ bin/hive --service hiveserver &
Starting Hive Thrift Server
#啟動hive客戶端
~ bin/hive shell
hive> show tables


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23073818/viewspace-1580604/,如需轉載,請註明出處,否則將追究法律責任。

相關文章