前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >0816-CDP Hive3升级说明

0816-CDP Hive3升级说明

作者头像
Fayson
发布2020-11-03 10:47:15
3K1
发布2020-11-03 10:47:15
举报
文章被收录于专栏:Hadoop实操Hadoop实操

文档编写目的

CDH5中的Hive版本是1.1,而CDP7中的Hive版本为3。Hive3相对Hive1更新特别多,比如支持全新的ACID v2机制,并且底层使用Tez和内存进行查询,相比MR的方式性能提升超过10倍,支持物化视图以及语法使用扩充等等。因为是一次大版本的更新,对于老的CDH5用户升级到CDP7,会需要对于Hive3有足够的了解与准备,才能保证升级成功。本文主要介绍Hive3的新特性,架构,以及语法改造说明。

Apache Hive3关键特性

Hive是一个数据仓库系统,用于汇总,查询和分析庞大而分散的数据集。Cloudera Runtime(CR)服务包括Hive on Tez和Hive Metastore。Hive 3.x中与以前版本相比的增强功能可以提高SQL查询性能,安全性和审核功能。Hive元数据库HMS是一个单独的服务,不是Hive的一部分,甚至不必位于同一集群上,HMS将元数据存储在Hive,Impala,Spark和其他组件的后端。

2.1 ACID事务处理

Hive 3表符合ACID(原子性,一致性,隔离性和耐久性)。Hive 3的读写操作提高了事务表的性能。原子操作包括简单的写入和插入,对多个分区的写入以及单个SELECT语句中的多个插入。读操作不受操作期间发生的更改的影响。你可以插入或删除数据,并且在整个软件和硬件崩溃中它都能保持一致。Hive表的创建和维护也得到大大的简化,因为你不再需要对表设置bucket。

你可以利用以下事务处理特性来部署新的Hive应用程序:

1.ACID事务处理的成熟版本:

a)ACID表是默认表类型。

b)默认情况下启用ACID不会导致性能或操作过载。

2.简化的应用程序开发,具有强大事务保证的操作以及SQL命令的简单语义。

a)你不需要为ACID表设置bucket

3.物化视图重写

4.自动查询缓存

5.高级优化

2.2共享的Hive Metastore

Cloudera Runtime(CR)服务包括Hive和Hive Metastore(HMS)。HMS支持多个计算引擎(例如Impala和Spark)的交互操作。HMS简化了各种引擎之间的访问和用户数据访问。

2.3计划的查询

使用SQL语句,你可以计划Hive查询定期运行,监视查询进度,临时忽略一个查询计划并限制查询并发数。比如你可以使用Scheduled Queries开始压缩并重建物化视图。

2.4低延时分析处理(CDP公有云/私有云)

Hive支持low-latency analytical processing (LLAP)或Tez引擎。

Apache Tez是Hive on Tez服务的执行引擎,该服务包括HiveServer(HS2),不再支持MapReduce。在Cloudera集群中,如果旧脚本或应用程序指定MapReduce引擎,则会发生异常。大多数用户自定义函数(UDF)不需要更改即可在Tez上执行。

通过使用有向无环图(DAG),以及中间结果不落地,使用Tez执行查询比MapReduce性能要好。在CDP中,Tez一般仅由Hive使用,并且在Hive on Tez服务启动时会自动启动和管理Tez AM。你提交给Hive的SQL查询的执行方式如下:

1.Hive编译查询。

2.Tez执行查询。

3.资源是为整个集群中的应用程序分配的。

4.Hive更新数据源中的数据并返回查询结果。

Hive on Tez在临时容器上运行任务,并使用标准的YARN shuffle服务。

2.5Hive集成Spark

Spark和Hive表使用Hive Warehouse Connector交互操作。

你可以使用Hive Warehouse Connector从Spark访问ACID或外部表。你也可以不需要Hive Warehouse Connector即可从Spark读取Hive外部表并从Spark写入Hive外部表,Spark用户可以直接从Hive读取或写入。你可以读取ORC或Parquet格式的外部表,但使用Spark只能写入ORC格式的Hive外部表。

2.6数据存储和访问控制

为了支持Hive3的设计,一个主要的架构更改是使Hive对元数据内存资源和文件系统或对象存储有了更多的控制。如下所示是Hive2到Hive3的架构更改,以提升更好的安全:

1.严格控制的文件系统和计算内存资源,替代了灵活的边界:明确的边界提高了可预测性。更好的文件系统控制可提高安全性。

2.优化共享文件和YARN容器中的工作负载

默认情况下,CDP Private Cloud Base将Hive数据存储在HDFS上。而对于CDP公有云,Hive则是默认存储到S3。在公有云中,Hive将HDFS只用于存储临时文件。Hive 3通过以下方式针对对象存储(例如S3)进行了优化:

1.Hive使用ACID来确定要读取的文件,而不是依赖于存储系统。

2.在Hive 3中,文件移动比在Hive 2中减少。

3.Hive积极地缓存元数据和数据,以减少文件系统的操作。

Hive的主要授权模型是Ranger。Hive强制实施Ranger中指定的访问控制。与其他安全方案相比,该模型提供了更强的安全性,并且在管理策略方面具有更大的灵活性。

此模型仅允许Hive访问数据仓库。如果集群没有启用Ranger安全服务或者其他安全,默认情况下CDP Private Cloud Base中,Hive使用基于存储的授权(SBA)。

2.7查询级别的工作负载管理

你可以配置谁使用查询资源,可以使用多少资源以及Hive对资源请求的响应速度。工作负载管理可以提升查询并发和查询性能。尽管名称相似,但是Hive工作负载管理查询与Cloudera Workload XM无关,WXM可以报告和查看数百万个查询和数百个数据库。

2.8物化视图

因为很多查询经常需要相同的中间汇总表或关联表,所以可以通过将中间表预先计算和缓存到视图中来避免昂贵,重复的查询操作。

2.9查询结果缓存

Hive会过滤和缓存相似或相同的查询。Hive不会重新计算未更改的数据。当数百个或数千个BI工具和Web服务的用户查询Hive时,缓存重复查询可以大大减少负载。

