前提: 安装好mysql ,新建数据库hive,新建用户hive:hive ,并且允许远程登录和访问
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'master' IDENTIFIED BY 'hive' WITH GRANT OPTION;flush privileges;
开始:
1.. Hive下载:http://archive.cloudera.com/cdh5/cdh/5/wget http://archive.cloudera.com/cdh5/cdh/5/hive-1.1.0-cdh5.7.0.tar.gz
2. 解压tar -zxvf hive-1.1.0-cdh5.7.0.tar.gz -C ~/app/
3. 配置系统环境变量( centos:~/.bahs_profile | ubuntu: /etc/profile )export HIVE_HOME=/home/hadoop/app/hive-2.1.1export PATH=$HIVE_HOME/bin:$PATH
4. hive安装路径下新建存储目录iotmp,并且赋予相应的权限 chmod 777 %HIVE_HOME/iotmp
5. 配置 hive-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><configuration> <property> <name>hive.exec.scratchdir</name> <value>/usr/local/hadoop/hive/tmp</value> <description>HDFS root scratch dir for Hive jobs which gets created with write all (733) permission. For each connecting user, an HDFS scratch dir: ${hive.exec.scratchdir}/<username> is created, with ${hive.scratch.dir.permission}.</description> </property> <property> <name>hive.exec.local.scratchdir</name> <value>/usr/local/hadoop/hive/iotmp</value> <description>Local scratch space for Hive jobs</description> </property> <property> <name>hive.downloaded.resources.dir</name> <value>/usr/local/hadoop/hive/iotmp</value> <description>Temporary local directory for added resources in the remote file system.</description> </property> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://172.16.1.80:3306/hive?createDatabaseIfNotExit=true&characterEncoding=UTF-8</value> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> </property> <property> <name>javax.jdo.option.ConnectionUsername</name> <value>hive</value> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>hive</value> </property></configuration>
6. 拷贝mysql驱动到$HIVE_HOME/lib/
7. 启动hive: $HIVE_HOME/bin/hive