1、下载tar包 解压

2、安装mysql

3、修改hive配置文件

vim hive-env.sh

  1. HADOOP_HOME=/usr/local/hadoop-2.9.2
  2. export HIVE_CONF_DIR=/usr/local/apache-hive-2.3.9-bin/conf

vim hive-site.xml

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  3. <configuration>
  4. <property>
  5. <name>javax.jdo.option.ConnectionUserName</name>
  6. <value>root</value>
  7. </property>
  8. <property>
  9. <name>javax.jdo.option.ConnectionPassword</name>
  10. <value>123456</value>
  11. </property>
  12. <property>
  13. <name>javax.jdo.option.ConnectionURL</name>
  14. <value>jdbc:mysql://192.100.3.21:3306/hive?createDatabaseIfNotExist=true</value>
  15. </property>
  16. <property>
  17. <name>javax.jdo.option.ConnectionDriverName</name>
  18. <value>com.mysql.cj.jdbc.Driver</value>
  19. </property>
  20. <property>
  21. <name>hive.metastore.schema.verification</name>
  22. <value>false</value>
  23. </property>
  24. <property>
  25. <name>hive.server2.thrift.bind.host</name>
  26. <value>node-1</value>
  27. </property>
  28. <property>
  29. <name>datanucleus.schema.autoCreateAll</name>
  30. <value>true</value>
  31. </property>
  32. </configuration>

4、添加mysql驱动

将mysql 驱动mysql-connector-java-8.0.18.jar放置到lib目录下

5、配置hive环境变量

  1. export HIVE_HOME=/usr/local/apache-hive-2.3.9-bin
  2. export PATH=$HIVE_HOME/bin:$PATH

6、初始化元数据库

  1. schematool -dbType mysql -initSchema
  2. # 2.x版本Hive需要手动初始化

7、使用

  1. $ hive
  2. hive> show database;
  3. hive> create database mytest;
  4. hive> use mytest;
  5. hive> create table book(id int, name string);