[lxl@hadoop102 hbase]$ bin/stop-hbase.sh
[lxl@hadoop102 hbase]$ touch conf/backup-masters
[lxl@hadoop102 hbase]$ echo hadoop103 > conf/backup-masters
[atguigu@hadoop102 hbase]$ scp -r conf/ hadoop103:/opt/module/hbase/ [atguigu@hadoop102 hbase]$ scp -r conf/ hadoop104:/opt/module/hbase/
[lxl@hadoop102 hbase]$ xsync conf/backup-masters
[lxl@hadoop102 hbase]$ bin/start-hbase.sh
starting master, logging to /opt/module/hbase/logs/hbase-lxl-master-hadoop102.out
hadoop102: starting regionserver, logging to /opt/module/hbase/bin/../logs/hbase-lxl-regionserver-hadoop102.out
hadoop104: starting regionserver, logging to /opt/module/hbase/bin/../logs/hbase-lxl-regionserver-hadoop104.out
hadoop103: starting regionserver, logging to /opt/module/hbase/bin/../logs/hbase-lxl-regionserver-hadoop103.out
hadoop103: starting master, logging to /opt/module/hbase/bin/../logs/hbase-lxl-master-hadoop103.out
[lxl@hadoop102 hbase]$ util.sh
================ lxl@hadoop102 ================
13040 HMaster
2868 NodeManager
2949 JobHistoryServer
13190 HRegionServer
3115 QuorumPeerMain
2460 NameNode
13535 Jps
2575 DataNode
================ lxl@hadoop103 ================
8562 Jps
8307 HMaster
2868 QuorumPeerMain
8229 HRegionServer
2407 ResourceManager
2268 DataNode
2525 NodeManager
================ lxl@hadoop104 ================
2384 SecondaryNameNode
8864 Jps
2484 NodeManager
8676 HRegionServer
2646 QuorumPeerMain
2279 DataNodenode
http://hadooo102:16010
hbase> create 'staff1','info','partition1',SPLITS => ['1000','2000','3000','4000']
hbase(main):002:0> create 'staff2','info','partition2',{NUMREGIONS => 15, SPLITALGO => 'HexStringSplit'}
aaaa
dddd
cccc
bbbb
hbase(main):003:0> create 'staff3','partition3',SPLITS_FILE => 'splits.txt'
//自定義算法,產生一系列 Hash 散列值存儲在二維數組中 byte[][] splitKeys = 某個散列值函數 //建立 HBaseAdmin 實例 HBaseAdmin hAdmin = new HBaseAdmin(HBaseConfiguration.create()); //建立 HTableDescriptor 實例 HTableDescriptor tableDesc = new HTableDescriptor(tableName); //經過 HTableDescriptor 實例和散列值二維數組建立帶有預分區的 HBase 表 hAdmin.createTable(tableDesc, splitKeys);
好比: 原 本 rowKey 爲 1001 的 , SHA1 後變成: dd01903921ea24941c26a48f2cec24e0bb0e8cc7 原 本 rowKey 爲 3001 的 , SHA1 後變成: 49042c54de64a1e9bf0b33e00245660ef92dc7bd 原 本 rowKey 爲 5001 的 , SHA1 後變成: 7b61dec07e02c188790670af43e717f0f46e8913 在作此操做以前,通常咱們會選擇從數據集中抽取樣本,來決定什麼樣的 rowKey 來 Hash 後做爲每一個分區的臨界值。
20170524000001 轉成 10000042507102 20170524000002 轉成 20000042507102
20170524000001_a12e
20170524000001_93i7
屬性:dfs.support.append 解釋:開啓 HDFS 追加同步,能夠優秀的配合 HBase 的數據同步和持久化。默認值爲 true。
屬性:dfs.datanode.max.transfer.threads 解釋:HBase 通常都會同一時間操做大量的文件,根據集羣的數量和規模以及數據動做,//合併文件或者刷寫的時候會操做大量的文件 設置爲 4096 或者更高。默認值:4096 //須要看集羣的大小而定
屬性:dfs.image.transfer.timeout 解釋:若是對於某一次數據操做來說,延遲很是高,socket 須要等待更長的時間,建議把 該值設置爲更大的值(默認 60000 毫秒),以確保 socket 不會被 timeout 掉。
屬性: mapreduce.map.output.compress mapreduce.map.output.compress.codec 解釋:開啓這兩個數據能夠大大提升文件的寫入效率,減小寫入時間。第一個屬性值修改成 true,第二個屬性值修改成:org.apache.hadoop.io.compress.GzipCodec 或者 其餘壓縮方式。
屬性:hbase.regionserver.handler.count 解釋:默認值爲 30,用於指定 RPC 監聽的數量,能夠根據客戶端的請求數進行調整,讀寫 請求較多時,增長此值。
屬性:hbase.hregion.max.filesize 解釋:默認值 10737418240(10GB),若是須要運行 HBase 的 MR 任務,能夠減少此值, 由於一個 region 對應一個 map 任務,若是單個 region 過大,會致使 map 任務執行時間 過長。該值的意思就是,若是 HFile 的大小達到這個數值,則這個 region 會被切分爲兩 個 Hfile。
屬性:hbase.client.write.buffer 解釋:用於指定 HBase 客戶端緩存,增大該值能夠減小 RPC 調用次數,可是會消耗更多內 存,反之則反之。通常咱們須要設定必定的緩存大小,以達到減小 RPC 次數的目的。
屬性:hbase.client.scanner.caching
解釋:用於指定 scan.next 方法獲取的默認行數,值越大,消耗內存越大。
<!-- 一個store裏面容許存的hfile的個數,超過這個個數會被寫到新的一個hfile裏面 也便是每一個region的每一個列族對應的memstore在fulsh爲hfile的時候,默認狀況下當超過3個hfile的時候就會 對這些文件進行合併重寫爲一個新文件,設置個數越大能夠減小觸發合併的時間,可是每次合併的時間就會越長 --> <property> <name>hbase.hstore.compactionThreshold</name> <value>3</value> <description> If more than this number of HStoreFiles in any one HStore (one HStoreFile is written per flush of memstore) then a compaction is run to rewrite all HStoreFiles files as one. Larger numbers put off compaction but when it runs, it takes longer to complete. </description> </property> <!-- 每一個minor compaction操做的 容許的最大hfile文件上限 --> <property> <name>hbase.hstore.compaction.max</name> <value>10</value> <description>Max number of HStoreFiles to compact per 'minor' compaction.</description> </property> <!-- regionServer的全局memstore的大小,超過該大小會觸發flush到磁盤的操做,默認是堆大小的40%,並且regionserver級別的 flush會阻塞客戶端讀寫 --> <property> <name>hbase.regionserver.global.memstore.size</name> <value></value> <description>Maximum size of all memstores in a region server before new updates are blocked and flushes are forced. Defaults to 40% of heap (0.4). Updates are blocked and flushes are forced until size of all memstores in a region server hits hbase.regionserver.global.memstore.size.lower.limit. The default value in this configuration has been intentionally left emtpy in order to honor the old hbase.regionserver.global.memstore.upperLimit property if present. </description> </property> <!-- 內存中的文件在自動刷新以前可以存活的最長時間,默認是1h --> <property> <name>hbase.regionserver.optionalcacheflushinterval</name> <value>3600000</value> <description> Maximum amount of time an edit lives in memory before being automatically flushed. Default 1 hour. Set it to 0 to disable automatic flushing. </description> </property> <!-- 單個region裏memstore的緩存大小,超過那麼整個HRegion就會flush,默認128M --> <property> <name>hbase.hregion.memstore.flush.size</name> <value>134217728</value> <description> Memstore will be flushed to disk if size of the memstore exceeds this number of bytes. Value is checked by a thread that runs every hbase.server.thread.wakefrequency. </description> </property>