hive hplsql安装

Last updated on November 22, 2024 am

🧙 Questions

在服务器上安装hplsql

☄️ Ideas

下载

cd /tmp
nohup wget http://www.hplsql.org/downloads/hplsql-0.3.31.tar.gz >> download_hplsql.log 2>&1 &
tail -f download_hplsql.log

安装

sudo mkdir -p /data/hplsql
sudo chown -R ispong:ispong /data/hplsql

tar -vzxf /tmp/hplsql-0.3.31.tar.gz -C /data/hplsql
sudo ln -s /data/hplsql/hplsql-0.3.31 /opt/hplsql
配置环境变量
sudo tee -a /etc/profile <<-'EOF'
export HPLSQL_HOME=/opt/hplsql
export PATH=$PATH:$HPLSQL_HOME
EOF
source /etc/profile

修改配置文件

如果是安装cdh的话,需要配置hadoop_classpath
Note: 修改CDH_HOME参数

vim /opt/hplsql/hplsql
#!/bin/bash

CDH_HOME=/u01/cloudera/parcels/CDH/lib
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop/*:$CDH_HOME/hadoop/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop/lib/*:$CDH_HOME/hadoop/lib/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/etc/hadoop/conf"

export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop-mapreduce/*:$CDH_HOME/hadoop-mapreduce/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop-mapreduce/lib/*:$CDH_HOME/hadoop-mapreduce/lib/*"

export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop-hdfs/*:$CDH_HOME/hadoop-hdfs/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop-hdfs/lib/*:$CDH_HOME/hadoop-hdfs/lib/*"

export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop-yarn/*:$CDH_HOME/hadoop-yarn/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop-yarn/lib/*:$CDH_HOME/hadoop-yarn/lib/*"

# 一定要添加hive的依赖
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hive/lib/*:$CDH_HOME/hive/lib/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hive/conf:$CDH_HOME/hive/conf"

export HADOOP_OPTS="$HADOOP_OPTS -Djava.library.path=$CDH_HOME/hadoop/lib/native"

SCRIPTPATH=${0%/*}

java -cp $SCRIPTPATH:$HADOOP_CLASSPATH:$SCRIPTPATH/hplsql-0.3.31.jar:$SCRIPTPATH/antlr-runtime-4.5.jar $HADOOP_OPTS org.apache.hive.hplsql.Hplsql "$@"
如果是apache的环境
#!/bin/bash

export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop/lib/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/etc/hadoop/conf"

export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop-mapreduce/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop-mapreduce/lib/*"

export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop-hdfs/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop-hdfs/lib/*"

export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop-yarn/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lib/hadoop-yarn/lib/*"

# 一定要添加本地的hive依赖
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/opt/hive/lib/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/opt/hive/conf"

export HADOOP_OPTS="$HADOOP_OPTS -Djava.library.path=/usr/lib/hadoop/lib/native"

SCRIPTPATH=${0%/*}

java -cp $SCRIPTPATH:$HADOOP_CLASSPATH:$SCRIPTPATH/hplsql-0.3.31.jar:$SCRIPTPATH/antlr-runtime-4.5.jar $HADOOP_OPTS org.apache.hive.hplsql.Hplsql "$@"
配置hplsql的hive连接信息
vim /opt/hplsql/hplsql-site.xml
<!-- ispong :) 配置hive2的连接信息 -->
<!-- DRIVER;JDBC_URL;USERNAME;PASSWD -->
<property>
  <name>hplsql.conn.hive2conn</name>
  <value>org.apache.hive.jdbc.HiveDriver;jdbc:hive2://localhost:30115;de;</value>
  <description>HiveServer2 JDBC connection</description>
</property>

<!-- ispong :) 配置连接参数 -->
<!-- mapred.job.queue.name使用yarn的队列名称 -->
<!-- hive.execution.engine 使用引擎 mr/spark -->
<property>
  <name>hplsql.conn.init.hive2conn</name>
  <value>
    set mapred.job.queue.name=default;
    set hive.execution.engine=mr;
    use default;
  </value>
  <description>Statements for execute after connection to the database</description>
</property>

测试安装

注意hive3后面,自带hplsql
可能命令冲突 mv /opt/hive/bin/hplsql /opt/hive/bin/hplsql_bak

hplsql --version
cd /opt/hpsql
./hplsql -e "use hp_dev;select * from test"
hplsql -e "use hp_dev;select * from test"
问题

可能ssh 用户无法找到命令

vim ~/.bashrc
if [ -f /etc/profile ]; then
    source /etc/profile
fi

hive hplsql安装
https://ispong.isxcode.com/hadoop/hive/hive hplsql安装/
Author
ispong
Posted on
March 21, 2022
Licensed under