ITPub博客

首页 > 大数据 > Hadoop > hive在centos上安装

hive在centos上安装

原创 Hadoop 作者:suifeng2316 时间:2015-04-16 18:30:30 0 删除 编辑
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/,如需转载,请注明出处,否则将追究法律责任。

上一篇: sqoop简单使用
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2011-09-14

  • 博文量
    48
  • 访问量
    178813