Chmod +x
vi hplsql 配置
Hadoop环境变量
和hadoopjar包的环境变量
export "HADOOP_CLASSPATH=/opt/cloudera/parcels/CDH/jars/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HADOOP_HOME/lib/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HADOOP_CONF_DIR/"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HADOOP_HOME/share/hadoop/mapreduce/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HADOOP_HOME/share/hadoop/mapreduce/lib/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HADOOP_HOME/share/hadoop/hdfs/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HADOOP_HOME/share/hadoop/hdfs/lib/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HADOOP_HOME/share/hadoop/yarn/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HADOOP_HOME/share/hadoop/yarn/lib/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HADOOP_HOME/share/hadoop/common/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HADOOP_HOME/share/hadoop/common/lib/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HIVE_HOME/lib/*"
export "HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HIVE_HOME/conf"
export HADOOP_OPTS="$HADOOP_OPTS -Djava.library.path=$HADOOP_HOME/lib/native"
HPL/SQL x.x.x
export PATH=$PATH:
4.1配置队列
如果hivesever2没有启动,需要配置并启动
4.2vi hplsql-site.xml
配置:
--设置默认连接
--连接hive2
--可以不添加
--设置队列、资源获取、
set mapred.job.queue.name=default;
set hive.execution.engine=mr;
use _default;
hplsql -e "CURRENT_DATE+1"
hplsql -e "SELECT * FROM src LIMIT 1"
or
②hplsql -f script.sql
Use HPL/SQL in Shell Scripts
Get a value from HPL/SQL script:
MDATE=$(hplsql -e "NVL(MIN_PARTITION_DATE(sales, local_dt, code='A'), '1970-01-01')")
START=$(hplsql -e 'CURRENT_DATE - 1')
可以通过 –main 参数指定要执行的部分
Hplsql –f script.sql –main funcation_name