2.10连接池

Hive支持HakariCP JDBC连接池。

2.11HDFS权限更改

在CDP Private Cloud Base中,SBA在很大程度上依赖于HDFS ACL。ACL是HDFS中权限系统的扩展。默认情况下,CDP Private Cloud Base会开启HDFS ACL,为你提供以下优势:

1.在授予多个组和用户特定权限时,增加了灵活性

2.方便地将权限应用于目录树,而不是单个文件

2.12Hive客户端变更

CDP Private Cloud Base支持瘦客户端Beeline命令行,你可以从命令行运行Hive管理命令。Beeline使用JDBC连接到Hive on Tez来执行命令,解析/编译/执行都在Hive on Tez中。Beeline支持Hive CLI的许多命令行选项。Beeline不支持hive -e set key = value来配置Hive Metastore。

通过使用hive关键字,命令选项和命令调用Beeline,可以输入受支持的Hive CLI命令。比如hive -e set。使用Beeline代替不再支持的胖客户端Hive CLI具有许多优点,包括较低的开销。执行查询只需要较少的守护进程简化了监控和调试。

Hive on Tez会强制执行白名单和黑名单设置,你可以使用SET命令对其进行更改。使用黑名单,你可以限制内存配置更改,以防止不稳定。你可以在具有不同白名单和黑名单的Tez实例上配置多个Hive,以建立不同级别的稳定性。

2.13批处理和交互式工作负载的查询执行

你可以使用JDBC命令行工具(例如Beeline)或使用JDBC / ODBC驱动程序和BI工具(例如Tableau)连接到Hive。客户端与同一个Hive on Tez版本的实例进行通信。你可以为每个实例配置设置文件(settings file)以执行批处理或交互式处理。

迁移Hive数据到CDP

使用WXM或Replication Manager将Hive数据迁移到CDP之后,你可能还需要执行一些额外的任务来真正完成迁移。你需要了解Hive3.x和早期版本之间的语法差异,其中一些差异会需要你更改Hive脚本或者工作流。另外在CDP中需要将Hive CLI脚本替换为Beeline,因为Hive CLI已经不支持。

你需要知道表的位置以及升级过程所做的属性更改。使用Hive表之前,你需要执行一些迁移后任务。了解Apache Hive 3的主要设计功能(例如默认的ACID事务处理)可以帮助你使用Hive满足企业数据仓库系统不断增长的需求。

3.1Casting Timestamps

从Hive1/2到Hive3,如果将数值(numeric)类型转换为时间戳(timestamp)类型结果会不一样。Apache Hive更改了CAST的行为以符合SQL标准,即不将时区与TIMESTAMP类型相关联。

1.升级到CDP之前

将数字类型值强制转换为时间戳可用于生成反映集群时区的结果。例如1597217764557 is 2020-08-12 00:36:04 PDT,运行以下查询将数字强制转换为PDT中的时间戳:

> SELECT CAST(1597217764557 AS TIMESTAMP); 
| 2020-08-12 00:36:04 |    

2.升级到CDP之后

将数字类型值转换为时间戳会产生一个反映UTC而不是集群时区的结果。运行以下查询会将数字强制转换为UTC中的时间戳。

> SELECT CAST(1597217764557 AS TIMESTAMP); 
| 2020-08-12 07:36:04.557  |  

3.需要采取的行动

更改应用程序。不要通过数字强制转换来获取本地时区。内置函数from_utc_timestamp和to_utc_timestamp可用于模拟升级之前的行为。

3.2检查列更改的兼容性

默认配置可能导致更改列类型的应用程序失败。

1.升级到CDP之前

hive.metastore.disallow.incompatible.col.type.changes默认为false,以允许更改不兼容的列类型。例如,您可以将STRING列更改为不兼容类型的列,例如MAP <STRING,STRING>,不会发生错误。

2.升级到CDP之后

在CDP中,默认情况下,hive.metastore.disallow.incompatible.col.type.changes为true。Hive会阻止将列修改为不兼容的类型。而兼容的列类型的更改不会阻止,比如INT, STRING, BIGINT。

3.需要采取的行动

更改应用程序以禁止不兼容的列类型更改,这样可以防止可能的数据损坏。检查ALTER TABLE语句,并更改由于不兼容的列类型而失败的语句。

4.相关信息

https://issues.apache.org/jira/browse/HIVE-12320

3.3创建一张表

为了提高可用性和功能性,Hive 3显著更改了表的创建。

创建Hive表修改了一下几点:

  • 创建兼容ACID的表,这是CDP中的默认表
  • 支持简单的写入和插入
  • 写入多个分区
  • 在单个SELECT语句中插入多个数据更新
  • ACID表不需要bucket

如果你有ETL管道是在Hive中创建表,则这些表将被创建为ACID。Hive现在严格控制访问并定期在表上执行压缩。从Spark和其他客户端访问托管Hive表的方式发生了变化。在CDP中,对外部表的访问要求你设置安全访问权限。

1.升级到CDP之前

在CDH和HDP 2.6.5中,默认情况下CREATE TABLE创建一个非ACID表。

2.升级到CDP之后

在CDP中,默认情况下CREATE TABLE以ORC格式创建完整的ACID事务表。

3.需要采取的行动

执行以下一项或多项操作:

a)升级过程会将CDH中的Hive内部表转换为外部表。你必须更改脚本以创建用例所需的表类型。

b)配置旧的CREATE TABLE行为以默认创建外部表。

c)要从Spark读取Hive ACID表,需要使用Hive Warehouse Connector(HWC)或HWC Spark Direct Reader连接到Hive。要使用Spark写入Hive ACID表,需要使用HWC和HWC API。如果不使用HWC API,Spark将使用purge属性创建一个外部表。

d)为表设置Ranger策略和HDFS ACL。

3.4更正查询中的db.table

为了符合ANSI SQL,Hive 3.x在SQL查询中拒绝db.table。表名中不允许使用点(.)。

