0816-CDP Hive3升級說明

文檔編寫目的



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 <tableTO 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

本文分享自微信公衆號 - Hadoop實操(gh_c4c535955d0f)。
如有侵權,請聯繫 [email protected] 刪除。
本文參與“OSC源創計劃”,歡迎正在閱讀的你也加入,一起分享。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章