Hbase常用api操作

2021-10-01 23:25:11 字數 1924 閱讀 8069

//連線資料庫

configuration conf = new configuration()

; conf.set

("hbase.zookeeper.quorum", "node01:2181,node02:2181,node03:2181");

connection connection = connectionfactory.createconnection

(conf)

; //讀取表

table hbase_rate = connection.gettable

(tablename.valueof

("hbase_rate"))

; scan scan = new scan()

; scan.setstartrow

("7u6uaipflc0".getbytes()

);scan.setstoprow

("1wbxfcrs2ag".getbytes()

);resultscanner scanner = hbase_rate.getscanner

(scan)

; for (result result : scanner)

connection.close()

;

//連線資料庫

configuration conf = new configuration()

; conf.set

("hbase.zookeeper.quorum", "node01:2181,node02:2181,node03:2181");

connection connection = connectionfactory.createconnection

(conf)

; //讀取表

table hbase_comments = connection.gettable

(tablename.valueof

("hbase_comments"))

; scan scan = new scan()

; resultscanner scanner = hbase_comments.getscanner

(scan)

; for (result result : scanner)

} connection.close()

;

/ 建立hbase 資料表

public static void create() throws ioexception

//向表中新增資料

public static void adddatas() throws ioexception

//向表中新增一批資料

public static void adddatass() throws ioexception

//查詢 主鍵 rowkey 0004 的人 獲取某一行

public static void searchdata() throws ioexception

else

} //關閉連線

connection.close()

;}//通過starrowkey 和 endrowkey 進行掃瞄

public static void scanrowkey() throws ioexception

else}}

}// 過濾器 查詢rowkey 小於0005的資料

public static void rowkeyfilter() throws ioexception

}

HBase 詳細API操作

新建專案後在pom.xml中新增依賴 org.apache.hbasegroupid hbase serverartifactid 1.3.1version dependency org.apache.hbasegroupid hbase clientartifactid 1.3.1version ...

Hbase 二 Hbase常用操作

常用shell命令 hbase shell命令 描述alter 修改列族 column family 模式 count 統計表中行的數量 create 建立表describe 顯示表相關的詳細資訊 delete 刪除指定物件的值 可以為表,行,列對應的值,另外也可以指定時間戳的值 deleteall...

hbase常用操作

cd bin start hbase.sh cd bin stop hbase.sh cd bin hbase daemon.sh start rest p 20550 登入zookeeper,如 zkcli.sh ls hbase table lock rmr hbase table lock 你...