今天在hadoop2.6.0的集群上安装了hive-1.1.0,感觉hive就是一个驱动层,只是连了连数据库,连了连hadoop
1.简述
整个安装步骤主要分为三步
- myslq准备
- 安装hive
本次安装的操作系统环境为centos6.8
hadoop版本为2.6.0
hive版本为1.1.0
2. 安装过程
1. mysql准备
hive使用mysql作为元数据管理的系统,所以必须先安装mysql
可以在mysql中先创建一个库给hive使用,我这里创建的库叫query_hive
2. 安装hive
注意,安装hive之前要先安装hadoop,我这里前面装过hadoop,就不再重复安装了
1. 下载hive-1.1.0
老版本的hive可以在这里找到
wget https://archive.apache.org/dist/hive/hive-1.1.0/apache-hive-1.1.0-bin.tar.gz
tar -xzvf apache-hive-1.1.0-bin.tar.gz -C /usr/local
mv apache-hive-1.1.0-bin hive
2. 配置环境变量
vim /etc/profile
export HIVE_HOME=/usr/local/hive
export PATH=$PATH:$HIVE_HOME/bin
3. 创建hive-site.xml并配置
cd /usr/local/hive/conf
touch hive-site.xml
添加如下内容
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://10.76.4.113:3306/query_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>query_hive_wr</value>
<description>Username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hVLjcAiLUrxJsylu</value>
<description>password to use against metastore database</description>
</property>
</configuration>
4. 初始化数据库
schematool -dbType mysql -initSchema
#返回
Metastore connection URL: jdbc:mysql://10.76.4.113:3306/query_hive?createDatabaseIfNotExist=true
Metastore Connection Driver : com.mysql.jdbc.Driver
Metastore connection User: query_hive_wr
Starting metastore schema initialization to 1.1.0
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to load driver
init Failed
说明失败了,这个是因为缺少mysql的jar
cd /usr/local/hive/lib
wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.36/mysql-connector-java-5.1.36.jar
再执行
schematool -dbType mysql -initSchema
报错
[root@master bin]# ./hive
[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.setupConsoleReader(CliDriver.java:787)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:721)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
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.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
这个是因为hive中的/user/local/hive/lib/jline-2.12.jar
和hadoop中的的/usr/local/hadoop/share/hadoop/yarn/lib/jline-0.9.94.jar
版本冲突了,
使用高版本的替换低版本的即可
schematool -dbType mysql -initSchema
# 返回
Metastore connection URL: jdbc:mysql://10.76.4.113:3306/query_hive?createDatabaseIfNotExist=true
Metastore Connection Driver : com.mysql.jdbc.Driver
Metastore connection User: query_hive_wr
Starting metastore schema initialization to 1.1.0
Initialization script hive-schema-1.1.0.mysql.sql
Initialization script completed
schemaTool completed
终于成功