你需要更改使用此类db.table引用的查询,以防止Hive将整个db.table字符串解释为表名。你需要将数据库名称和表名称括在反引号中。

3.5将反引号添加到表引用

CDP包含Hive-16907 bug修复,该bug主要是拒绝SQL查询中的“ db.table”。表名中不允许使用点(.)。你需要更改使用此类引用的查询,以防止Hive将整个db.table字符串解释为表名。

1.查找具有有问题的表

math.students

像上述这种写法出现在CREATE TABLE语句中。

2.将数据库名称和表名称括在反引号中。

CREATE TABLE `math`.`students` (name VARCHAR(64), age INT, gpa DECIMAL(3,2));

3.6处理关键字APPLICATION

如果在查询中使用关键字APPLICATION,则可能需要修改查询以防止失败。

为防止使用关键字的查询失败,需要将查询括在反引号中。

1.升级到CDP之前

在CDH版本(例如CDH 5.13)中,在查询中使用单词APPLICATION是没有问题的。例如,你可以将此词用作表名。

> select f1, f2 from application

2.升级到CDP之后

使用关键字APPLICATION的查询会失败。

3.需要采取的行动

更改应用程序,将查询括在反引号中。

SELECT field1, field2 FORM `application`

3.7禁用分区类型检查

Hive3中的一项增强功能可以检查分区的类型,可以通过设置属性来禁用此功能。

1.升级到CDP之前

在CDH 5.x中,不对分区值进行类型检查。

2.升级到CDP之后

如果将属性hive.typecheck.on.insert设置为true(默认值),则会对指定的分区值进行类型检查,转换和标准化,以使其符合其列类型,可以是数字。

3.需要采取的行动

如果分区的类型检查导致问题,可以禁用该功能。要禁用分区类型检查,将hive.typecheck.on.insert设置为false。

SET hive.typecheck.on.insert=false;

3.8Dropping Partitions

CASCADE子句中用于删除分区的OFFLINE和NO_DROP关键字会导致性能问题,不再受支持。

1.升级到CDP之前

您可以在DROP CASCADE子句中使用OFFLINE和NO_DROP关键字来防止读取或删除分区。

2.升级到CDP之后

DROP CASCADE子句不支持OFFLINE和NO_DROP。

3.需要采取的行动

更改应用程序,将DROP CASCADE子句中的OFFLINE和NO_DROP删除。使用授权工具Ranger,以防止删除和读取分区。

3.9授予角色权限

在CDH中,ROLE/GROUP语义与CDP中的语义不同。Hive 3需要严格控制的文件系统和计算机内存资源,以替代早期Hive版本允许的灵活边界。

明确的边界增加了可预测性,更好的文件系统控制可提高安全性,该模型提供比其他安全方案更强的安全性和更好的策略管理。

1.升级到CDP之前

在CDH中,使用Sentry进行授权管理,CDH支持GRANT ON ROLE语法。

2.升级到CDP之后

CDP中不再支持Sentry,需要迁移至Apache Ranger,也不支持GRANT ON ROLE语义。

3.需要采取的行动

例如,使用CDP支持的GRANT语义来设置文件系统权限:

GRANT <permissions> ON TABLE <table> TO USER <user or group>;

使用在Configuring a resource-based policy描述的语义:Hive

3.10处理greatest和least函数的输出

1.升级到CDP之前

greatest函数返回值列表中的最大值,least函数返回值列表中的最小值。

2.升级到CDP之后

当一个或多个参数为NULL时返回NULL。

3.需要采取的行动

在用作greatest或least函数的参数的列上使用NULL过滤器或nvl函数。

SELECT greatest(nvl(col1,default value incase of NULL),nvl(col2,default value incase of NULL));

3.11重命名表

为了强化系统,Hive数据可以存储在HDFS加密区域(encryption zone)中。RENAME行为已更改,以防止将表移到同一个加密区域之外或移入非加密区域。

1.升级到CDP之前

在CDH和HDP中,重命名托管表(内部表)将移动其HDFS位置。

2.升级到CDP之后

重命名托管表仅在创建不带LOCATION子句且位于其数据库目录下的表时才移动其位置。

3.需要采取的行动

3.12Hive配置属性修改

你需要了解升级过程进行的属性值更改,因为这些更改可能影响你的工作,你可能还需要考虑也升级这些属性的默认值。

升级过程将更改某些Hive配置属性的默认值,并添加新属性。下表描述了从CDH或HDP升级到CDP后发生的更改。

datanucleus.connectionPool.maxPoolSize

升级前: 30

升级后: 10

datanucleus.connectionPoolingType

升级前: BONECP

升级后: HikariCP

hive.auto.convert.join.noconditionaltask.size

升级前: 20971520

升级后: 52428800

Exception: Preserves pre-upgrade value if old default is overridden;otherwise, uses new default.

hive.auto.convert.sortmerge.join

升级前: FALSE in the old CDH; TRUE in the old HDP.

升级后: TRUE

hive.auto.convert.sortmerge.join.to.mapjoin

升级前: FALSE

升级后: TRUE

hive.cbo.enable

升级前: FALSE

升级后: TRUE

hive.cbo.show.warnings

升级前: FALSE

升级后: TRUE

hive.compactor.worker.threads

升级前: 0

升级后: 5

hive.compute.query.using.stats

升级前: FALSE

升级后: TRUE

hive.conf.hidden.list

升级前:

javax.jdo.option.ConnectionPassword,hive.server2.keystore.password,hive.metastore.dbaccess.ssl.truststore.password,fs.s3.awsAccessKeyId,fs.s3.awsSecretAccessKey,fs.s3n.awsAccessKeyId,fs.s3n.awsSecretAccessKey,fs.s3a.access.key,fs.s3a.secret.key,fs.s3a.proxy.password,dfs.adls.oauth2.credential,fs.adl.oauth2.credential,fs.azure.account.oauth2.client.secret

升级后

javax.jdo.option.ConnectionPassword,hive.server2.keystore.password,hive.druid.metadata.password,hive.driver.parallel.compilation.global.limit

hive.conf.restricted.list

升级前

