hive 参数、变量:hive中的参数、变量都是以命名空间开头
命名空间 | 读写权限 | 含义 |
hiveconf | 可读写 | hive-site.xml当中的各配置变量 例:hive --hiveconf hive.cli.print.header=true |
system | 可读写 | 系统变量,包含JVM运行参数等 例:system:user.name=root |
env | 只读 | 环境变量 例:env:JAVA_HOME |
hivevar | 可读写 | 例:hive -d val=key |
通过${}方式进行引用,其中system、env下的变量必须以前缀开头
hive 参数设置方式
1、修改配置文件 ${HIVE_HOME}/conf/hive-site.xml
2、启动hive cli时,通过--hiveconf key=value的方式进行设置
例:hive --hiveconf hive.cli.print.header=true
3、进入cli之后,通过使用set命令设置
hive set命令
在hive CLI控制台可以通过set对hive中的参数进行查询、设置
set设置:set hive.cli.print.header=true;
set查看:set hive.cli.print.header
hive参数初始化配置
当前用户家目录下的.hiverc文件
如: ~/.hiverc
如果没有,可直接创建该文件,将需要设置的参数写到该文件中,hive启动运行时,会加载改文件中的配置。
hive历史操作命令集
~/.hivehistory
查看hive设置的参数
hive> set;
system:java.io.tmpdir=/tmp
system:java.library.path=/opt/software/hadoop-2.10.1/lib/native
system:java.net.preferIPv4Stack=true
system:java.runtime.name=Java(TM) SE Runtime Environment
system:java.runtime.version=1.8.0_291-b10
system:java.specification.name=Java Platform API Specification
system:java.specification.vendor=Oracle Corporation
system:java.specification.version=1.8
system:java.util.logging.config.file=/opt/software/hive/conf/parquet-logging.properties
system:java.vendor=Oracle Corporation
system:java.vendor.url=http://java.oracle.com/
system:java.vendor.url.bug=http://bugreport.sun.com/bugreport/
system:java.version=1.8.0_291
system:java.vm.info=mixed mode
system:java.vm.name=Java HotSpot(TM) 64-Bit Server VM
system:java.vm.specification.name=Java Virtual Machine Specification
system:java.vm.specification.vendor=Oracle Corporation
system:java.vm.specification.version=1.8
system:java.vm.vendor=Oracle Corporation
system:java.vm.version=25.291-b10
system:line.separator=
env:HADOOP_CLIENT_OPTS= -Dproc_hivecli -Dlog4j.configurationFile=hive-log4j2.properties -Djava.util.logging.config.file=/opt/software/hive/conf/parquet-logging.properties
env:HADOOP_COMMON_HOME=/opt/software/hadoop-2.10.1
env:HADOOP_CONF_DIR=/opt/software/hadoop-2.10.1/etc/hadoop
env:HADOOP_DATANODE_OPTS=-Dhadoop.security.logger=ERROR,RFAS
env:HADOOP_HDFS_HOME=/opt/software/hadoop-2.10.1
env:HADOOP_HEAPSIZE=256
env:HADOOP_HOME=/opt/software/hadoop-2.10.1
env:HADOOP_HOME_WARN_SUPPRESS=true
env:HADOOP_IDENT_STRING=root
env:HADOOP_MAPRED_HOME=/opt/software/hadoop-2.10.1
env:HADOOP_NAMENODE_OPTS=-Dhadoop.security.logger=INFO,RFAS -Dhdfs.audit.logger=INFO,NullAppender
hive.txn.strict.locking.mode=true
hive.txn.timeout=300s
hive.typecheck.on.insert=true
hive.udtf.auto.progress=false
hive.unlock.numretries=10
hive.user.install.directory=/user/
hive.variable.substitute=true
hive.variable.substitute.depth=40
hive.vectorized.adaptor.usage.mode=all
hive.vectorized.execution.enabled=false
hive.vectorized.execution.mapjoin.minmax.enabled=false
hive.vectorized.execution.mapjoin.native.enabled=true
hive.vectorized.execution.mapjoin.native.fast.hashtable.enabled=false
hive.vectorized.execution.mapjoin.native.multikey.only.enabled=false
hive.vectorized.execution.mapjoin.overflow.repeated.threshold=-1
hive.vectorized.execution.reduce.enabled=true
hive.vectorized.execution.reduce.groupby.enabled=true
hive.vectorized.execution.reducesink.new.enabled=true
hive.vectorized.groupby.checkinterval=100000
hive.vectorized.groupby.flush.percent=0.1
hive.vectorized.groupby.maxentries=1000000
hive.vectorized.use.row.serde.deserialize=false
hive.vectorized.use.vector.serde.deserialize=true
hive.vectorized.use.vectorized.input.format=true
hive.warehouse.subdir.inherit.perms=true
表头设置:
1、未设置前查询
hive> select * from student;
OK
1 小红1 ["王者","book","movie"] {"modu":"renminglu","shenzheng":"futian"}
2 小红2 ["王者","book","movie"] {"modu":"renminglu","xizhang":"lasha"}
3 小红3 ["吃鸡","book","movie"] {"chongqing":"renminglu","shenzheng":"futian"}
4 小红4 ["王者","book","movie"] {"modu":"renminglu","dongguang":"changan"}
5 小红5 ["walking","book","movie"] {"modu":"renminglu","shenzheng":"futian"}
6 小红6 ["王者","book","movie"] {"nanchang":"renminglu","shenzheng":"futian"}
7 小红7 ["王者","book","movie"] {"modu":"renminglu","shenzheng":"futian"}
8 小红8 ["walking","book","movie"] {"nanchang":"renminglu","guangzhou":"niwan"}
9 小红9 ["王者","book","movie"] {"modu":"renminglu","shenzheng":"futian"}
10 小红10 ["王者","book","movie"] {"shanghai":"renminglu","shenzheng":"futian"}
Time taken: 0.835 seconds, Fetched: 10 row(s)
2、设置 hive --hiveconf hive.cli.print.header=true 会出现表头,注意只在当前会话有效
[root@node04 ~]# hive --hiveconf hive.cli.print.header=true
which: no hbase in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/java/jdk1.8.0_291-amd64/bin:/opt/software/hadoop-2.10.1/bin:/opt/software/hadoop-2.10.1/sbin:/opt/software/apache-zookeeper
-3.6.2-bin/bin:/opt/software/hive/bin:/root/bin)
Logging initialized using configuration in jar:file:/opt/software/hive/lib/hive-common-2.3.9.jar!/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive> select * from student;
OK
student.id student.name student.likes student.address
1 小红1 ["王者","book","movie"] {"modu":"renminglu","shenzheng":"futian"}
2 小红2 ["王者","book","movie"] {"modu":"renminglu","xizhang":"lasha"}
3 小红3 ["吃鸡","book","movie"] {"chongqing":"renminglu","shenzheng":"futian"}
4 小红4 ["王者","book","movie"] {"modu":"renminglu","dongguang":"changan"}
5 小红5 ["walking","book","movie"] {"modu":"renminglu","shenzheng":"futian"}
6 小红6 ["王者","book","movie"] {"nanchang":"renminglu","shenzheng":"futian"}
7 小红7 ["王者","book","movie"] {"modu":"renminglu","shenzheng":"futian"}
8 小红8 ["walking","book","movie"] {"nanchang":"renminglu","guangzhou":"niwan"}
9 小红9 ["王者","book","movie"] {"modu":"renminglu","shenzheng":"futian"}
10 小红10 ["王者","book","movie"] {"shanghai":"renminglu","shenzheng":"futian"}
Time taken: 2.655 seconds, Fetched: 10 row(s)
进入客户端后设置
1、查询
hive> set hive.cli.print.header
> ;
hive.cli.print.header=true
hive>
2、设置hive.cli.print.header 为 false
hive> set hive.cli.print.header
> ;
hive.cli.print.header=true
hive> set hive.cli.print.header
> = false;
hive> set hive.cli.print.header
> ;
hive.cli.print.header=false
hive> select * from student;
OK
1 小红1 ["王者","book","movie"] {"modu":"renminglu","shenzheng":"futian"}
2 小红2 ["王者","book","movie"] {"modu":"renminglu","xizhang":"lasha"}
3 小红3 ["吃鸡","book","movie"] {"chongqing":"renminglu","shenzheng":"futian"}
4 小红4 ["王者","book","movie"] {"modu":"renminglu","dongguang":"changan"}
5 小红5 ["walking","book","movie"] {"modu":"renminglu","shenzheng":"futian"}
6 小红6 ["王者","book","movie"] {"nanchang":"renminglu","shenzheng":"futian"}
7 小红7 ["王者","book","movie"] {"modu":"renminglu","shenzheng":"futian"}
8 小红8 ["walking","book","movie"] {"nanchang":"renminglu","guangzhou":"niwan"}
9 小红9 ["王者","book","movie"] {"modu":"renminglu","shenzheng":"futian"}
10 小红10 ["王者","book","movie"] {"shanghai":"renminglu","shenzheng":"futian"}
Time taken: 0.344 seconds, Fetched: 10 row(s)
hive>
3、进入当前用户主目录设置.hiverc文件,在启动hive时自动加载此文件设置hive的参数信息
[root@node04 logs]# cd ~
[root@node04 ~]# ls
anaconda-ks.cfg install.log install.log.syslog
[root@node04 ~]# ls -a
. .. anaconda-ks.cfg .bash_history .bash_logout .bash_profile .bashrc .beeline .cshrc .hivehistory install.log install.log.syslog .ssh .tcshrc
[root@node04 ~]# vi .hiverc
set hive.cli.print.header=true;
4、验证加载生效
[root@node04 ~]# hive
which: no hbase in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/java/jdk1.8.0_291-amd64/bin:/opt/software/hadoop-2.10.1/bin:/opt/software/hadoop-2.10.1/sbin:/opt/software/apache-zookeeper
-3.6.2-bin/bin:/opt/software/hive/bin:/root/bin)
Logging initialized using configuration in jar:file:/opt/software/hive/lib/hive-common-2.3.9.jar!/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive> set hive.cli.print.header;
hive.cli.print.header=true
hive>