99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
首頁大數(shù)據(jù)時(shí)代Hadoop數(shù)據(jù)傾斜產(chǎn)生的原因是什么?如何進(jìn)行處理?
Hadoop數(shù)據(jù)傾斜產(chǎn)生的原因是什么?如何進(jìn)行處理?
2020-07-20
收藏

大數(shù)據(jù)處理時(shí)我們經(jīng)常會遇到數(shù)據(jù)傾斜的問題,尤其是在數(shù)據(jù)量過大時(shí),數(shù)據(jù)傾斜可能會導(dǎo)致各種各樣的問題。Hadoop數(shù)據(jù)傾斜主要表現(xiàn)為:ruduce階段卡在99.99%,而且是一直99.99%不能結(jié)束。

具體來說就是:mapreduce程序執(zhí)行時(shí),reduce節(jié)點(diǎn)大部分已經(jīng)執(zhí)行完畢,但是其中會有一個(gè)或者幾個(gè)reduce節(jié)點(diǎn)運(yùn)行速度很慢,從而使得整個(gè)程序的處理時(shí)間很長。原因是:某一個(gè)key的條數(shù)比其他key多出太多,因此這條key所在的reduce節(jié)點(diǎn)所處理的數(shù)據(jù)量就比其他節(jié)點(diǎn)就大很多,這也就造成了某幾個(gè)節(jié)點(diǎn)遲遲運(yùn)行不完。由于Hive是分階段執(zhí)行的,map處理數(shù)據(jù)量的差異,取決于上一個(gè)stage的reduce輸出,因此將數(shù)據(jù)均勻的分配到各個(gè)reduce中,這一點(diǎn)是解決數(shù)據(jù)傾斜的關(guān)鍵。

一、Hadoop數(shù)據(jù)傾斜常見情形

二、Hadoop數(shù)據(jù)傾斜產(chǎn)生原因

1.Hadoop框架的特性

A、Hadoop不怕數(shù)據(jù)大,但是怕數(shù)據(jù)傾斜

B、Jobs 數(shù)多的作業(yè)運(yùn)行效率會相對比較低

C、countdistinct、group by、join等操作,觸發(fā)了Shuffle動作,導(dǎo)致全部相同key的值聚集在一個(gè)或幾個(gè)節(jié)點(diǎn)上,很容易發(fā)生單點(diǎn)問題。

2.具體原因

A:key 分布不均勻,某一個(gè)key的條數(shù)比其他key多太多

B:業(yè)務(wù)數(shù)據(jù)自帶的特性

C:建表時(shí)考慮不全面

D:可能某些 HQL 語句自身就存在數(shù)據(jù)傾斜 問題

三、Hadoop數(shù)據(jù)傾斜處理

1、從業(yè)務(wù)和數(shù)據(jù)方面解決數(shù)據(jù)傾斜

(1)有損的方法:找到異常數(shù)據(jù)。

(2)無損的方法:

對分布不均勻的數(shù)據(jù),進(jìn)行單獨(dú)計(jì)算

首先對key做一層hash,把數(shù)據(jù)打散,讓它的并行度變大,之后進(jìn)行匯集

(3)數(shù)據(jù)預(yù)處理

2、Hadoop平臺的解決方法

(1)針對join產(chǎn)生的數(shù)據(jù)傾斜

A.大表和小表join產(chǎn)生的數(shù)據(jù)傾斜

a.在多表關(guān)聯(lián)情況下,將小表(關(guān)聯(lián)鍵記錄少的表)依次放到前面,這樣能夠觸發(fā)reduce端減少操作次數(shù),從而減少運(yùn)行時(shí)間。

b.同時(shí)使用Map Join讓小表緩存到內(nèi)存。在map端完成join過程,這樣就能省掉redcue端的工作。需要注意:這一功能使用時(shí),需要開啟map-side join的設(shè)置屬性:set hive.auto.convert.join=true(默認(rèn)是false)

還可以對使用這個(gè)優(yōu)化的小表的大小進(jìn)行設(shè)置:set hive.mapjoin.smalltable.filesize=25000000(默認(rèn)值25M)

B.大表和大表的join產(chǎn)生的數(shù)據(jù)傾斜

a.j將異常值賦一個(gè)隨機(jī)值,以此來分散key,均勻分配給多個(gè)reduce去執(zhí)行

b.如果key值都是有效值的情況下,需要設(shè)置以下幾個(gè)參數(shù)來解決

set hive.exec.reducers.bytes.per.reducer = 1000000000