hive.security.authenticator.manager,hive.security.authorization.manager,hive.users.in.admin.role,hive.server2.xsrf.filter.enabled,hive.spark.client.connect.timeout,hive.spark.client.server.connect.timeout,hive.spark.client.channel.log.level,hive.spark.client.rpc.max.size,hive.spark.client.rpc.threads,hive.spark.client.secret.bits,hive.spark.client.rpc.server.address,hive.spark.client.rpc.server.port,hive.spark.client.rpc.sasl.mechanisms,hadoop.bin.path,yarn.bin.path,spark.home,bonecp.,hikaricp.,hive.driver.parallel.compilation.global.limit,_hive.local.session.path,_hive.hdfs.session.path,_hive.tmp_table_space,_hive.local.session.path,_hive.hdfs.session.path,_hive.tmp_table_space

升级后

hive.security.authenticator.manager,hive.security.authorization.manager,hive.security.metastore.authorization.manager,hive.security.metastore.authenticator.manager,hive.users.in.admin.role,hive.server2.xsrf.filter.enabled,hive.security.authorization.enabled,hive.distcp.privileged.doAs,hive.server2.authentication.ldap.baseDN,hive.server2.authentication.ldap.url,hive.server2.authentication.ldap.Domain,hive.server2.authentication.ldap.groupDNPattern,hive.server2.authentication.ldap.groupFilter,hive.server2.authentication.ldap.userDNPattern,hive.server2.authentication.ldap.userFilter,hive.server2.authentication.ldap.groupMembershipKey,hive.server2.authentication.ldap.userMembershipKey,hive.server2.authentication.ldap.groupClassKey,hive.server2.authentication.ldap.customLDAPQuery,hive.privilege.synchronizer.interval,hive.spark.client.connect.timeout,hive.spark.client.server.connect.timeout,hive.spark.client.channel.log.level,hive.spark.client.rpc.max.size,hive.spark.client.rpc.threads,hive.spark.client.secret.bits,hive.spark.client.rpc.server.address,hive.spark.client.rpc.server.port,hive.spark.client.rpc.sasl.mechanisms,bonecp.,hive.druid.broker.address.default,hive.druid.coordinator.address.default,hikaricp.,hadoop.bin.path,yarn.bin.path,spark.home,hive.driver.parallel.compilation.global.limit,_hive.local.session.path,_hive.hdfs.session.path,_hive.tmp_table_space,_hive.local.session.path,_hive.hdfs.session.path,_hive.tmp_table_space

hive.default.fileformat.managed

升级前: None

升级后: ORC

hive.default.rcfile.serde

升级前:org.apache.hadoop.hive.serde2.columnar.ColumnarSerDe

升级后:org.apache.hadoop.hive.serde2.columnar.LazyBinaryColumnarSerDe

Not supported in Impala. Impala cannot read Hive-created RC tables.

hive.driver.parallel.compilation

升级前: FALSE

升级后: TRUE

hive.exec.dynamic.partition.mode

升级前: strict

升级后: nonstrict

In CDPPrivate Cloud Base, accidental use of dynamic partitioning feature is not prevented by default.

hive.exec.max.dynamic.partitions

升级前: 1000

升级后: 5000

In CDP Private Cloud Base, fewer restrictions on dynamic partitioning occur than in the pre-upgrade CDH or HDP cluster.

hive.exec.max.dynamic.partitions.pernode

升级前: 100

升级后: 2000

In CDP Private Cloud Base, fewer restrictions on dynamic partitioning occur than in the pre-upgrade CDH or HDP cluster.

hive.exec.post.hooks

升级前:

com.cloudera.navigator.audit.hive.HiveExecHookContext,org.apache.hadoop.hive.ql.hooks.LineageLogger

升级后:org.apache.hadoop.hive.ql.hooks.HiveProtoLoggingHook

A prime number is recommended.

hive.exec.reducers.max

升级前: 1099

升级后: 1009

Exception: Preserves pre-upgrade value if old default is overridden; otherwise, uses new default

hive.execution.engine

升级前: mr

升级后: tez

Tez isnow the only supported execution engine, existing queries that change executionmode to Spark or MapReduce within a session, for example, fail.

hive.fetch.task.conversion

升级前: minimal

升级后: more

hive.fetch.task.conversion.threshold

升级前: 256MB

升级后: 1GB

Exception: Preserves pre-upgrade value if old default is overridden; otherwise, uses new default.

hive.hashtable.key.count.adjustment

升级前: 1

升级后: 0.99

Exception: Preserves pre-upgrade value if old default is overridden; otherwise, uses new default.

hive.limit.optimize.enable

升级前: FALSE

升级后: TRUE

hive.limit.pushdown.memory.usage

升级前: 0.1

升级后: 0.04

Exception: Preserves pre-upgrade value if old default is overridden; otherwise, uses new default.

hive.mapjoin.hybridgrace.hashtable

升级前: TRUE

升级后: FALSE

hive.mapred.reduce.tasks.speculative.execution

升级前: TRUE

升级后: FALSE

hive.metastore.aggregate.stats.cache.enabled

升级前: TRUE

升级后: FALSE

hive.metastore.disallow.incompatible.col.type.changes

升级前: FALSE

升级后: TRUE

Schema evolution is more restrictive in CDP Private Cloud Base than in CDH to avoid data corruption. The new default disallows column type changes if the old andnew types are incompatible.

hive.metastore.dml.events

升级前: FALSE

升级后: TRUE

hive.metastore.event.message.factory

升级前:

org.apache.hadoop.hive.metastore.messaging.json.ExtendedJSONMessageFactory

升级后:

org.apache.hadoop.hive.metastore.messaging.json.gzip.GzipJSONMessageEncoder

hive.metastore.uri.selection

升级前:SEQUENTIAL

升级后: RANDOM

hive.metastore.warehouse.dir

升级前:/user/hive/warehouse

升级后 from CDP:/user/hive/warehouse

升级后 from HDP:/warehouse/tablespace/managed/hive

Tablesexisting in the old (HDFS) warehouse path are migrated to the new location.

