免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
大數(shù)據(jù)技術(shù)分享:Hbase精解

為什么有hbase?hbase是什么?Hbase的架構(gòu)。

  一、 為什么有hbase?

  數(shù)據(jù)量越來越大,傳統(tǒng)的關(guān)系型數(shù)據(jù)庫不能滿足存儲和查詢的需求。而hive雖然能滿足存儲的要求,但是hive不能滿足非結(jié)構(gòu)化、半結(jié)構(gòu)化數(shù)據(jù)的存儲和查詢。

  二、hbase是什么?

  hbase是一個開源的、分布式的、多版本的、可擴展的非關(guān)系型數(shù)據(jù)庫。hbasebigtable的開源java版本,建立在hdfs之上,提供高可靠性的、高性能、列式存儲、可伸縮、實時讀寫的nosql數(shù)據(jù)庫系統(tǒng)。適用的場景如:需要對海量非結(jié)構(gòu)化的數(shù)據(jù)進(jìn)行存儲。

  需要隨機近實時的讀寫管理數(shù)據(jù)。

  三、hbase的架構(gòu)

  client\zookeeper\hmaster\

  hregionserver\hlog\hregion\memstore\storefile\hfile

  clienthbase的客戶端,包含訪問hbase的接口(linux shell 、java api)

  client維護(hù)一些cache來加快訪問hbase的速度,比如region的位置信息。

  zookeeper:監(jiān)控hmaster的狀態(tài),保證有些僅有一個activehmaster,達(dá)到高可用。存儲所有region的尋址入口,--root表在那臺服務(wù)器上。實時監(jiān)控hregionserver的狀態(tài),將regionserver的上下線信息實時通知給hmaster。存儲hbase的所有表的信息(hbase的元數(shù)據(jù))

  hmaster(hbase的老大)regionserver分配region(新建表等)。負(fù)責(zé)regionserver的負(fù)載均衡。負(fù)責(zé)region的重新分配(hregionserver異常、hregion裂變)。hdfs上的垃圾文件回收。處理schema的更新請求。

  hregionserver(hbase的小弟)hregionserver維護(hù)master分配給他的region(管理本機器上region)。處理client對這些regionIO請求,并和hdfs進(jìn)行交互

  region server負(fù)責(zé)切分在運行過程中變大的region

  hlog:對hbase的操作進(jìn)行記錄,使用WAL寫數(shù)據(jù),優(yōu)先寫入log,然后再寫入memstore,以防數(shù)據(jù)丟死可以進(jìn)行回滾。

  hregionhbase中分布式存儲和負(fù)載均衡的最小單元,表或者表的一部分。

  store:相當(dāng)于一個列簇。

  memstore128M內(nèi)存緩沖區(qū),用于將數(shù)據(jù)批量刷新到hdfs上。

  hstorefile(hfile)hbase中的數(shù)據(jù)是以hfile的形式存儲在hdfs上。

  各組件間的數(shù)量關(guān)系:

  hmaster:hregionserver=1:n

  hregionserver:hregion=1:n

  hregionserver:hlog=1:1

  hregion:hstore=1:n

  store:memstore=1:1

  store:storefile=1:n

  storefile:hfile=1:1

  hbase關(guān)鍵字詞:

  rowkey:行鍵,和mysql的主鍵是一樣的,不允許重復(fù),有順序。

  columnfamily:列簇(列的集合)。

  column:列。

  timestamp:時間戳,默認(rèn)顯示最新的時間戳。

  version:版本號。

  cell:單元格。

  四、hbasehadoop的關(guān)系

  hbase是基于hadoophbase的存儲依賴于hdfs。具體說hbase的特點:

  模式:無模式。

  數(shù)據(jù)類型:單一 byte[]。

  多版本:每個值都可以有多個版本。

  列式存儲:一個列簇存儲到一個目錄。

  稀疏存儲:如果key-valuenull,則將不占用存儲空間。

  再說hbase的安裝:

  1、standalone模式

  1)解壓并配置環(huán)境變量

  tar -zxvf hbase-1.2.1-bin.tar.gz -C /usr/local

  cd /usr/local

  vi /etc/profile

  source /etc/profile

  2)測試hbase的安裝

  hbase version

  配置hbase的配置文件

  vi conf/hbase-env.sh

  JAVA_HOME

  注意:

  # Configure PermSize. Only needed in JDK7. You can safely remove it for JDK8+

  export HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS -XX:PermSize=128m -XX:MaxPermSize=128m"。

  export HBASE_REGIONSERVER_OPTS="$HBASE_REGIONSERVER_OPTS -XX:PermSize=128m -XX:MaxPermSize=128m"。

  vi hbase-site.xml

  hbase.rootdir

  file:///usr/local/hbasedata

  hbase.zookeeper.property.dataDir

  /usr/local/zookeeperdata

  啟動hbase服務(wù):

  bin/start-hbase/sh

  啟動客戶端:

  bin/hbase shell

  2、偽分布式

  3、全分布式

  解壓并配置環(huán)境變量

  配置hbase的配置文件

  vi conf/hbase-env.sh

  export HBASE_MANAGES_ZK=false

  vi regionservers

  vi backup-masters

  vi hbase-site.xml

  hbase.cluster.distributed

  true

  hbase.rootdir

  hdfs://qianfeng/hbase

  hbase.zookeeper.property.dataDir

  /usr/local/zookeeperdata

  hbase.zookeeper.quorum

  hadoop05:2181,hadoop06:2181,hadoop07:2181

  注意:

  如果hdfs是高可用的,要講hadoop下的core-site.xmlhdfs-site.xml copyhbase/conf目錄下。

  分發(fā):

  scp -r hbase-1.2.1 root@hadoop06:$PWD

  scp -r hbase-1.2.1 root@hadoop07:$PWD

  啟動:

  1)啟動zk

  2)啟動hdfs

  3)啟動hbase

  hbase集群的時間必須同步。

  hmaster16010

  hregionserver16030

  hbaseshell操作

  help

  help "COMMAND"

  help "COMMAND_GROUP"

  列舉出當(dāng)前namespace下的所有表

  list

  創(chuàng)建表:

  create 'test','f1', 'f2'

  namespace

  hbase沒有庫的概念,但是有名稱空間或者組的概念,namespace相當(dāng)于()

  hbase默認(rèn)有兩個組:

  default

  hbase

  列舉出所有的namespcae

  list_namespace

  list_namespace_tables 'hbase'

  create_namespace 'ns1'

  describe_namespace 'ns1'

  alter_namespace 'ns1', {METHOD => 'set', 'NAME' => 'gjz1'}

  alter_namespace 'ns1', {METHOD => 'unset', NAME => 'NAME'}

  drop_namespace 'ns1' ###只能刪除一個空的namespace

  DDL:

  Group name: ddl

  Commands: alter, alter_async, alter_status, create, describe, disable, disable_all, drop, drop_all, enable, enable_all, exists, get_table, is_disabled, is_enabled, list, locate_region, show_filters

  創(chuàng)建表:

  create 'test','f1', 'f2'

  create 'ns1:t_userinfo',{NAME=>'base_info',BLOOMFILTER => 'ROWCOL',VERSIONS => '3'}

  create 'ns1:t1', 'f1', SPLITS => ['10', '20', '30', '40'] --事先分配好region所管轄的rowkey的范圍。

  修改表:(有則更新,無則新增)

  alter 'ns1:t_userinfo',{NAME=>'extra_info',BLOOMFILTER => 'ROW',VERSIONS => '2'}

  alter 'ns1:t_userinfo',{NAME=>'extra_info',BLOOMFILTER => 'ROWCOL',VERSIONS => '5'}

  刪除列簇:

  alter 'ns1:t_userinfo', NAME => 'extra_info', METHOD => 'delete'

  alter 'ns1:t_userinfo', 'delete' => 'base_info'

  刪除表:(先要禁用表)

  disable 'ns1:t1'

  drop 'ns1:t1'

  DML:

  Group name: dml

  Commands: append, count, delete, deleteall, get, get_counter, get_splits, incr, put, scan, truncate, truncate_preserve

  插入數(shù)據(jù):(不能一次性插入多列)

  put 'ns1:test','u00001','cf1:name','zhangsan'

  put 'ns1:t_userinfo','rk00001','base_info:name','gaoyuanyuan'

  put 'ns1:t_userinfo','rk00001','extra_info:pic','picture'

  更新數(shù)據(jù):

  put 'ns1:t_userinfo','rk00001','base_info:name','zhouzhiruo'

  put 'ns1:t_userinfo','rk00002','base_info:name','zhaoming'

  表掃描(scan)

  scan 'ns1:t_userinfo'

  scan 'ns1:t_userinfo',{COLUMNS => ['base_info:name','base_info:age']}

  設(shè)置查詢條件:(包頭不包尾)

  scan 'ns1:t_userinfo',{COLUMNS => ['base_info:name','base_info:age'],STARTROW=>'rk000012',LIMIT=>2}

  scan 'ns1:t_userinfo',{COLUMNS => ['base_info:name','base_info:age'],STARTROW=>'rk000012',ENDROW=>'rk00002',LIMIT=>2}

  查詢數(shù)據(jù):(GET)

  get 'ns1:t_userinfo','rk00001'

  get 'ns1:t_userinfo','rk00001',{TIMERANGE=>[1534136591897,1534136667747]}

  get 'ns1:t_userinfo','rk00001',{COLUMN=>['base_info:name','base_info:age'],VERSIONS =>4}

  get 'ns1:t_userinfo','rk00001',{TIMESTAMP=>1534136580800}

  刪除數(shù)據(jù):(DELETE)

  delete 'ns1:t_userinfo','rk00002','base_info:age'

  'ns1:t_userinfo','rk00001',{TIMERANGE=>[1534138686498,1534138738862]}

  刪除指定的版本:(往上刪除版本)

  delete 'ns1:t_userinfo','rk00001','base_info:name',TIMESTAMP=>1534138686498

  表判斷:

  exists 'ns1:t_userinfo'

  disable 'ns1:t_userinfo'

  enable 'ns1:t_userinfo'

  desc 'ns1:t_userinfo'

  統(tǒng)計表:(統(tǒng)計效率較差,不建議使用)

  count 'ns1:t_userinfo'

  清空表:

  truncate 'ns1:test'

  學(xué)習(xí)大數(shù)據(jù)開發(fā),內(nèi)容包含Linux&&Hadoop生態(tài)體系、大數(shù)據(jù)計算框架體系、云計算體系、機器學(xué)習(xí)&&深度學(xué)習(xí)。

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
HBase技術(shù)介紹
多圖技術(shù)貼:深入淺出解析大數(shù)據(jù)平臺架構(gòu) | 36大數(shù)據(jù)
[翻譯]HBase 架構(gòu)101 –預(yù)寫日志系統(tǒng) (WAL)
HBase 系統(tǒng)架構(gòu)
01-Hbase環(huán)境搭建、shell和API訪問實現(xiàn)
HDFS Federation(聯(lián)邦)簡介
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服