hive安装与mysql对接

Hive只在一个节点上安装即可


必须有hadoop的支持


1.上传tar包
2.解压
tar -zxvf hive-0.9.0.tar.gz
3.配置mysql metastore(切换到root用户)
配置HIVE_HOME环境变量
rpm -qa | grep mysql
rpm -e mysql-libs-5.1.66-2.el6_3.i686 --nodeps
rpm -ivh MySQL-server-5.1.73-1.glibc23.i386.rpm 
rpm -ivh MySQL-client-5.1.73-1.glibc23.i386.rpm 
修改mysql的密码
/usr/bin/mysql_secure_installation
(注意:删除匿名用户,允许用户远程连接)
登陆mysql
mysql -u root -p


4.配置hive
cp hive-default.xml.template hive-site.xml 
修改hive-site.xml(删除所有内容,只留一个<property></property>)
添加如下内容:
<property>
 <name>javax.jdo.option.ConnectionURL</name>
 <value>jdbc:mysql://master: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>root</value>
 <description>username to use against metastore database</description>
</property>


<property>
 <name>javax.jdo.option.ConnectionPassword</name>
 <value>123456</value>
 <description>password to use against metastore database</description>
</property>

5.安装hive和mysq完成后,将mysql的连接jar包拷贝到$HIVE_HOME/lib目录下
如果出现没有权限的问题,在mysql授权(在安装mysql的机器上执行)
mysql -u root -p
#(执行下面的语句  *.*:所有库下的所有表   %:任何IP地址或主机都可以连接)
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123' WITH GRANT OPTION;

FLUSH PRIVILEGES;


6.出现的常见错误

    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)
     
    原因是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:
    -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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值