hive.optimize.metadataonly

升级前: FALSE

升级后: TRUE

hive.optimize.point.lookup.min

升级前: 31

升级后: 2

hive.prewarm.numcontainers

升级前: 10

升级后: 3

hive.script.operator.env.blacklist

升级前:hive.txn.valid.txns,hive.script.operator.env.blacklist

升级后:

hive.txn.valid.txns,hive.txn.tables.valid.writeids,hive.txn.valid.writeids,hive.script.operator.env.blacklist

hive.security.authorization.sqlstd.confwhitelist

升级前:

hive\.auto\..*hive\.cbo\..*hive\.convert\..*hive\.exec\.dynamic\.partition.*hive\.exec\..*\.dynamic\.partitions\..*hive\.exec\.compress\..*hive\.exec\.infer\..*hive\.exec\.mode.local\..*hive\.exec\.orc\..*hive\.exec\.parallel.*hive\.explain\..*hive\.fetch.task\..*hive\.groupby\..*hive\.hbase\..*hive\.index\..*hive\.index\..*hive\.intermediate\..*hive\.join\..*hive\.limit\..*hive\.log\..*hive\.mapjoin\..*hive\.merge\..*hive\.optimize\..*hive\.orc\..*hive\.outerjoin\..*hive\.parquet\..*hive\.ppd\..*hive\.prewarm\..*hive\.server2\.proxy\.userhive\.skewjoin\..*hive\.smbjoin\..*hive\.stats\..*hive\.strict\..*hive\.tez\..*hive\.vectorized\..*mapred\.map\..*mapred\.reduce\..*mapred\.output\.compression\.codecmapred\.job\.queuenamemapred\.output\.compression\.typemapred\.min\.split\.sizemapreduce\.job\.reduce\.slowstart\.completedmapsmapreduce\.job\.queuenamemapreduce\.job\.tagsmapreduce\.input\.fileinputformat\.split\.minsizemapreduce\.map\..*mapreduce\.reduce\..*mapreduce\.output\.fileoutputformat\.compress\.codecmapreduce\.output\.fileoutputformat\.compress\.typeoozie\..*tez\.am\..*tez\.task\..*tez\.runtime\..*tez\.queue\.namehive\.transpose\.aggr\.joinhive\.exec\.reducers\.bytes\.per\.reducerhive\.client\.stats\.countershive\.exec\.default\.partition\.namehive\.exec\.drop\.ignorenonexistenthive\.counters\.group\.namehive\.default\.fileformat\.managedhive\.enforce\.bucketmapjoinhive\.enforce\.sortmergebucketmapjoinhive\.cache\.expr\.evaluationhive\.query\.result\.fileformathive\.hashtable\.loadfactorhive\.hashtable\.initialCapacityhive\.ignore\.mapjoin\.hinthive\.limit\.row\.max\.sizehive\.mapred\.modehive\.map\.aggrhive\.compute\.query\.using\.statshive\.exec\.rowoffsethive\.variable\.substitutehive\.variable\.substitute\.depthhive\.autogen\.columnalias\.prefix\.includefuncnamehive\.autogen\.columnalias\.prefix\.labelhive\.exec\.check\.crossproductshive\.cli\.tez\.session\.asynchive\.compathive\.exec\.concatenate\.check\.indexhive\.display\.partition\.cols\.separatelyhive\.error\.on\.empty\.partitionhive\.execution\.enginehive\.exec\.copyfile\.maxsizehive\.exim\.uri\.scheme\.whitelisthive\.file\.max\.footerhive\.insert\.into\.multilevel\.dirshive\.localize\.resource\.num\.wait\.attemptshive\.multi\.insert\.move\.tasks\.share\.dependencieshive\.support\.quoted\.identifiershive\.resultset\.use\.unique\.column\.nameshive\.analyze\.stmt\.collect\.partlevel\.statshive\.exec\.schema\.evolutionhive\.server2\.logging\.operation\.levelhive\.server2\.thrift\.resultset\.serialize\.in\.taskshive\.support\.special\.characters\.tablenamehive\.exec\.job\.debug\.capture\.stacktraceshive\.exec\.job\.debug\.timeouthive\.llap\.io\.enabledhive\.llap\.io\.use\.fileid\.pathhive\.llap\.daemon\.service\.hostshive\.llap\.execution\.modehive\.llap\.auto\.allow\.uberhive\.llap\.auto\.enforce\.treehive\.llap\.auto\.enforce\.vectorizedhive\.llap\.auto\.enforce\.statshive\.llap\.auto\.max\.input\.sizehive\.llap\.auto\.max\.output\.sizehive\.llap\.skip\.compile\.udf\.checkhive\.llap\.client\.consistent\.splitshive\.llap\.enable\.grace\.join\.in\.llaphive\.llap\.allow\.permanent\.fnshive\.exec\.max\.created\.fileshive\.exec\.reducers\.maxhive\.reorder\.nway\.joinshive\.output\.file\.extensionhive\.exec\.show\.job\.failure\.debug\.infohive\.exec\.tasklog\.debug\.timeouthive\.query\.id 

升级后:

