sudo apt-get install mysql-server mysql-client
create database hive;
create user 'hive'@'%' identified by 'hive';
grant all on hive.* to hive@'%' identified by 'hive';
flush privileges;
2.安装Hive
1). 官网下载hive安装包,并解压。
2).hive配置信息,(hive仅需要在master节点配置即可)
我安装在根目录的software下
tg@master:/software$ ls
apache-hive-1.1.1-bin hadoop-2.6.4 hbase-1.2.1-bin.tar.gz zookeeper-3.4.8
apache-hive-1.1.1-bin.tar.gz hbase-1.2.1 jdk1.7.0_80 zookeeper-3.4.8.tar.gz
tg@master:/software$ cd apache-hive-1.1.1-bin/
tg@master:/software/apache-hive-1.1.1-bin$ cd bin
tg@master:/software/apache-hive-1.1.1-bin/bin$ sudo gedit hive-config.sh
在最后加三行
export JAVA_HOME=/software/jdk1.7.0_80
export HIVE_HOME=/software/apache-hive-1.1.1-bin
export HADOOP_HOME=/software/hadoop-2.6.4
export HIVE_HOME=/software/apache-hive-1.1.1-bin
export PATH=$HIVE_HOME/bin:$PATH
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://master:3306/hive?createDatabaseInfoNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
</property>
</configuration>
下载mysql-connector-java-5.0.6-bin.jar文件,并放到$HIVE_HOME/lib目录下
tg@master:/software/apache-hive-1.1.1-bin$ bin/hive
Logging initialized using configuration in jar:file:/software/apache-hive-1.1.1-bin/lib/hive-common-1.1.1.jar!/hive-log4j.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/software/hadoop-2.6.4/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/software/apache-hive-1.1.1-bin/lib/hive-jdbc-1.1.1-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)
如果报错了,解决办法:进入到hadoop安装目录下的share/hadoop/yarn下删除 jline的jar文件。再启动hive即可
tg@master:/software/apache-hive-1.1.1-bin$ bin/hive
Logging initialized using configuration in jar:file:/software/apache-hive-1.1.1-bin/lib/hive-common-1.1.1.jar!/hive-log4j.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/software/hadoop-2.6.4/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/software/apache-hive-1.1.1-bin/lib/hive-jdbc-1.1.1-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]
hive> create table tanggao (key string);
OK
Time taken: 1.414 seconds
hive> show tables;
OK
tanggao
test
Time taken: 0.142 seconds, Fetched: 2 row(s)
hive>