下载地址:点此链接(P.S.下载带bin的安装包)
下载hive后放到虚拟机文件夹内,打开:
tar -zxf /home/tools/apache-hive-1.2.2-bin.tar.gz -C /home/software/
修改并保存环境配置:
gedit /etc/profile //添加 export HIVE_HOME=/home/software/apache-hive-1.2.2-bin export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin:$FINDBUGS_HOME/bin:$HBASE_HOME/bin:$HIVE_HOME/bin source /etc/profile
重命名hive安装目录下的conf文件夹的两个文件名(可以把conf里面带.template的都删掉后缀):
mv hive-env.sh.template hive-env.sh mv hive-default.xml.template hive-default.xml
修改hadoop下的etc/hadoop/hadoop-env.sh:
export HADOOP_CLASSPATH=.$CLASSPATH:$HADOOP_CLASSPATH:$HADOOP_HOME/bin
修改hive下的/bin/hive-config.sh:添加下面三行:
export JAVA_HOME=/home/software/jdk1.8.0_151 export HADOOP_HOME=/home/software/hadoop-2.6.5 export HIVE_HOME=/home/software/apache-hive-1.2.2-bin
新建hive-site.xml :
touch hive-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive?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> </configuration>
安装mysql:点此链接
下载mysql jdbc 包:点此链接
tar -zxvf mysql-connector-java-5.1.40.tar.gz #解压 cp mysql-connector-java-5.1.40/mysql-connector-java-5.1.40-bin.jar /home/software/apache-hive-1.2.2-bin/lib
//将mysql-connector-java-5.1.40-bin.jar拷贝到hive的lib目录下
启动并登陆mysql shell
service mysql start //启动mysql服务 mysql -u root -p //登陆shell界面
新建hive数据库
mysql> create database hive; //这个hive数据库与hive-site.xml中localhost:3306/hive的hive对应,用来保存hive元数据
配置mysql允许hive接入:
mysql> grant all on *.* to hive@localhost identified by 'hive'; //将所有数据库的所有表的所有权限赋给hive用户,后面的hive是配置hive-site.xml中配置的连接密码 mysql> flush privileges; //刷新mysql系统权限关系表
启动hive,在hive目录下
(启动hive之前,请先启动hadoop集群。)
hive //启动hive