hive\.auto\..*hive\.cbo\..*hive\.convert\..*hive\.druid\..*hive\.exec\.dynamic\.partition.*hive\.exec\.max\.dynamic\.partitions.*hive\.exec\.compress\..*hive\.exec\.infer\..*hive\.exec\.mode.local\..*hive\.exec\.orc\..*hive\.exec\.parallel.*hive\.exec\.query\.redactor\..*hive\.explain\..*hive\.fetch.task\..*hive\.groupby\..*hive\.hbase\..*hive\.index\..*hive\.index\..*hive\.intermediate\..*hive\.jdbc\..*hive\.join\..*hive\.limit\..*hive\.log\..*hive\.mapjoin\..*hive\.merge\..*hive\.optimize\..*hive\.materializedview\..*hive\.orc\..*hive\.outerjoin\..*hive\.parquet\..*hive\.ppd\..*hive\.prewarm\..*hive\.query\.redaction\..*hive\.server2\.thrift\.resultset\.default\.fetch\.sizehive\.server2\.proxy\.userhive\.skewjoin\..*hive\.smbjoin\..*hive\.stats\..*hive\.strict\..*hive\.tez\..*hive\.vectorized\..*hive\.query\.reexecution\..*reexec\.overlay\..*fs\.defaultFSssl\.client\.truststore\.locationdistcp\.atomicdistcp\.ignore\.failuresdistcp\.preserve\.statusdistcp\.preserve\.rawxattrsdistcp\.sync\.foldersdistcp\.delete\.missing\.sourcedistcp\.keystore\.resourcedistcp\.liststatus\.threadsdistcp\.max\.mapsdistcp\.copy\.strategydistcp\.skip\.crcdistcp\.copy\.overwritedistcp\.copy\.appenddistcp\.map\.bandwidth\.mbdistcp\.dynamic\..*distcp\.meta\.folderdistcp\.copy\.listing\.classdistcp\.filters\.classdistcp\.options\.skipcrccheckdistcp\.options\.mdistcp\.options\.numListstatusThreadsdistcp\.options\.mapredSslConfdistcp\.options\.bandwidthdistcp\.options\.overwritedistcp\.options\.strategydistcp\.options\.idistcp\.options\.p.*distcp\.options\.updatedistcp\.options\.deletemapred\.map\..*mapred\.reduce\..*mapred\.output\.compression\.codecmapred\.job\.queue\.namemapred\.output\.compression\.typemapred\.min\.split\.sizemapreduce\.job\.reduce\.slowstart\.completedmapsmapreduce\.job\.queuenamemapreduce\.job\.tagsmapreduce\.input\.fileinputformat\.split\.minsizemapreduce\.map\..*mapreduce\.reduce\..*mapreduce\.output\.fileoutputformat\.compress\.codecmapreduce\.output\.fileoutputformat\.compress\.typeoozie\..*tez\.am\..*tez\.task\..*tez\.runtime\..*tez\.queue\.namehive\.transpose\.aggr\.joinhive\.exec\.reducers\.bytes\.per\.reducerhive\.client\.stats\.countershive\.exec\.default\.partition\.namehive\.exec\.drop\.ignorenonexistenthive\.counters\.group\.namehive\.default\.fileformat\.managedhive\.enforce\.bucketmapjoinhive\.enforce\.sortmergebucketmapjoinhive\.cache\.expr\.evaluationhive\.query\.result\.fileformathive\.hashtable\.loadfactorhive\.hashtable\.initialCapacityhive\.ignore\.mapjoin\.hinthive\.limit\.row\.max\.sizehive\.mapred\.modehive\.map\.aggrhive\.compute\.query\.using\.statshive\.exec\.rowoffsethive\.variable\.substitutehive\.variable\.substitute\.depthhive\.autogen\.columnalias\.prefix\.includefuncnamehive\.autogen\.columnalias\.prefix\.labelhive\.exec\.check\.crossproductshive\.cli\.tez\.session\.asynchive\.compathive\.display\.partition\.cols\.separatelyhive\.error\.on\.empty\.partitionhive\.execution\.enginehive\.exec\.copyfile\.maxsizehive\.exim\.uri\.scheme\.whitelisthive\.file\.max\.footerhive\.insert\.into\.multilevel\.dirshive\.localize\.resource\.num\.wait\.attemptshive\.multi\.insert\.move\.tasks\.share\.dependencieshive\.query\.results\.cache\.enabledhive\.query\.results\.cache\.wait\.for\.pending\.resultshive\.support\.quoted\.identifiershive\.resultset\.use\.unique\.column\.nameshive\.analyze\.stmt\.collect\.partlevel\.statshive\.exec\.schema\.evolutionhive\.server2\.logging\.operation\.levelhive\.server2\.thrift\.resultset\.serialize\.in\.taskshive\.support\.special\.characters\.tablenamehive\.exec\.job\.debug\.capture\.stacktraceshive\.exec\.job\.debug\.timeouthive\.llap\.io\.enabledhive\.llap\.io\.use\.fileid\.pathhive\.llap\.daemon\.service\.hostshive\.llap\.execution\.modehive\.llap\.auto\.allow\.uberhive\.llap\.auto\.enforce\.treehive\.llap\.auto\.enforce\.vectorizedhive\.llap\.auto\.enforce\.statshive\.llap\.auto\.max\.input\.sizehive\.llap\.auto\.max\.output\.sizehive\.llap\.skip\.compile\.udf\.checkhive\.llap\.client\.consistent\.splitshive\.llap\.enable\.grace\.join\.in\.llaphive\.llap\.allow\.permanent\.fnshive\.exec\.max\.created\.fileshive\.exec\.reducers\.maxhive\.reorder\.nway\.joinshive\.output\.file\.extensionhive\.exec\.show\.job\.failure\.debug\.infohive\.exec\.tasklog\.debug\.timeouthive\.query\.idhive\.query\.tag 

hive.security.command.whitelist

升级前: set,reset,dfs,add,list,delete,reload,compile

升级后: set,reset,dfs,add,list,delete,reload,compile,llap

hive.server2.enable.doAs

升级前: TRUE (in case of an insecure cluster only)

升级后: FALSE (in all cases)

Affects only insecure clusters by turning off impersonation. Permission issues are expected to arise for affected clusters.

hive.server2.idle.session.timeout

升级前: 12 hours

升级后: 24 hours

Exception:Preserves pre-upgrade value if old default is overridden; otherwise, uses new default.

hive.server2.max.start.attempts

升级前: 30

升级后: 5

hive.server2.parallel.ops.in.session

升级前: TRUE

升级后: FALSE

A Tez limitation requires disabling this property; otherwise, queries submitted concurrently on a single JDBC connection fail or execute slower.

hive.server2.support.dynamic.service.discovery

升级前: FALSE

升级后: TRUE

hive.server2.tez.initialize.default.sessions

升级前: FALSE

升级后: TRUE

hive.server2.thrift.max.worker.threads

升级前: 100

升级后: 500

