hive安装有三种模式:
内嵌模式:元数据保持在内嵌的derby模式,只允许一个会话连接
本地独立模式:在本地安装Mysql,把元数据放到mySql内
远程模式:元数据放置在远程的Mysql数据库
本地独立模式
1.下载hive安装包
下载地址: http://hive.apache.org/downloads.html
2、将hive文件上传到HADOOP集群,并解压
将文件上传到:/root
解压: tar -zxvf apache-hive-1.2.1-bin.tar.gz -C /use/local
由于解压后文件名太长,可以利用软连接或者直接改文件名cd /use/local
ln -s apache-hive-1.2.1-bin hive
3.配置环境变量
vi /etc/profile
#set hive env
export HIVE_HOME=/use/local/hive
export PATH=$HIVE_HOME/bin:$PATH
#让环境变量生效
source /etc/profile
4.修改hive配置文件
cd /use/local/hive/conf
touch hive-site.xml
<?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>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</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>mysql</value>
<description>password to use against metastore database</description>
</property>
</configuration>
5.安装MySQL数据库
安装MySQL博客地址:http://blog.csdn.net/itqingliang/article/details/77547521
6.启动hive
hive
#在运行hive之前,你的确保自己hadoop已经启动.
7.问题
启动hive时.报Terminal initialization failed; falling back to unsupported
将/use/local/hive/lib 里面的jline2.12替换了
hadoop 中/use/local/hadoop/hadoop-2.6.1/share/hadoop/yarn/lib/jline-0.09*.jar
远程模式:
1.将hive这个目录scp到hadoop的各个节点上
2.配置环境变量 /etc/profile
3.修改其它节点上的hive-site.xml配置文件
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.local</name>
<value>false</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://hadoop01:9083</value>
</property>
</configuration>
4.启动多用户hive
先在服务器端hadoop01上启动:hive --service metastore
然后在客户端上启动hive: hive