魯春利的工作筆記,好記性不如爛筆頭
為企業(yè)提供做網(wǎng)站、網(wǎng)站制作、網(wǎng)站優(yōu)化、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)、競(jìng)價(jià)托管、品牌運(yùn)營(yíng)等營(yíng)銷(xiāo)獲客服務(wù)。創(chuàng)新互聯(lián)擁有網(wǎng)絡(luò)營(yíng)銷(xiāo)運(yùn)營(yíng)團(tuán)隊(duì),以豐富的互聯(lián)網(wǎng)營(yíng)銷(xiāo)經(jīng)驗(yàn)助力企業(yè)精準(zhǔn)獲客,真正落地解決中小企業(yè)營(yíng)銷(xiāo)獲客難題,做到“讓獲客更簡(jiǎn)單”。自創(chuàng)立至今,成功用技術(shù)實(shí)力解決了企業(yè)“網(wǎng)站建設(shè)、網(wǎng)絡(luò)品牌塑造、網(wǎng)絡(luò)營(yíng)銷(xiāo)”三大難題,同時(shí)降低了營(yíng)銷(xiāo)成本,提高了有效客戶(hù)轉(zhuǎn)化率,獲得了眾多企業(yè)客戶(hù)的高度認(rèn)可!通過(guò)HDFS查看
HBase中行鍵(RowKey)是表中唯一的,并且按照字典排序由低到高存儲(chǔ)在表中的。
hbase(main):018:0> put 't_domain', 'row1', 'c_domain:name', 'baidu.com' 0 row(s) in 0.6830 seconds hbase(main):019:0> put 't_domain', 'row2', 'c_domain:name', 'sina.com' 0 row(s) in 0.0870 seconds hbase(main):020:0> put 't_domain', 'row3', 'c_domain:name', 'mycms.com' 0 row(s) in 0.0100 seconds hbase(main):021:0> put 't_domain', 'row10', 'c_domain:name', 'www.163.com' 0 row(s) in 0.0280 seconds hbase(main):022:0> put 't_domain', 'row21', 'c_domain:name', 'www.51cto.com' 0 row(s) in 0.0240 seconds hbase(main):023:0> scan 't_domain' ROW COLUMN+CELL row1 column=c_domain:name, timestamp=1440340474441, value=baidu.com row10 column=c_domain:name, timestamp=1440340536382, value=www.163.com row2 column=c_domain:name, timestamp=1440340492582, value=sina.com row21 column=c_domain:name, timestamp=1440340550534, value=www.51cto.com row3 column=c_domain:name, timestamp=1440340518003, value=mycms.com 5 row(s) in 0.1350 secondsHBase Shell工具:
選擇一臺(tái)HBase集群的節(jié)點(diǎn)(建議選擇客戶(hù)端節(jié)點(diǎn)),執(zhí)行命令bin/hbase shell
看到如下命令說(shuō)明已進(jìn)入hbase shell環(huán)境,執(zhí)行help命令可以查看幫助信息:
[hadoop@dnode1 bin]$ hbase shell HBase Shell; enter 'help<RETURN>' for list of supported commands. Type "exit<RETURN>" to leave the HBase Shell Version 0.98.1-hadoop2, r1583035, Sat Mar 29 17:19:25 PDT 2014 hbase(main):001:0> help HBase Shell, version 0.98.1-hadoop2, r1583035, Sat Mar 29 17:19:25 PDT 2014 Type 'help "COMMAND"', (e.g. 'help "get"' -- the quotes are necessary) for help on a specific command. Commands are grouped. Type 'help "COMMAND_GROUP"', (e.g. 'help "general"') for help on a command group. COMMAND GROUPS: Group name: general Commands: status, table_help, version, whoami 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, show_filters Group name: namespace Commands: alter_namespace, create_namespace, describe_namespace, drop_namespace, list_namespace, list_namespace_tables Group name: dml Commands: append, count, delete, deleteall, get, get_counter, incr, put, scan, truncate, truncate_preserve Group name: tools Commands: assign, balance_switch, balancer, catalogjanitor_enabled, catalogjanitor_run, catalogjanitor_switch, close_region, compact, flush, hlog_roll, major_compact, merge_region, move, split, trace, unassign, zk_dump Group name: replication Commands: add_peer, disable_peer, enable_peer, list_peers, list_replicated_tables, remove_peer, set_peer_tableCFs, show_peer_tableCFs Group name: snapshot Commands: clone_snapshot, delete_snapshot, list_snapshots, rename_snapshot, restore_snapshot, snapshot Group name: security Commands: grant, revoke, user_permission Group name: visibility labels Commands: add_labels, clear_auths, get_auths, set_auths # 查看集群狀態(tài) hbase(main):002:0> status 3 servers, 0 dead, 3.0000 average load # 該集群有3臺(tái)RegionServer,沒(méi)有”死掉“的RegionServer中,平均每臺(tái)有3個(gè)Region。 # HBase版本命令 hbase(main):003:0> version 0.98.1-hadoop2, r1583035, Sat Mar 29 17:19:25 PDT 2014 # 返回值為由逗號(hào)分割的三個(gè)部分,0.98.1-hadoop2表示HBase版本號(hào),r1583035表示修訂版本,第三部分為編譯HBase的時(shí)間。 # 查看ddl命令組的幫助 hbase(main):006:0> help 'ddl' Command: alter Alter a table. Depending on the HBase setting ("hbase.online.schema.update.enable"), the table must be disabled or not to be altered (see help 'disable'). You can add/modify/delete column families, as well as change table configuration. Column families work similarly to create; column family spec can either be a name string, or a dictionary with NAME attribute. Dictionaries are described on the main help command output. For example, to change or add the 'f1' column family in table 't1' from current value to keep a maximum of 5 cell VERSIONS, do: hbase> alter 't1', NAME => 'f1', VERSIONS => 5 You can operate on several column families: hbase> alter 't1', 'f1', {NAME => 'f2', IN_MEMORY => true}, {NAME => 'f3', VERSIONS => 5} // 略 # 示例: hbase(main):033:0> create 'tb1', {NAME => 'cf1', VERSIONS => 5} 0 row(s) in 20.1040 seconds => Hbase::Table - tb1 hbase(main):035:0> create 'tb2', {NAME => 'cf1'}, {NAME => 'cf2'}, {NAME => 'cf3'} 0 row(s) in 19.1130 seconds => Hbase::Table - tb2 # 上述命令的簡(jiǎn)化版本如下 hbase(main):036:0> create 'tb3', 'cf1' 0 row(s) in 6.8610 seconds => Hbase::Table - tb3 hbase(main):037:0> create 'tb4', 'cf1', 'cf2', 'cf3' # 三個(gè)列族 0 row(s) in 6.2010 seconds hbase(main):045:0> list TABLE httptable tb1 tb2 tb3 tb4 testtable 6 row(s) in 2.3430 seconds => ["httptable", "tb1", "tb2", "tb3", "tb4", "testtable"] hbase(main):046:0> # 說(shuō)明: # => 表示賦值,如{NAME = 'cf1'}; # 字符串必須使用單引號(hào)引起來(lái),如'cf2'; # 如果創(chuàng)建表時(shí)需要指定列族的特定屬性,需要花括號(hào)括起來(lái),如{NAME='cf1', VERSIONS=5} hbase(main):025:0> help 'namespace' Command: alter_namespace Alter namespace properties. To add/modify a property: hbase> alter_namespace 'ns1', {METHOD => 'set', 'PROERTY_NAME' => 'PROPERTY_VALUE'} To delete a property: hbase> alter_namespace 'ns1', {METHOD => 'unset', NAME=>'PROERTY_NAME'} // 略 hbase(main):048:0> create_namespace 'ns1' 0 row(s) in 4.7320 seconds hbase(main):049:0> list_namespace NAMESPACE default hbase ns1 3 row(s) in 11.0490 seconds hbase(main):050:0> create 'ns1:tb5', 'cf' # 列族cf 0 row(s) in 12.0680 seconds => Hbase::Table - ns1:tb5 hbase(main):051:0> list_namespace_tables 'ns1' TABLE tb5 1 row(s) in 2.1220 seconds hbase(main):052:0> # 查看DML命令的幫助 hbase(main):026:0> help 'dml' hbase(main):052:0> put 'ns1:tb5', 'baidu.com', 'cf:owner', 'BeiJingBaiduCo.' 0 row(s) in 0.4400 seconds hbase(main):053:0> put 'ns1:tb5', 'baidu.com', 'cf:ipstr', '61.135.169.121' 0 row(s) in 1.1640 seconds hbase(main):054:0> put 'ns1:tb5', 'baidu.com', 'cf:reg_date', '19990415' 0 row(s) in 0.3530 seconds hbase(main):055:0> put 'ns1:tb5', 'baidu.com', 'cf:address', '北京' 0 row(s) in 2.7540 seconds hbase(main):056:0> put 'ns1:tb5', 'alibaba.com', 'cf:ipstr', '205.204.101.42' 0 row(s) in 1.2040 seconds # 統(tǒng)計(jì)表的行數(shù) hbase(main):064:0> count 'tb5' ERROR: Unknown table tb5! hbase(main):066:0> count 'ns1:tb5' 2 row(s) in 0.3110 seconds => 2 hbase(main):067:0> count 'ns1:tb5', INTERVAL => 100000 2 row(s) in 0.0170 seconds => 2 # 單行讀 hbase(main):068:0> get 'ns1:tb5', 'baidu.com' COLUMN CELL cf:address timestamp=1441006344446, value=\xE5\x8C\x97\xE4\xBA\xAC cf:ipstr timestamp=1441006329572, value=61.135.169.121 cf:owner timestamp=1441006321284, value=BeiJingBaiduCo. cf:reg_date timestamp=1441006335701, value=19990415 4 row(s) in 0.1150 seconds hbase(main):074:0> get 'ns1:tb5', 'baidu.com', 'cf:ipstr' COLUMN CELL cf:ipstr timestamp=1441006329572, value=61.135.169.121 1 row(s) in 0.0200 seconds hbase(main):075:0> # 如果COLUMN未指定column family則會(huì)提示錯(cuò)誤 # ERROR: Unknown column family! Valid column names: cf:* hbase(main):076:0> get 'ns1:tb5', 'baidu.com', {COLUMN => 'cf:reg_date'} COLUMN CELL cf:reg_date timestamp=1441006335701, value=19990415 1 row(s) in 0.0170 seconds hbase(main):077:0> # 掃描表 scan 'hbase:meta' scan 'hbase:meta', {COLUMNS => 'info:regioninfo'} # 刪除列 hbase(main):004:0> delete 'ns1:tb5', 'baidu.com', 'cf:address' 0 row(s) in 0.2260 seconds hbase(main):005:0> get 'ns1:tb5', 'baidu.com' COLUMN CELL cf:ipstr timestamp=1441006329572, value=61.135.169.121 cf:owner timestamp=1441006321284, value=BeiJingBaiduCo. cf:reg_date timestamp=1441006335701, value=19990415 3 row(s) in 0.0210 seconds # 清空表 hbase(main):006:0> truncate 'ns1:tb5' Truncating 'ns1:tb5' table (it may take a while): - Disabling table... - Dropping table... - Creating table... 0 row(s) in 76.4690 seconds hbase(main):007:0> get 'ns1:tb5', 'baidu.com' COLUMN CELL 0 row(s) in 0.0480 seconds 其他操作略。Thrift客戶(hù)端:
略
MapReduce批量操作HBase
見(jiàn)http://luchunli.blog.51cto.com/2368057/1691298
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。
新聞名稱(chēng):HBase-1.0.1學(xué)習(xí)筆記(二)HBaseShell工具使用-創(chuàng)新互聯(lián)
URL標(biāo)題:http://m.rwnh.cn/article6/djijig.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、外貿(mào)建站、軟件開(kāi)發(fā)、企業(yè)建站、小程序開(kāi)發(fā)、品牌網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容