最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

HBase 快速入門(mén)

2023-02-21 12:12 作者:Cool_army  | 我要投稿

2.1 HBase 安裝部署

2.1.1 Zookeeper 正常部署

首先保證 Zookeeper 集群的正常部署,并啟動(dòng)之。

[atguigu@hadoop102 zookeeper-3.5.7]$ bin/zkServer.sh start [atguigu@hadoop103 zookeeper-3.5.7]$ bin/zkServer.sh start [atguigu@hadoop104 zookeeper-3.5.7]$ bin/zkServer.sh start

2.1.2 Hadoop 正常部署

Hadoop 集群的正常部署并啟動(dòng)。

?[atguigu@hadoop102 hadoop-3.1.3]$ sbin/start-dfs.sh [atguigu@hadoop103 hadoop-3.1.3]$ sbin/start-yarn.sh

2.1.3 HBase 的解壓

1)解壓 Hbase 到指定目錄

[atguigu@hadoop102 software]$ tar -zxvf hbase-2.4.11-bin.tar.gz -C /opt/module/ [atguigu@hadoop102 software]$ mv /opt/module/hbase-2.4.11 /opt/module/hbase

2)配置環(huán)境變量

?[atguigu@hadoop102 ~]$ sudo vim /etc/profile.d/my_env.sh

添加

#HBASE_HOME export HBASE_HOME=/opt/module/hbase export PATH=$PATH:$HBASE_HOME/bin

3)使用 source 讓配置的環(huán)境變量生效

[atguigu@hadoop102 module]$ source /etc/profile.d/my_env.sh

2.1.4 HBase 的配置文件

1)hbase-env.sh 修改內(nèi)容,可以添加到最后:

?export HBASE_MANAGES_ZK=false

2)hbase-site.xml 修改內(nèi)容:

hbase.zookeeper.quorum hadoop102,hadoop103,hadoop104 The directory shared by RegionServers. hbase.rootdir hdfs://hadoop102:8020/hbase The directory shared by RegionServers. hbase.cluster.distributed true

3)regionservers

hadoop102 hadoop103 hadoop104

4)解決 HBase 和 Hadoop 的 log4j 兼容性問(wèn)題,修改 HBase 的 jar 包,使用 Hadoop 的 jar 包

?[atguigu@hadoop102 hbase]$ mv /opt/module/hbase/lib/client-facingthirdparty/slf4j-reload4j-1.7.33.jar /opt/module/hbase/lib/clientfacing-thirdparty/slf4j-reload4j-1.7.33.jar.bak2.1.5 HBase 遠(yuǎn)程發(fā)送到其他集群

?[atguigu@hadoop102 module]$ xsync hbase/

2.1.6 HBase 服務(wù)的啟動(dòng)

1)單點(diǎn)啟動(dòng)

[atguigu@hadoop102 hbase]$ bin/hbase-daemon.sh start master [atguigu@hadoop102 hbase]$ bin/hbase-daemon.sh start regionserver

2)群?jiǎn)?/p>

?[atguigu@hadoop102 hbase]$ bin/start-hbase.sh

3)對(duì)應(yīng)的停止服務(wù)

[atguigu@hadoop102 hbase]$ bin/stop-hbase.sh

2.1.7 查看 HBase 頁(yè)面

啟動(dòng)成功后,可以通過(guò)“host:port”的方式來(lái)訪問(wèn) HBase 管理頁(yè)面,例如:http://hadoop102:16010/

2.1.8 高可用(可選)

在 HBase 中 HMaster 負(fù)責(zé)監(jiān)控 HRegionServer 的生命周期,均衡 RegionServer 的負(fù)載, 如果 HMaster 掛掉了,那么整個(gè) HBase 集群將陷入不健康的狀態(tài),并且此時(shí)的工作狀態(tài)并不 會(huì)維持太久。所以 HBase 支持對(duì) HMaster 的高可用配置。

1)關(guān)閉 HBase 集群(如果沒(méi)有開(kāi)啟則跳過(guò)此步)

?[atguigu@hadoop102 hbase]$ bin/stop-hbase.sh

2)在 conf 目錄下創(chuàng)建 backup-masters 文件

?[atguigu@hadoop102 hbase]$ touch conf/backup-masters

3)在 backup-masters 文件中配置高可用 HMaster 節(jié)點(diǎn)

?[atguigu@hadoop102 hbase]$ echo hadoop103 > conf/backup-masters

4)將整個(gè) conf 目錄 scp 到其他節(jié)點(diǎn)

[atguigu@hadoop102 hbase]$ xsync conf

5)重啟 hbase,打開(kāi)頁(yè)面測(cè)試查看

http://hadooo102:16010/

2.2 HBase Shell 操作

2.2.1 基本操作

1)進(jìn)入 HBase 客戶(hù)端命令行

?[atguigu@hadoop102 hbase]$ bin/hbase shell

2)查看幫助命令 能夠展示 HBase 中所有能使用的命令,主要使用的命令有 namespace 命令空間相關(guān), DDL 創(chuàng)建修改表格,DML 寫(xiě)入讀取數(shù)據(jù)。

hbase:001:0> help

2.2.2 namespace

1)創(chuàng)建命名空間 使用特定的 help 語(yǔ)法能夠查看命令如何使用。

hbase:002:0> help 'create_namespace'

2)創(chuàng)建命名空間 bigdata

