- 官网下载apache-hive-1.1.1-bin.tar.gz
tar -zxvf apache-hive-1.1.1-bin.tar.gz 解压到 /usr/local/apache-hive-1.1.1-bin 目录
- 设置环境变量 vi /etc/profile
JAVA_HOME=/usr/java/jdk1.8.0_51
HADOOP_HOME=/usr/local/hadoop-2.6.0
HIVE_HOME=/usr/local/apache-hive-1.1.1-bin
PATH=$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HIVE_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tool.jar
export JAVA_HOME
export PATH
export CLASSPATH
export HADOOP_HOME
export HIVE_HOME
- 配置修改
cd /usr/local/apache-hive-1.1.1-bin/conf
将所有的配置文件copy一份,如:
cp hive-env.sh.template hive-env.sh
其中
cp hive-default.xml.template hive-site.xml
修改日志文件的存放路径,
修改hive-env.sh
HADOOP_HOME=/usr/local/hadoop-2.6.0
export HIVE_CONF_DIR=/usr/local/apache-hive-1.1.1-bin/conf
export HIVE_AUX_JARS_PATH=/usr/local/apache-hive-1.1.1-bin/lib
修改hive-site.xml
<pre name="code" class="html"><configuration> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive</value> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>hive</value> </property> <property> <name>hive.hwi.listen.port</name> <value>9999</value> <description>This is the port the Hive Web Interface will listen on </description> </property> <property> <name>datanucleus.autoCreateSchema</name> <value>true</value> </property> <property> <name>datanucleus.fixedDatastore</name> <value>false</value> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>hive</value> <description>Username to use against metastore database</description> </property> <property> <name>hive.exec.local.scratchdir</name> <value>/usr/local/apache-hive-1.1.1-bin/iotmp</value> <description>Local scratch space for Hive jobs</description> </property> <property> <name>hive.downloaded.resources.dir</name> <value>/usr/local/apache-hive-1.1.1-bin/iotmp</value> <description>Temporary local directory for added resources in the remote file system.</description> </property> <property> <name>hive.querylog.location</name> <value>/usr/local/apache-hive-1.1.1-bin/iotmp</value> <description>Location of Hive run time structured log file</description> </property> <property> <name>hive.metastore.warehouse.dir</name> <value>/hive/warehouse</value>//hdfs path <description>location of default database for the warehouse</description> </property> </configuration>
创建数据存放文件位置
mkdir <span style="font-family: Arial, Helvetica, sans-serif;">/usr/local/apache-hive-1.1.1-bin/data/iotmp</span>
</pre><pre name="code" class="html">找一个mysql-connector-java-5.1.37-bin.jar copy到/usr/local/apache-hive-1.1.1-bin/lib下,
注意本人试过用mysql-connector-java-5.1.6-bin.jar 这个版本,出现了异常,然后才换了5.1.37版本。
cp /usr/local/apache-hive-1.1.1-bin/lib/jline-2.12.jar /usr/local/hadoop-2.6.0/share/hadoop/yarn/lib/
mv/usr/local/hadoop-2.6.0/share/hadoop/yarn/lib/jline-0.9.94.jar
/usr/local/hadoop-2.6.0/share/hadoop/yarn/lib/jline-0.9.94.jar.bak
- 创建设置hive数据库
CREATE DATABASE hive;
一定要设置CHARACTER SET latin1; //否则以后操作hive的时候会异常
ALTER DATABASE hive CHARACTER SET latin1;CREATE USER hive IDENTIFIED BY 'hive';
允许远程登录
GRANT ALL PRIVILEGES ON hive.* TO 'hive'@'%' IDENTIFIED BY 'hive' WITH GRANT OPTION;
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON hive.* TO 'hive'@'localhost'IDENTIFIED BY 'hive' WITH GRANT OPTION;
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON hive.* TO 'hive'@'node1'IDENTIFIED BY 'hive' WITH GRANT OPTION;
FLUSH PRIVILEGES;
- 启动hadoop后,输入hive命令,启动hive