解压安装Hive
tar -zxvf /h3ch/apache-hive-2.3.4-bin.tar.gz -C /usr/local/src/
配置环境变量
全局环境变量
vim /root/.bash_profile
export JAVA_HOME=/usr/local/src/jdk1.8.0_301/ export HADOOP_HOME=/opt/module/hadoop-2.6.0/ export SCALA_HOME=/usr/local/src/scala-2.11.0/ export FLINK_HOME=/opt/module/flink-1.10.2/ export HIVE_HOME=/usr/local/src/apache-hive-2.3.4-bin/ PATH=.:$JAVA_HOME:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$SCALA_HOME/bin:$FLINK_HOME/bin:$HIVE_HOME/bin:$PATH:$HOME/bin export PATH
刷新环境变量
source /root/.bash_profile
查看hive的版本
hive --version
配置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/hahive</value>(mysql地址localhost)
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>(mysql的驱动)
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>(用户名)
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>(密码)
<value>123456</value>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
</configuration>
复制mysql的驱动程序到hive的lib目录下面
jar包拷贝
mysql-connector-java-5.1.49-bin.jar
cp /h3ch/mysql-connector-java-5.1.49-bin.jar /usr/local/src/apache-hive-2.3.4-bin/lib
在mysql中hive的schema(在此之前需要创建mysql下的hive数据库)
schematool -dbType mysql -initSchema
执行hive命令
hive