hive在centos上安装

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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/23073818/viewspace-1580604/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值