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