hbase:003:0> create_namespace 'bigdata'

3)查看所有的命名空間

hbase:004:0> list_namespace

2.2.3 DDL

1)創(chuàng)建表

在 bigdata 命名空間中創(chuàng)建表格 student,兩個(gè)列族。info 列族數(shù)據(jù)維護(hù)的版本數(shù)為 5 個(gè), 如果不寫(xiě)默認(rèn)版本數(shù)為 1。

hbase:005:0> create 'bigdata:student', {NAME => 'info', VERSIONS => 5}, {NAME => 'msg'} 如果創(chuàng)建表格只有一個(gè)列族,沒(méi)有列族屬性,可以簡(jiǎn)寫(xiě)。

如果不寫(xiě)命名空間,使用默認(rèn)的命名空間 default。

hbase:009:0> create 'student1','info'

2)查看表

查看表有兩個(gè)命令:list 和 describe

list:查看所有的表名

hbase:013:0> list describe:查看一個(gè)表的詳情

hbase:014:0> describe 'student1'

3)修改表

表名創(chuàng)建時(shí)寫(xiě)的所有和列族相關(guān)的信息,都可以后續(xù)通過(guò) alter 修改,包括增加刪除列 族。

(1)增加列族和修改信息都使用覆蓋的方法

?hbase:015:0> alter 'student1', {NAME => 'f1', VERSIONS => 3}

(2)刪除信息使用特殊的語(yǔ)法

hbase:015:0> alter 'student1', NAME => 'f1', METHOD => 'delete'

hbase:016:0> alter 'student1', 'delete' => 'f1'

4)刪除表

shell 中刪除表格,需要先將表格狀態(tài)設(shè)置為不可用。

hbase:017:0> disable 'student1'

hbase:018:0> drop 'student1'

2.2.4 DML

1)寫(xiě)入數(shù)據(jù)

?在 HBase 中如果想要寫(xiě)入數(shù)據(jù),只能添加結(jié)構(gòu)中最底層的 cell。可以手動(dòng)寫(xiě)入時(shí)間戳指 定 cell 的版本,推薦不寫(xiě)默認(rèn)使用當(dāng)前的系統(tǒng)時(shí)間。

hbase:019:0> put 'bigdata:student','1001','info:name','zhangsan'

hbase:020:0> put 'bigdata:student','1001','info:name','lisi'

hbase:021:0> put 'bigdata:student','1001','info:age','18'

如果重復(fù)寫(xiě)入相同 rowKey,相同列的數(shù)據(jù),會(huì)寫(xiě)入多個(gè)版本進(jìn)行覆蓋。

2)讀取數(shù)據(jù)

讀取數(shù)據(jù)的方法有兩個(gè):get 和 scan。

get 最大范圍是一行數(shù)據(jù),也可以進(jìn)行列的過(guò)濾,讀取數(shù)據(jù)的結(jié)果為多行 cell。

hbase:022:0> get 'bigdata:student','1001'

hbase:023:0> get 'bigdata:student','1001' , {COLUMN => 'info:name'}

也可以修改讀取 cell 的版本數(shù),默認(rèn)讀取一個(gè)。最多能夠讀取當(dāng)前列族設(shè)置的維護(hù)版本 數(shù)。 hbase:024:0>get 'bigdata:student','1001' , {COLUMN => 'info:name', VERSIONS => 6}

scan 是掃描數(shù)據(jù),能夠讀取多行數(shù)據(jù),不建議掃描過(guò)多的數(shù)據(jù),推薦使用 startRow 和 stopRow 來(lái)控制讀取的數(shù)據(jù),默認(rèn)范圍左閉右開(kāi)。

hbase:025:0> scan 'bigdata:student',{STARTROW => '1001',STOPROW => '1002'}

實(shí)際開(kāi)發(fā)中使用 shell 的機(jī)會(huì)不多,所有豐富的使用方法到 API 中介紹。

3)刪除數(shù)據(jù)

刪除數(shù)據(jù)的方法有兩個(gè):delete 和 deleteall。

delete 表示刪除一個(gè)版本的數(shù)據(jù),即為 1 個(gè) cell,不填寫(xiě)版本默認(rèn)刪除最新的一個(gè)版本。 hbase:026:0> delete 'bigdata:student','1001','info:name'

deleteall 表示刪除所有版本的數(shù)據(jù),即為當(dāng)前行當(dāng)前列的多個(gè) cell。(執(zhí)行命令會(huì)標(biāo)記 數(shù)據(jù)為要?jiǎng)h除,不會(huì)直接將數(shù)據(jù)徹底刪除,刪除數(shù)據(jù)只在特定時(shí)期清理磁盤(pán)時(shí)進(jìn)行)

hbase:027:0> deleteall 'bigdata:student','1001','info:name'


HBase 快速入門(mén)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
高台县| 沧州市| 湘阴县| 合水县| 武陟县| 华容县| 山西省| 乌兰浩特市| 芮城县| 塘沽区| 榆社县| 长葛市| 金华市| 库车县| 琼结县| 贵阳市| 龙口市| 安平县| 秀山| 汕尾市| 太湖县| 五台县| 鄄城县| 滨海县| 滨州市| 肇东市| 扶风县| 随州市| 津南区| 蒙城县| 精河县| 资溪县| 江达县| 黑山县| 年辖:市辖区| 田林县| 杭锦旗| 武胜县| 承德县| 天津市| 兰坪|