1. 程式人生 > >hive安裝

hive安裝

com conn meta orm prop sta 創建 create content

1. Hive的安裝

系統環境
裝好hadoop的環境後。我們能夠把Hive裝在namenode機器上(NameNode-82)。

下載: hive-0.9.0.tar.gz
解壓到: /home/hadoop/hive


hive配置


[[email protected] ~]# cd /home/hadoop/hive/conf
[[email protected] conf]cp hive-default.xml.template hive-site.xml
[[email protected] conf]cp hive-log4j.properties.template hive-log4j.properties
[[email protected]

/* */ conf]cp hive-env.sh.template hive-env.sh


配置hive-env.sh
vi hive-env.sh
HADOOP_HOME=/home/hadoop/hadoop
export HIVE_CONF_DIR=/home/hadoop/hive/conf
export HIVE_AUX_JARS_PATH=/home/hadoop/hive/lib
source hive-env.sh


改動hive-site.xml配置文件
把Hive的元數據存儲到MySQL中

vi conf/hive-site.xml

<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive_metadata?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.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>


環境變量設置

vi /etc/profile


export JAVA_HOME=/usr/local/jdk1.8.0_45
export JRE_HOME=/usr/local/jdk1.8.0_45/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export JAVA_HOME=/usr/local/jdk1.8.0_45

export HADOOP_HOME=/home/hadoop/hadoop
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin

export HBASE_HOME=/home/hadoop/hbase
export PATH=$PATH:$HBASE_HOME/bin

export HIVE_HOME=/home/hadoop/hive

在hdfs上面。創建文件夾


hadoop fs -mkidr /tmp
hadoop fs -mkidr /user/hive/warehouse
hadoop fs -chmod g+w /tmp
hadoop fs -chmod g+w /user/hive/warehouse


在MySQL中創建數據庫

create database hive_metadata;
grant all on hive_metadata.* to [email protected]%‘ identified by ‘hive‘;
grant all on hive_metadata.* to [email protected] identified by ‘hive‘;
ALTER DATABASE hive_metadata CHARACTER SET latin1;


手動上傳mysql的jdbc庫到hive/lib
ls /home/hadoop/hive/lib
mysql-connector-java-5.1.22-bin.jar

啟動hive

#啟動metastore服務
hive --service metastore
Starting Hive Metastore Server

#啟動hiveserver服務
hive --service hiveserver
Starting Hive Thrift Server


#啟動hiveclient
hive shell
Logging initialized using configuration in file:/root/hive-0.9.0/conf/hive-log4j.properties
Hive history file=/tmp/root/hive_job_log_root_201211141845_1864939641.txt

hive> show tables
OK

hive安裝