Hive安装 使用主机(win7)上的mysql数据库

Hive安装
    mysql使用主机(win7)上的mysql数据库,启动后,要关闭360和win7自带的防火墙,确保在虚拟机里能拼通主机**************************************************
    D:\server\mysql-5.0.16-win32\bin
        grant all on *.* to  hive@'localhost'  identified by 'hive' with grant  option;
        create database hive character set 'UTF8'; 
    下载地址: http://archive.apache.org/dist/hive/hive-0.8.1/
        拷贝:cp /mnt/hgfs/share_files/hive-0.8.1.tar.gz ~
        解压:tar -zxvf hive-0.8.1.tar.gz 
    安装配置hive
    (1)修改/home/grid/hive-0.8.1/bin/hive-config.sh
        在末尾添加:
        [grid@h1 bin]$ vi hive-config.sh
            export JAVA_HOME=/usr/java/jdk1.6.0_29/
            export HIVE_HOME=/home/grid/hive-0.8.1
            export HADOOP_HOME=/home/grid/hadoop-0.20.2 
    (2) 根据hive-default.xml.template复制hive-site.xml
        [grid@h1 conf]$ cp hive-default.xml.template hive-site.xml 
    (3) 修改配置文件hive-site.xml:
        临时文件目录,默认值是/tmp/hive-${user.name}
        数据目录,默认值是/user/hive/warehouse
            
            hive.exec.scratchdir
            /home/grid/hive-tmp
             
            
            hive.metastore.warehouse.dir
            /home/grid/hive-data
             
              
            javax.jdo.option.ConnectionURL  
            jdbc:mysql://192.168.1.100:3306/hive?createDatabaseIfNotExist=true
             
              
            javax.jdo.option.ConnectionDriverName  
            com.mysql.jdbc.Driver
             
              
            javax.jdo.option.ConnectionUserName  
            hive 
            
              
            javax.jdo.option.ConnectionPassword  

            hive 



(4)配置log4j
        [grid@h1 conf]$ cp hive-log4j.properties.template hive-log4j.properties 

    (5)创建临时文件目录、数据目录
        [grid@h1 ~]$ mkdir hive-tmp
        [grid@h1 ~]$ mkdir hive-data 

    (6)把MySQL的JDBC驱动mysql-connector-java-5.0.8.jar 复制到Hive的lib目录下。(注:发现无法直接拷贝到/home/grid/hive-0.8.1/lib目录下,奇怪)
        [grid@h1 ~]$ cp /mnt/hgfs/share_files/mysql-connector-java-5.0.8.jar ~
        [grid@h1 ~]$ cp mysql-connector-java-5.0.8.jar /home/grid/hive-0.8.1/lib
        [grid@h1 ~]$ rm mysql*.jar 

    (7)启动
        [grid@h1 ~]$ hive-0.8.1/bin/hive 
        出现问题1:
            Hive requires Hadoop 0.20.x (x >= 1).
            'hadoop version' returned:
            Hadoop 0.20-append-r1056497 Subversionhttps://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-append -r 1056491 Compiled by stack on Fri Jan 7 20:43:30 UTC 2011 
        问题解决1:出现这个问题是因为安装hbase的时候,我们用hbase的jar包覆盖hadoop的jar包(老师的课程里说的是用hadoop的包覆盖hbase的包,但这样运行时会报错) 

        [grid@h1 ~]$ hadoop-0.20.2/bin/stop-all.sh
        [grid@h1 ~]$ cd hadoop-0.20.2
        [grid@h1 hadoop-0.20.2]$ rm hadoop-0.20.2-core.jar
        //用原来备份的文件还原(如果想运行hbase,又要用hbase的jar来覆盖这个jar)
        [grid@h1 hadoop-0.20.2]$ cp hadoop-0.20.2-core.sav hadoop-0.20.2-core.jar
        //要同步到其他机器
        [root@h1 hadoop-0.20.2]# scp hadoop-0.20.2-core.jar grid@h2:/home/grid/hadoop-0.20.2/hadoop-0.20.2-core.jar
        [root@h1 hadoop-0.20.2]# scp hadoop-0.20.2-core.jar grid@h3:/home/grid/hadoop-0.20.2/hadoop-0.20.2-core.jar 

        问题解决2:
            在mysql里运行:grant all on *.* to hive@'192.168.1.104' identified by 'hive' with grant option;
            192.168.1.104是安装hive的机器ip 
  这个是因win7自带防火墙问题,连不上mysql 



   问题3
        hive> show tables;   
        FAILED: Error in metadata: MetaException(message:Got exception: javax.jdo.JDODataStoreException An exception was thrown while adding/validating class(es) : Can't create table '.\hive\sd_params.frm' (errno: 139)
        java.sql.SQLException: Can't create table '.\hive\sd_params.frm' (errno: 139)
            at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
            at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
            at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
            at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723) 
        问题解决3:(是数据库编码引起的)
            drop database hive;
            create database hive character set 'latin1'; 
        建表
        hive> CREATE TABLE pokes (foo INT, bar STRING); 
            OK
            Time taken: 4.357 seconds
        其他操作见:Hive常用的SQL命令操作.txt 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值