1. 安裝mysql數據庫(這個能夠用其餘DB代替),安裝方法參照之前寫的Mysql安裝教程。java
``` create user 'hive' identified by 'hive'; grant all privileges on *.* to 'hive'@'%' with grant option; flush privileges; ```
``` create database hive; show databases; ```
安裝Hadoop集羣環境,按照hadoop僞分佈式安裝教程安裝mysql
下載Hive安裝包,並解壓至相關目錄sql
設置環境變量數據庫
``` #hive pro export HIVE_HOME=/home/dzy/runsofts/apache-hive-1.2.1 export PATH=$PATH:$HIVE_HOME/bin export CLASSPATH=$CLASSPATH:$HIVE_HOME/bin ``` 使其生效 ```source /etc/profile```
建立一個IO的tmp文件,筆者在用戶根目錄下建立的 hive/iotmp 用來修改配置apache
修改Hive配置,將其conf文件中的hive-default.xml.templete配置文件複製更名hive-site.xml,主要修改如下參數分佈式
``` <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive</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.querylog.location</name> <value>/home/dzy/logs/hive_logs</value> <description>Location of Hive run time structured log file</description> </property> <property> <name>hive.exec.local.scratchdir</name> <value>/home/dzy/hive/iotmp/hive-${user.name}</value> <description>Local scratch space for Hive jobs</description> </property> <property> <name>hive.downloaded.resources.dir</name> <value>/home/dzy/hive/iotmp</value> <description>Temporary local directory for added resources in the remote file system.</description> </property> ```
cp hive-env.sh.template hive-env.sh
``` dzy@dzy-pc ~/runsofts/apache-hive-1.2.1/conf $ hive Cannot find hadoop installation: $HADOOP_HOME or $HADOOP_PREFIX must be set or hadoop must be in the path ``` 將其中的修改 ``` # Set HADOOP_HOME to point to a specific hadoop install directory HADOOP_HOME=/home/dzy/runsofts/hadoop ```
啓動hive,此時正常啓動。此時mysql的hive庫中多了不少表。ide
在啓動的hive中直接建立表oop
``` hive> create table test1(name string,age int); OK Time taken: 0.793 seconds hive> show tables; OK test1 Time taken: 0.046 seconds, Fetched: 1 row(s) hive> desc te temporary terminated textfile hive> desc test1; OK name string age int Time taken: 0.185 seconds, Fetched: 2 row(s) ```
``` select * from hive.TBLS ```
drop table test1