1.解压安装包
tar -zxvf apache-hive-2.3.0-bin.tar.gz
2.添加环境变量,在文件/etc/profile中或者/home/登录用户名/.bash_profile中添加,两者有什么区别请自行查找。
导入下面的环境变量
export HIVE_HOME = hive目录路径
export PATH = $HIVE_HOME/bin
使用下面的命令使修改的环境变量生效
source /etc/profile 或者 source /home/登录用户名/.bash_profile
3.配置hive-env.sh
添加hadoop_home路径:
HADOOP_HOME = hadoop安装路径
添加HIVE_CONF_DIR路径:
export HIVE_CONF_DIR = hive中的conf目录路径
添加HIVE_AUX_JARS_PATH路径:
export HIVE_AUX_JARS_PATH = hive中lib目录路径
4.在hive/lib目录下放入mysql-connector-java-5.1.40.jar包
5.修改配置文件hive-site.xml
JDBC connect string for a JDBC metastore.
To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL.
For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.
Enforce metastore schema version consistency.
True: Verify that version information stored in is compatible with one from Hive jars. Also disable automatic
schema migration attempt. Users are required to manually migrate schema after Hive upgrade which ensures
proper metastore schema migration. (Default)
False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
6.启动hive:
hive启动分为metastore和hiveserver2,其中metastore用于和mysql之间的表结构创建或更新时通讯,hiveserver2用于客户端连接,这两个都要启动。
启动metastore的命令:
nohup ./hive --service metastore >> metastore.log 2>&1 &
启动hiveserver2的命令:
nohup ./hive --service hiveserver2 > hiveserver2.log 2>&1 &