一,目标
1、部署hive
二、前提条件
1、环境为centos 6.5
2、已经部署了hadoop伪分布式
3、安装了hbase
4、安装了mysql 5.6.33
三、部署步骤
1、下载安装包
下载hive http://mirrors.hust.edu.cn/apache/ 得到apache-hive-2.1.0-bin.tar.gz ,放到该目录下 /home/soft/hive
2、 在mysql上创建 hive用户, 创建hive用户,数据库等
<span style="font-family:Microsoft YaHei;font-size:12px;">CREATE USER 'hive'@'archive.cloudera.com' IDENTIFIED BY 'hive'; GRANT ALL ON *.* TO 'hive'@'archive.cloudera.com'; create database hive; grant all on hive.* to hive@'%' identified by 'hive'; grant all on hive.* to hive@'archive.cloudera.com' identified by 'hive'; flush privileges; </span>
退出mysql
进入/home/soft/hive目录,解压hive安装包 tar -zxvf apache-hive-2.1.0-bin.tar.gz
进入/opt/hadoop目录, mv /home/soft/hive/apache-hive-2.1.0-bin ./hive
2) 添加环境变量
vi /etc/profile<span style="font-family:Microsoft YaHei;font-size:12px;"><?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost: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>hive</value> <description>username to use against metastore database</description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>hive</value> <description>password to use against metastore database</description> </property> <property> <name>hive.metastore.local</name> <value>true</value> <description></description> </property> <property> <name>datanucleus.readOnlyDatastore</name> <value>false</value> </property> <property> <name>datanucleus.fixedDatastore</name> <value>false</value> </property> <property> <name>datanucleus.autoCreateSchema</name> <value>true</value> </property> <property> <name>datanucleus.autoCreateTables</name> <value>true</value> </property> <property> <name>datanucleus.autoCreateColumns</name> <value>true</value> </property> </configuration> </span>
5)配置hive-env.sh文件,指定HADOOP_HOME
HADOOP_HOME=/usr/local/hadoop
<span style="font-family:Microsoft YaHei;font-size:12px;">[root@archive lib]# pwd /opt/hadoop/hive/lib [root@archive lib]# [root@archive lib]# cp /home/soft/hive/*jar . [root@archive lib]# [root@archive lib]# ls my* mysql-connector-java-5.1.6-bin.jar [root@archive lib]# </span>7)把hive lib目录里面的jline-2.12.jar拷贝到hadoop相应的目录下,替代jline-0.9.94.jar,否则启动会报错
<span style="font-family:Microsoft YaHei;font-size:12px;">[root@archive lib]# pwd /opt/hadoop/hive/lib [root@archive lib]# cp jline-2.12.jar /opt/hadoop/hadoop-2.6.4/share/hadoop/yarn/lib</span>
1) 启动 hive server
启动正常,可以通过 jps 命令,显示
[root@archive hive]# jps
4944 DataNode
16356 RunJar
5105 SecondaryNameNode
5257 ResourceManager
18329 Jps
5353 NodeManager
4822 NameNode
注意,多了RunJar
现在我们可以用hive登录进行操作: 输入hive 回车
五:启动异常和处理
1) 启动报异常,如图
这个是因为之前
<span style="font-family:Microsoft YaHei;font-size:12px;">jdbc:mysql://192.168.136.144:3306/hive?createDatabaseIfNotExist=true修改后</span>
<span style="font-family:Microsoft YaHei;font-size:12px;"> </span>
2) 启动异常二: 无法连接mysql
解决: hive 版本太高,降级到2.0.0 问题解决
3)hive连接mysql 被拒绝