2018-05-01

link https://lihaimei.wordpress.com/2014/11/05/hbase-1-opentsdb-table-design/#respond

http://opentsdb.net/docs/build/html/user_guide/uids.html

HBase (1): OpenTSDB Table?Design

Leave a reply

Why we need to learn OpenTSDB? Is it good study case for us to know how to design HBase Table? For me, I would totally say yes. There are many good optimizations which already are applied to OpenTSDB, this open source project. So this post will only say how does OpenTSDB design the HBase table, not focus on how to use OpenTSDB or how to implement?OpenTSDB ?to monitor server. Maybe in the future, I will write down this part.

So first, Let’s simply know some basic concepts in OpenTSDB.

What is OpenTSDB?

It is the distributed, scalable, time series database which is for modern monitor needs. It can collect, store and serve billion data points with no less of precision, can be used with Tcollector. Here are two key points, one is time series, the other is billion data. So timestamp is important point in OpenTSDB, and there are many data points which OpenTSDB needs to deal with. (That’s the main reason we need to learn OpenTSDB’s design; we are also facing big data and time is also significant field for the data)

Even though OpenTSDB is open source project, it is also used many other big companies, including Yahoo, Ebay, Pinterest, and so on.

Some Concepts

data points: (time, value)

metrics:?proc.loadavg.cpu

tags: hosts=haimeili, ip=127.0.0.1

metric + tags = time series

There are two tables which OpenTSDB use to store data, one is tsdb, the other is tsdb-uid. Currently, it already have two additional tables, named tsdb-meta, tsdb-tree.(new in OpenTSDB 2.0)

tsdb-uid

This table is to map uid to name or map name to uid. There are only three kinds of qualifiers: metric, tagk and tagv. We need to remember that this is two ways, one is from uid to name, the other is from name to uid. Here is the example,


tsdb

tsdb is the main table to store data point. Its rowkey is a concatenation of uids and time.

This is rowkey format: ….

Timestamp normalized on 1 hour boundaries

All data points for an hour are stored in one row

There are two qualifer formats, one is 2 bytes, the other is 4 bytes. For 2 bytes, it looks like this: <12 bits><4bits>. The first 12 bits is to store min-second information.?the 4 bits is a flag, first 1 bit is to tell the value is integer or double, the rest three bits is to tell the length of the value from 0 to 8 bytes. e.g. “000” means 1 byte value, “010” means 2 bytes value, etc. For 4 bytes, it looks like this: <4 bits><22 bits><2 bits><4 bits>. The first 4 bits is “0000” or “1111”. The 22 bits is the min-second information. The last 4 bits is flag which is the same with above.

Here is one example:

1297574486 = 2011-02-13 13:21:26 ? ?

MWeP = 01001101 01010111 01100101 01010000 = 1297573200 = 2011-02-13 13:00:00 (only select hours and cut down mins which will be stored in qualifier)

PK = 01010000 01101011 = 1286 (1286 seconds = 21 mins 26 seconds)1297573200+1286=1297574486


Summary

When you design table for big table, you need to consider to use concatenation method to save space. If you have time-based data, you need to think about the position to store timestamp, and whether you want to store the data for per second or per minute. Also if your data is not good format, or too long, or you have the list of data, you might need to map data to a uid to save space.

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末垂寥,一起剝皮案震驚了整個(gè)濱河市坏匪,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌宜鸯,老刑警劉巖腾供,帶你破解...
    沈念sama閱讀 221,888評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件仆邓,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡伴鳖,警方通過(guò)查閱死者的電腦和手機(jī)节值,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,677評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門(mén),熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)榜聂,“玉大人搞疗,你說(shuō)我怎么就攤上這事⌒胨粒” “怎么了匿乃?”我有些...
    開(kāi)封第一講書(shū)人閱讀 168,386評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)豌汇。 經(jīng)常有香客問(wèn)我幢炸,道長(zhǎng),這世上最難降的妖魔是什么拒贱? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 59,726評(píng)論 1 297
  • 正文 為了忘掉前任宛徊,我火速辦了婚禮佛嬉,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘闸天。我一直安慰自己暖呕,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,729評(píng)論 6 397
  • 文/花漫 我一把揭開(kāi)白布号枕。 她就那樣靜靜地躺著缰揪,像睡著了一般。 火紅的嫁衣襯著肌膚如雪葱淳。 梳的紋絲不亂的頭發(fā)上钝腺,一...
    開(kāi)封第一講書(shū)人閱讀 52,337評(píng)論 1 310
  • 那天,我揣著相機(jī)與錄音赞厕,去河邊找鬼艳狐。 笑死,一個(gè)胖子當(dāng)著我的面吹牛皿桑,可吹牛的內(nèi)容都是我干的毫目。 我是一名探鬼主播,決...
    沈念sama閱讀 40,902評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼诲侮,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼镀虐!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起沟绪,我...
    開(kāi)封第一講書(shū)人閱讀 39,807評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤刮便,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后绽慈,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體恨旱,經(jīng)...
    沈念sama閱讀 46,349評(píng)論 1 318
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,439評(píng)論 3 340
  • 正文 我和宋清朗相戀三年坝疼,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了搜贤。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,567評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡钝凶,死狀恐怖仪芒,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情腿椎,我是刑警寧澤桌硫,帶...
    沈念sama閱讀 36,242評(píng)論 5 350
  • 正文 年R本政府宣布,位于F島的核電站啃炸,受9級(jí)特大地震影響铆隘,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜南用,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,933評(píng)論 3 334
  • 文/蒙蒙 一膀钠、第九天 我趴在偏房一處隱蔽的房頂上張望掏湾。 院中可真熱鬧,春花似錦肿嘲、人聲如沸融击。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 32,420評(píng)論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)尊浪。三九已至,卻和暖如春封救,著一層夾襖步出監(jiān)牢的瞬間拇涤,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 33,531評(píng)論 1 272
  • 我被黑心中介騙來(lái)泰國(guó)打工誉结, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留鹅士,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,995評(píng)論 3 377
  • 正文 我出身青樓惩坑,卻偏偏與公主長(zhǎng)得像掉盅,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子以舒,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,585評(píng)論 2 359

推薦閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,345評(píng)論 0 10
  • 每個(gè)人內(nèi)心都會(huì)有一個(gè)黑暗地帶 不允許別人觸碰 偶爾 甚至不允許自己踏足那里 噢 或者也不 甚至?xí)辉试S它的存在吧
    你喜不喜歡吃橘子閱讀 123評(píng)論 0 0
  • 本文根據(jù)眾多互聯(lián)網(wǎng)博客內(nèi)容整理后形成趾痘,引用內(nèi)容的版權(quán)歸原始作者所有,僅限于學(xué)習(xí)研究使用蔓钟,不得用于任何商業(yè)用途扼脐。 原...
    深紅的眼眸閱讀 1,319評(píng)論 0 0
  • 其 實(shí) 每 一 篇 文 章 都 是 無(wú) 題 如果魚(yú)缸的四面八方都是鏡子,魚(yú)會(huì)不會(huì)以為自己在浩瀚無(wú)盡的大海徜徉奋刽。 ...
    紅塔閱讀 223評(píng)論 0 1