hive部署
安装前准备
修改环境变量
vi /etc/profile
添加内容如下:(hive节点都要执行)
export HIVE_HOME=/opt/hive
export PATH=$PATH:$HIVE_HOME/bin
source /etc/profile
创建用户和用户组
groupadd hive
useradd -g hive hive
usermod -aG hadoop hive
安装hive
上传安装包并解压
tar -zxf apache-hive-3.1.3-bin.tar.gz -C /opt/
ln -s apache-hive-3.1.3-bin /opt/hive
上传驱动包
mysql-connector-java.jar
复制文件
scp -rp /opt/apache-hive-3.1.3-bin xxx.xxx.xxx.220:/opt/
ln -s /opt/apache-hive-3.1.3-bin /opt/hive
cp /usr/share/java/mysql-connector-java.jar /opt/hive/lib/
cp /opt/hadoop/share/hadoop/common/lib/guava-27.0-jre.jar /opt/hive/lib/
(复制完成后删除之前的guava包)
cp alluxio-2.9.3-client.jar /opt/hive/lib/
创建文件并修改权限
hdfs dfs -mkdir -p /user/hive/warehouse
hdfs dfs -mkdir /tmp
hdfs dfs -chmod g+w /tmp /user/hive/warehouse
hdfs dfs -chmod 777 /user/hive/warehouse
mkdir /log/hive
mkdir /log/hadoop
chown -R hive:hadoop /opt/hive/
chown -R hive:hadoop /log/hive /log/hadoop
配置hive
修改hive-env.sh
vi /opt/hive/conf/hive-env.sh
添加如下内容:
export HADOOP_HOME=/opt/hadoop
export HIVE_LOG_DIR=/log/hive
export HIVE_HOME=/opt/hive
export HIVE_CONF_DIR=/opt/hive/conf
if [ "$SERVICE" = "hiveserver2" ] ; then
HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Dhive.log.dir=/log/hive -Dhive.log.file=hiveserver2.log -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.port=9611 -javaagent:/opt/prometheus/jmx_prometheus_javaagent-0.3.1.jar=9511:/opt/prometheus/hiveserver2.yml"
fi
if [ "$SERVICE" = "metastore" ] ; then
HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Dhive.log.dir=/log/hive -Dhive.log.file=metastore.log -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.port=9606 -javaagent:/opt/prometheus/jmx_prometheus_javaagent-0.3.1.jar=9506:/opt/prometheus/hive_metastore.yml"
fi
export HIVE_AUX_JARS_PATH=/opt/hive/lib/alluxio-2.9.3-client.jar:${HIVE_AUX_JARS_PATH}
启动服务
初始化
创建hive元数据库,连接mysql数据库
create database metastore;
create user 'hive'@'%' identified by 'xxxxxxxx';
grant all privileges on metastore.* to 'hive'@'%' ;
cd /opt/hive/bin
schematool -dbType mysql -initSchema
启动服务
su - hive
$HIVE_HOME/bin/hive --service hiveserver2 > /log/hive/hiveserver2.log 2>&1 &
$HIVE_HOME/bin/hive --service metastore> /log/hive/metastore.log 2>&1 &