Exception: Preserves pre-upgrade value if the old default is overridden; otherwise, uses new default.

hive.server2.thrift.resultset.max.fetch.size

升级前: 1000

升级后: 10000

hive.service.metrics.file.location

升级前: /var/log/hive/metrics-hiveserver2/metrics.log

升级后: /var/log/hive/metrics-hiveserver2-hiveontez/metrics.log

This location change is due to a service name change.

hive.stats.column.autogather

升级前: FALSE

升级后: TRUE

hive.stats.deserialization.factor

升级前: 1

升级后: 10

hive.support.special.characters.tablename

升级前: FALSE

升级后: TRUE

hive.tez.auto.reducer.parallelism

升级前: FALSE

升级后: TRUE

hive.tez.bucket.pruning

升级前: FALSE

升级后: TRUE

hive.tez.container.size

升级前: -1

升级后: 4096

hive.tez.exec.print.summary

升级前: FALSE

升级后: TRUE

hive.txn.manager

升级前: org.apache.hadoop.hive.ql.lockmgr.DummyTxnManager

升级后: org.apache.hadoop.hive.ql.lockmgr.DbTxnManager

hive.vectorized.execution.mapjoin.minmax.enabled

升级前: FALSE

升级后: TRUE

hive.vectorized.execution.mapjoin.native.fast.hashtable.enabled

升级前: FALSE

升级后: TRUE

hive.vectorized.use.row.serde.deserialize

升级前: FALSE

升级后: TRUE

3.13自定义关键Hive配置

你会收到属性配置指南,包括升级后需要重新配置的属性。你了解哪个升级过程会从旧群集转移到新群集。

CDP升级过程将尝试保留你的Hive配置属性,这些属性是你在旧的CDH或HDP集群中给Hive的一些自定义的值。升级过程不会保留所以这些自定义配置,比如将保留为hive.exec.max.dynamic.partitions.pernode设置的自定义值。于其他属性,例如hive.cbo.enable,升级将忽略任何配置,而使用CDP的推荐值。

对于以下配置属性的自定义设置,CDP的升级过程不会保留:

  • hive.conf.hidden.list
  • hive.conf.restricted.list
  • hive.exec.post.hooks
  • hive.script.operator.env.blacklist
  • hive.security.authorization.sqlstd.confwhitelist
  • hive.security.command.whitelist

升级过程将忽略你的旧列表,并设置一个新的常规列表。例如hive.security.command.whitelist值是白名单上的安全命令列表。你在旧群集中设置的所有白名单均不会保留,升级到CDP后你仍然需要检查并更改新的默认值。新的默认列表可能比旧集群中使用的原始默认列表更短(限制更严格)。

实际你要重新的配置会大于上面列出的6个配置属性,因为即使你没有修改旧集群的配置默认值,CDP默认值也可能会以影响您工作的方式。

3.14覆盖设置Hive配置

对于旧的Hive集群中的自定义配置,你需要知道如何在升级过程中保留这些配置。根据记录的旧配置项,参考以下步骤至少设置6个关键属性值。

根据设计,这6个需要自定义的配置属性在Cloudera Manager中是不可见的,你需要使用Safety Valve来将这些属性添加到hive-site.xml中。

1.Cloudera Manager > Clusters,选择Hive on Tez服务,点击Configuration,搜索hive-site.xml。

2.在Hive Service Advanced Configuration Snippet (Safety Valve) for hive-site.xml中点击 +。

3.在Name中增加hive.conf.hidden.list属性。

4.在Value中增加自定义列表。

5.自定义其他关键属性:hive.conf.restricted.list, hive.exec.post.hooks, hive.script.operator.env.blacklist, hive.security.authorization.sqlstd.confwhitelist, hive.security.command.whitelist

6.保存配置并且重启Hive服务。

3.15Hive配置需求和推荐

升级后,你需要设置某些Hive和HiveServer(HS2)配置属性。你可以查看CDP Private Cloud Base的推荐配置,并了解升级后哪些配置保持不变,哪些会影响性能以及默认值。

下表包含升级过程会更改的Hive服务和HiveServer属性,其他未显示的属性值从CDH/HDP到CDP会保留。

  • Set After Upgrade:升级到CDP后需要手动配置的属性,升级后不会保留先前存在的自定义值。
  • Default Recommended:强烈建议升级后更改为新的值。
  • Impacts Performance:属性值会被升级过程调整,以提升性能。
  • Safety Value Overrides column:升级过程如何处理旧的Safety Valve配置
    • Disregards:升级过程将从新的CDP配置中删除所有旧的CDH Safety Valve configuration snippets。
    • Preserves:意味着升级过程会将所有旧的CDH snippets转移到新的CDP配置中。
    • Not applicable:意味着保留了旧参数的值。
  • Visible in CM column:升级后在Cloudera Manager中不可见该属性。

如果属性不可见,但你想对其进行配置,需要使用Cloudera Manager Safety Valve将参数添加到正确的文件中,比如添加到集群范围内的hive-site.xml文件中。

3.16使用YARN队列为ETL配置HiveServer

如果从CDH升级到CDP,如果还想运行ETL作业,则需要添加几个配置属性以允许将Hive工作负载放置在Yarn Queue Manager。

1.进入Cloudera Manager,点击Clusters > Hive on Tez > Configuration。

2.搜索Hive Service Advanced Configuration Snippet (Safety Valve) for hive-site.xml设置。

3.在Hive Service Advanced Configuration Snippet (Safety Valve) for hive-site.xml设置中,单击 +。

4.在Name中输入属性hive.server2.tez.initialize.default.sessions,将Value设置为false。

5.在Name中输入属性hive.server2.tez.queue.access.check,将Value设置为true。

6.在Name中输入属性hive.server2.tez.sessions.custom.queue.allowed,将Value设置为true。

3.17移除Hive on Spark配置

Hive on Spark不再受支持,所以你必须移除它。

在CDP中,没有Hive-Spark依赖项,Spark类库都不在classpath中。

1.升级到CDP之前

CDH支持Hive on Spark,然后通过set hive.execution.engine=spark来启用Hive on Spark。

