[root@bigdatatest01 conf]# cd ../
[root@bigdatatest01 hbase-1.2.0-cdh5.16.2]# bin/start-hbase.
start-hbase.cmd start-hbase.sh
[root@bigdatatest01 hbase-1.2.0-cdh5.16.2]# bin/start-hbase.sh
starting master, logging to /root/app/hbase-1.2.0-cdh5.16.2/bin/../logs/hbase-root-master-bigdatatest01.out
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
The authenticity of host 'bigdatatest01 (192.168.20.66)' can't be established.
ECDSA key fingerprint is SHA256:ubGg3eXeUXlLZLkDjezmag/lpWFbRFEl30lMiQ/Is6M.
ECDSA key fingerprint is MD5:eb:fa:c5:d9:2a:2e:d5:18:39:fc:41:18:8c:4a:76:f6.
Are you sure you want to continue connecting (yes/no)? yes
bigdatatest01: Warning: Permanently added 'bigdatatest01' (ECDSA) to the list of known hosts.
bigdatatest01: starting regionserver, logging to /root/app/hbase-1.2.0-cdh5.16.2/bin/../logs/hbase-root-regionserver-bigdatatest01.out
bigdatatest01: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
bigdatatest01: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
[root@bigdatatest01 ~]# su - hdfs
Last login: Tue Feb 2 10:31:56 CST 2021 on pts/1
[hdfs@bigdatatest01 ~]$ hadoop fs -chmod 777 /hbase
重启服务
[root@bigdatatest01 hbase-1.2.0-cdh5.16.2]# bin/stop-hbase.sh
stopping hbasecat: /tmp/hbase-root-master.pid: No such file or directory
[root@bigdatatest01 hbase-1.2.0-cdh5.16.2]# bin/start-hbase.sh
starting master, logging to /root/app/hbase-1.2.0-cdh5.16.2/bin/../logs/hbase-root-master-bigdatatest01.out
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
bigdatatest01: regionserver running as process 26211. Stop it first.
META 存的是所有的 Region 的位置信息,那么 RegioneServer 当中 Region 在进行分裂之后 的新产生的 Region,是由 Master 来决定发到哪个 RegioneServer,这就意味着,只有 Master 知道 new Region 的位置信息,所以,由 Master 来管理 META 这个表当中的数据的 CRUD。
所以结合以上两点表明,在没有 Region 分裂的情况,Master 宕机一段时间是可以忍受的。
HRegion:
Table 在行的方向上分隔为多个Region。Region是HBase中分布式存储和负载均衡的最小单元,即不同的 Region 可以分别在不同的 Region Server 上,但同一个Region是不会拆分到多个 Server 上。
Region按大小分隔,每个表一般是只有一个 Region。随着数据不断插入表,Region不断增大,当 Region 的某个列族达到一个阈值时就会分成两个新的 Region。
每个 Region 由以下信息标识:< 表名,startRowkey,创建时间>。
由目录表( META )记录该 Region 的 endRowkey。
Store:
每一个 Region 由一个或多个 Store 组成,至少是一个 Store,HBase会把一起访问的数据放在一个 Store 里面,即为每个 ColumnFamily 建一个 Store,如果有几个ColumnFamily,也就有几个 Store。一个 Store由一个 MemStore和0或者 多个 StoreFile组成。 HBase以 Store的大小来判断是否需要切分 Region。
hbase(main):020:0> help 'create'
Creates a table. Pass a table name, and a set of column family
specifications (at least one), and, optionally, table configuration.
Column specification can be a simple string (name), or a dictionary
(dictionaries are described below in main help output), necessarily
including NAME attribute.
Examples:
Create a table with namespace=ns1 and table qualifier=t1
hbase> create 'ns1:t1', {NAME => 'f1', VERSIONS => 5}
Create a table with namespace=default and table qualifier=t1
hbase> create 't1', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'}
hbase> # The above in shorthand would be the following:
hbase> create 't1', 'f1', 'f2', 'f3'
hbase> create 't1', {NAME => 'f1', VERSIONS => 1, TTL => 2592000, BLOCKCACHE => true}
hbase> create 't1', {NAME => 'f1', CONFIGURATION => {'hbase.hstore.blockingStoreFiles' => '10'}}
hbase> create 't1', {NAME => 'f1', IS_MOB => true, MOB_THRESHOLD => 1000000, MOB_COMPACT_PARTITION_POLICY => 'weekly'}
Table configuration options can be put at the end.
Examples:
hbase> create 'ns1:t1', 'f1', SPLITS => ['10', '20', '30', '40']
hbase> create 't1', 'f1', SPLITS => ['10', '20', '30', '40']
hbase> create 't1', 'f1', SPLITS_FILE => 'splits.txt', OWNER => 'johndoe'
hbase> create 't1', {NAME => 'f1', VERSIONS => 5}, METADATA => { 'mykey' => 'myvalue' }
hbase> # Optionally pre-split the table into NUMREGIONS, using
hbase> # SPLITALGO ("HexStringSplit", "UniformSplit" or classname)
hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit'}
hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit', REGION_REPLICATION => 2, CONFIGURATION => {'hbase.hregion.scan.loadColumnFamiliesOnDemand' => 'true'}}
hbase> create 't1', {NAME => 'f1', DFS_REPLICATION => 1}
You can also keep around a reference to the created table:
hbase> t1 = create 't1', 'f1'
Which gives you a reference to the table named 't1', on which you can then
创建表
hbase(main):021:0> create 'test:demo', 'o'
Created table test:demo
Took 1.3342 seconds
=> Hbase::Table - test:demo
5.4 CRUD
5.4.1 插入数据
hbase(main):028:0> put 'test:demo', 'row1' , 'o:id', '1'
Took 0.0427 seconds
5.4.2 查看所有数据
查看表中所有的数据
hbase(main):022:0> scan 'test:demo'
ROW COLUMN+CELL
0 row(s)
Took 0.0342 seconds
查看一行的数据
hbase(main):029:0> get 'test:demo','row1'
COLUMN CELL
o:id timestamp=1612256670990, value=1
1 row(s)
Took 0.0230 seconds
5.4.3 更新数据
hbase(main):030:0> put 'test:demo', 'row1' , 'o:id', '2'
Took 0.0094 seconds
hbase(main):031:0> get 'test:demo','row1'
COLUMN CELL
o:id timestamp=1612256869333, value=2
1 row(s)
Took 0.0123 seconds