1.修改环境变量
${HIVE_HOME}/conf/hive-site.xml
2.命令行参数
-e : 执行短命令
-f : 执行文件(适合脚本封装)
-S : 安静模式,不显示MR的运行过程
-hivevar : 传参数 ,专门提供给用户自定义变量。
-hiveconf : 传参数,包括了hive-site.xml中配置的hive全局变量。
[root@host shellcode]# cat hivesql.txt
select * from gamedw.cust where custname='${hivevar:name}'
[root@host shellcode]# hive -hivevar name='nihao' -S -f hivesql.txt
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/root/hive/apache-hive-2.1.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/spark/spark-2.2.0-bin-hadoop2.7/jars/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/hadoop/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
nihao 1 5
nihao 1 5
3.cli中进行参数声明
hive> set hive.cli.print.header=true;
hive> set hive.cli.print.current.db=true;
//设置并行计算
hive> set hive.exec.parallel=true;