2.升级到CDP之后

CDP不再支持Hive on Spark,启用Hive on Spark的脚本不起作用。

3.需要采取的行动

移除脚本中的set hive.execution.engine=spark

3.18更新Ranger的表策略

尽管升级过程不会更改外部表的位置,但是如果你在升级过程中移动了表,则需要了解访问HDFS中外部表的方法。

使用以下方法之一设置对HDFS中外部表的访问。

1.在Ranger中设置Hive HDFS策略(推荐)以包括指向外部表数据的路径。

2.设置一个HDFS ACL策略,将外部文本文件(例如,逗号分隔值(CSV)文件)存储在HDFS中,该文件将用作外部表的数据源。

3.19设置Access Control Lists

在CDP中,HDFS支持POSIX ACL(访问控制列表)为用户和组分配权限。代替Ranger策略,你可以使用HDFS ACL来检查HDFS权限更改并进行必要的更改。

在Ranger中,你根据用例为多个组和用户提供特定的权限。你将权限应用于目录树,而不是处理单个文件。

3.20配置加密区域安全

在某些情况下,你需要执行与安全性相关的任务,以允许访问存储在加密区域中的表,你将了解如何防止对这些表的访问问题。

在某些情况下,Hive on Tez无法对存储在加密区域中的表运行某些查询。当Hadoop密钥管理服务器(KMS)连接经过SSL加密并使用自签名证书时,请执行以下操作。

  • 请执行以下任一操作:
    • 将自签名的SSL证书安装到所有主机上的cacerts文件中,并跳过以下步骤。
    • 执行以下步骤。
  • 将ssl-client.xml复制到所有主机上可用的目录。
  • 在Cloudera Manager中,单机Clusters > Hive on Tez > Configuration. Clusters > Hive on Tez > Configuration。
  • 搜索Hive Service Advanced Configuration Snippet (Safety Valve) for hive-site.xml设置。
  • 在Hive Service Advanced Configuration Snippet (Safety Valve) for hive-site.xml设置中,单击 +。
  • Name设置为tez.aux.uris,Value设置为path-to-ssl-client.xml。

3.21对于Spark应用或者ETL使用HWC/Spark Direct Reader

HWC是随Spark应用程序一起启动的Spark库/插件,将Spark Direct Reader和HWC用于ETL。

Hive Warehouse Connector旨在从Spark访问托管的ACID v2 Hive表,Apache Ranger和HiveWarehouseConnector库提供对数据的行和列的细粒度访问,HWC支持spark-submit和pyspark,不支持Spark Thrift Server。

3.22配置HiveServer的HTTP Mode

如果使用Knox,则可能需要更改HTTP模式配置。如果在CDP Private Cloud Base中安装Knox,并想用Knox代理HiveServer,则需要将默认的HiveServer传输模式(hive.server2.transport.mode)从binary更改为http。

1.单击Cloudera Manager > Clusters > HIVE_ON_TEZ > Configuration

2.Search中输入transport

3.HiveServer2 Transport Mode选择http

4.保存并重启Hive on Tez。

3.23不支持的接口和功能

3.23.1不支持的接口

  • Druid
  • Hcat CLI
  • Hive CLI (replaced by Beeline)
  • Hive View
  • LLAP (available in CDP Public Cloud only)
  • MapReduce execution engine (replaced by Tez)
  • Pig
  • S3 (available in CDP Public Cloud only)
  • Spark execution engine (replaced by Tez)
  • Spark thrift server

Spark and Hive tables interoperate using the Hive Warehouse Connector.

  • SQL Standard Authorization
  • Tez View
  • WebHCat

你可以使用Hue代替Hive View。

3.23.2不支持的特性

CDP不支持HDP和CDH平台中可用的以下功能:

  • CREATE TABLE,并指定托管表(内部表)的位置

不要使用LOCATION子句创建托管表,对于托管表Hive会分配默认的位置。

  • CREATE INDEX

Hive自动在主表(而不是其他表)中的ORC或Parquet中构建和存储索引,将hive.optimize.index.filter启用即可,不过不推荐使用,而是使用物化视图。升级时,Parquet或ORC中的现有索引也会被迁移到CDP中。

3.23.3不支持的连接器使用

CDP不支持使用Teradata文档中的Hadoop jar命令(Java API)进行Sqoop导出。

3.24CDH表的更改

CDH升级到CDP后,现有表的位置不会更改,将CDH升级到CDP Private Cloud Base可将Hive托管表(内部表)转换为Hive 3中的外部表。

升级过程将托管表转换为外部表时,会将表属性external.table.purge设置为true,该表等效于在旧CDH集群中将purge设置为true的托管表。

托管表以前保存在HDFS的/user/hive/warehouse中,升级完成并转化为外表成功后,依旧会保存在这个位置。升级完成以后Hive仓库的位置由hive.metastore.warehouse.dir属性决定,在CDP中创建的新的托管表会保存到该位置。

升级之前的外部表不会被重定位,你需要在Ranger中设置HDFS策略或者HDFS ACL来访问这些表。

你可以使用Cloudera Manager中的Hive Metastore Action菜单更改仓库的位置。

  • Hive > Action Menu > Create Hive Warehouse Directory
  • Hive > Action Menu > Create Hive Warehouse External Directory

升级过程中,会默认将原来CDH的内部表转化为CDP的外部表。

CDP-PvC 7.1.4新特性:可以通过参数配置,使用legacy的方式创建表,即create table创建外部表,非ACID表。

具体请参考:

https://docs.cloudera.com/cdp-private-cloud-base/7.1.4/configuring-apache-hive/topics/hive_create_table_default.html
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-10-29,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Hadoop实操 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
专用宿主机
专用宿主机(CVM Dedicated Host,CDH)提供用户独享的物理服务器资源,满足您资源独享、资源物理隔离、安全、合规需求。专用宿主机搭载了腾讯云虚拟化系统,购买之后,您可在其上灵活创建、管理多个自定义规格的云服务器实例,自主规划物理资源的使用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档