對應HADOOP版本是2.5.2
安裝MySQL
yum install mysql-server
啟動MySQL
service mysqld start
進入MySQL
mysql
修改用戶權限
> use mysql;
> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123' WITH GRANT OPTION;
> SELECT host, user FROM user;
> DELETE FROM user where host !='%';
> flush privileges; # 刷新權限
下載hive
apache-hive-1.2.1-bin.tar.gz
修改環(huán)境變量/etc/profile
下
export HIVE_HOME=/home/hive-1.2.1
export PATH=$PATH:$HIVE_HOME/bin
hive配置文件
進入$HIVE_HOME/conf
修改配置文件
cp hive-default.xml.template hive-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive_remote/warehouse</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://node1/hive_remote?createDatabaseIfNotExist=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>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123</value>
</property>
</configuration>
添加MySQL的jar包
需要將 mysql 的 jar 包拷貝到$HIVE_HOME/lib 目錄下
mysql-connector-java-5.1.32.jar
下載拷貝至$HIVE_HOME/lib
目錄
替換HADOOP的Jline.jar
拷貝$HIVE_HOME/lib
下的jline.jar替換/usr/local/hadoop/share/hadoop/yarn/lib
目錄下的jline.jar
直接輸入hive即可啟動
$ hive
Hive服務端與客戶端
服務端配置
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://node1/hive?createDatabaseIfNotExist=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>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123</value>
</property>
</configuration>
拷貝MySQL的jar包至$HIVE_HOME/lib
目錄
啟動HIVE服務端
$ hive --service metastore
客戶端配置
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>false</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://node2:9083</value>
</property>
</configuration>
用Hive的Jline.jar包替換HADOOP的Jline.jar包
/usr/local/hadoop/share/hadoop/yarn/lib
$ hive