1、首先安装MySQL,参考https://www.jianshu.com/p/276d59cbc529
2、下载hive,wget http://archive.cloudera.com/cdh5/cdh/5/hive-1.1.0-cdh5.15.1.tar.gz
3、解压,然后添加~/.bash_profile里的环境变量
export HIVE_HOME=/home/hadoop/app/hive-1.1.0-cdh5.15.1
export PATH=$HIVE_HOME/bin:$PATH
4、进入$HIVE_HOME/conf/下,复制一个配置文件,cp hive-env.sh.template hive-env.sh,修改该配置文件的HADOOP_HOME路径为本机$HADOOP_HOME的路径
5、vi hive-site.xml,写入一下信息
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hostname:3306/db?createDatabaseIfNotExist=true</value>
</property>
#以下三个参数配置MySQL的相关信息:驱动和账号密码
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>user</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>password</value>
</property>
#以下两个参数配置显示当前数据库,以及查询表的行头信息
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
</property>
<property>
<name>hive.cli.print.header</name>
<value>true</value>
</property>
</configuration>
6、下载MySQL驱动:https://downloads.mysql.com/archives/c-j/ ,名字为mysql-connector-java-5.1.48.tar.gz,下载之后解压,取出里面的mysql-connector-java-5.1.48-bin.jar,放在$HIVE_HOME/lib目录下
7、进入$HIVE_HOME/bin,执行hive,进入hive命令行,启动成功。但是执行show tables时报错:
Tue Jun 02 01:54:47 CST 2020 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
此时:应该在第5步配置MySQL驱动(javax.jdo.option.ConnectionURL)的value改为以下内容(添加属性useSSL=true,而在xml文件中&等于&)
<value>jdbc:mysql://hostname:3306/db?createDatabaseIfNotExist=true&useSSL=true</value>
8、重启hive,执行create database test_db,然后在MySQL数据库中执行show tables ,发现javax.jdo.option.ConnectionURL配置里面的数据库已经存在,真正启动成功