hive 安装centos7

wget mirror.bit.edu.cn/apache/hive/hive-2.3.4/apache-hive-2.3.4-bin.tar.gz

解压到/usr/local/apache-hive

增加环境变量export HIVE_HOME=/usr/local/apache-hive

将bin加入path

cd /usr/local/apache-hive/conf

cp hive-default.xml.template hive-default.xml

vim hive-site.xm

# cat 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://ali:3306/hive?createDatabaseIfNotExist=true&amp;useSSL=false</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>mysq用户</value>
    <description>username to use against metastore database</description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>mysql密码</value>
    <description>password to use against metastore database</description>
  </property>
</configuration>

cp hive-env.sh.template hive-env.sh

修改

# Set HADOOP_HOME to point to a specific hadoop install directory
export HADOOP_HOME=/usr/local/hadoop/hadoop-2.7.7

# Hive Configuration Directory can be controlled by:
export HIVE_CONF_DIR=/usr/local/apache-hive/conf

# Folder containing extra libraries required for hive compilation/execution can be controlled by:
export HIVE_AUX_JARS_PATH=/usr/local/apache-hive/lib

hadoop fs -mkdir -p /user/hive/warehouse
hadoop fs -mkdir -p /user/hive/tmp
hadoop fs -mkdir -p /user/hive/log hadoop fs -chmod -R 777 /user/hive/warehouse hadoop fs -chmod -R 777 /user/hive/tmp hadoop fs -chmod -R 777 /user/hive/log

https://download.csdn.net/download/lychenhanqing/10049080
下载mysql drive到/usr/local/apache-hive/lib

schematool -initSchema -dbType mysql

请先确保 hadoop 已正常启动!

# 启动hive(由于已配置相关环境变量,直接使用):
hive
# 启动成功,启动过程提示信息结束后,回显:
hive> # 说明已成功启动。同样,注意 ";" 标识一条命令结束!
 
# 显示数据库:
hive> show databases;
OK
default
Time taken: 14.107 seconds, Fetched: 1 row(s)
 # 创建一个表: hive> create table test1(tid int, tname string); OK Time taken: 5.021 seconds  # 显示tables: hive> show tables; OK test1 Time taken: 5.077 seconds, Fetched: 1 row(s)  # 删除刚刚创建的表test1: hive> drop table test1; OK Time taken: 5.223 seconds  # 重新创建表 test1(用于mysql测试): hive> create table test1(tid int, tname string); OK Time taken: 1.322 seconds  # 退出 hive shell hive> exit;
 

猜你喜欢

转载自www.cnblogs.com/mhc-fly/p/10266901.html