也就是每個(gè)節(jié)點(diǎn)的reduce,其 默認(rèn)是處理數(shù)據(jù)地大小為1G,如果join 操作也產(chǎn)生了數(shù)據(jù)傾斜,那么就在hive 中設(shè)定

set hive.optimize.skewjoin = true;

set hive.skewjoin.key = skew_key_threshold (default = 100000)

(2)group by 造成的數(shù)據(jù)傾斜

解決方式相對簡單:

hive.map.aggr=true  (默認(rèn)true) 這個(gè)配置項(xiàng)代表是否在map端進(jìn)行聚合,相當(dāng)于Combiner

hive.groupby.skewindata

(3)count(distinct)或者其他參數(shù)不當(dāng)造成的數(shù)據(jù)傾斜

A.reduce個(gè)數(shù)太少

set mapred.reduce.tasks=800

B.HiveQL中包含count(distinct)時(shí)

使用sum...group byl來替代。例如select a,sum(1) from (select a, b from t group by a,b) group by a;

數(shù)據(jù)分析咨詢請掃描二維碼

若不方便掃碼,搜微信號:CDAshujufenxi

數(shù)據(jù)分析師資訊
更多

OK
客服在線
立即咨詢
客服在線
立即咨詢
') } function initGt() { var handler = function (captchaObj) { captchaObj.appendTo('#captcha'); captchaObj.onReady(function () { $("#wait").hide(); }).onSuccess(function(){ $('.getcheckcode').removeClass('dis'); $('.getcheckcode').trigger('click'); }); window.captchaObj = captchaObj; }; $('#captcha').show(); $.ajax({ url: "/login/gtstart?t=" + (new Date()).getTime(), // 加隨機(jī)數(shù)防止緩存 type: "get", dataType: "json", success: function (data) { $('#text').hide(); $('#wait').show(); // 調(diào)用 initGeetest 進(jìn)行初始化 // 參數(shù)1:配置參數(shù) // 參數(shù)2:回調(diào),回調(diào)的第一個(gè)參數(shù)驗(yàn)證碼對象,之后可以使用它調(diào)用相應(yīng)的接口 initGeetest({ // 以下 4 個(gè)配置參數(shù)為必須,不能缺少 gt: data.gt, challenge: data.challenge, offline: !data.success, // 表示用戶后臺檢測極驗(yàn)服務(wù)器是否宕機(jī) new_captcha: data.new_captcha, // 用于宕機(jī)時(shí)表示是新驗(yàn)證碼的宕機(jī) product: "float", // 產(chǎn)品形式,包括:float,popup width: "280px", https: true // 更多配置參數(shù)說明請參見:http://docs.geetest.com/install/client/web-front/ }, handler); } }); } function codeCutdown() { if(_wait == 0){ //倒計(jì)時(shí)完成 $(".getcheckcode").removeClass('dis').html("重新獲取"); }else{ $(".getcheckcode").addClass('dis').html("重新獲取("+_wait+"s)"); _wait--; setTimeout(function () { codeCutdown(); },1000); } } function inputValidate(ele,telInput) { var oInput = ele; var inputVal = oInput.val(); var oType = ele.attr('data-type'); var oEtag = $('#etag').val(); var oErr = oInput.closest('.form_box').next('.err_txt'); var empTxt = '請輸入'+oInput.attr('placeholder')+'!'; var errTxt = '請輸入正確的'+oInput.attr('placeholder')+'!'; var pattern; if(inputVal==""){ if(!telInput){ errFun(oErr,empTxt); } return false; }else { switch (oType){ case 'login_mobile': pattern = /^1[3456789]\d{9}$/; if(inputVal.length==11) { $.ajax({ url: '/login/checkmobile', type: "post", dataType: "json", data: { mobile: inputVal, etag: oEtag, page_ur: window.location.href, page_referer: document.referrer }, success: function (data) { } }); } break; case 'login_yzm': pattern = /^\d{6}$/; break; } if(oType=='login_mobile'){ } if(!!validateFun(pattern,inputVal)){ errFun(oErr,'') if(telInput){ $('.getcheckcode').removeClass('dis'); } }else { if(!telInput) { errFun(oErr, errTxt); }else { $('.getcheckcode').addClass('dis'); } return false; } } return true; } function errFun(obj,msg) { obj.html(msg); if(msg==''){ $('.login_submit').removeClass('dis'); }else { $('.login_submit').addClass('dis'); } } function validateFun(pat,val) { return pat.test(val); }