First install hadoop, refer to the previous article
Configuration file directory, mainly modify hbase-env.cmd and hbase-site.xml
hbase-env.cmd
set HBASE_MANAGES_ZK=true
set JAVA_HOME=C:\Program Files\Java\jre1.8.0_201
set HBASE_CLASSPATH=G:\datacenter\hbase-2.2.0\conf
The value of HBASE_MANAGES_ZK is false, which means zookeeper is externally installed, and the value of HBASE_MANAGES_ZK is true, which means that zookeeper comes with it.
Here we configure the stand-alone test mode, so it is enough to use the ZK that comes with HBase, so the configuration is true.
hbase-site.xml
<configuration>
<!--
The following properties are set for running HBase as a single process on a
developer workstation. With this configuration, HBase is running in
"stand-alone" mode and without a distributed file system. In this mode, and
without further configuration, HBase and ZooKeeper data are stored on the
local filesystem, in a path under the value configured for `hbase.tmp.dir`.
This value is overridden from its default value of `/tmp` because many
systems clean `/tmp` on a regular basis. Instead, it points to a path within
this HBase installation directory.
Running against the `LocalFileSystem`, as opposed to a distributed
filesystem, runs the risk of data integrity issues and data loss. Normally
HBase will refuse to run in such an environment. Setting
`hbase.unsafe.stream.capability.enforce` to `false` overrides this behavior,
permitting operation. This configuration is for the developer workstation
only and __should not be used in production!__
See also https://hbase.apache.org/book.html#standalone_dist
-->
<property>
<name>hbase.cluster.distributed</name>
<value>false</value>
</property>
<property>
<name>hbase.tmp.dir</name>
<value>D:/hbase-2.3.3/hbase-2.3.3/hbdata/tmp</value>
</property>
<property>
<name>hbase.unsafe.stream.capability.enforce</name>
<value>false</value>
</property>
<property>
<name>hbase.wal.provider</name>
<value>filesystem</value>
</property>
<property>
<name>hbase.rootdir</name>
<value>file:///D:/hbase-2.3.3/hbase-2.3.3/hbdata/root</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>127.0.0.1</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>D:/hbase-2.3.3/hbase-2.3.3/hbdata/zoo</value>
</property>
<property>
<name>hbase.master.info.port</name>
<value>60010</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
<property>
<name>hbase.master.port</name>
<value>60000</value>
</property>
<property>
<name>hbase.regionserver.port</name>
<value>60020</value>
</property>
</configuration>
The most important thing above is hbase.rootdir, and the local file system directory can be configured for local testing. The stand-alone mode hbase.cluster.distributed is configured as false.
hbase.rootdir
hbase.rootdir configures the shared directory of the region server to persist Hbase
You can configure hdfs path or local file system path: hdfs:
hdfs://localhost:49002/hbase
Local file system:
file:///G:/datacenter/hbdata/root
By default, Hbase is written to /tmp:
file:///tmp/hbase-${user.name}/hbase
Do not change this configuration, the data will be lost when restarting
hbase.cluster.distributed
Configure the operating mode of Hbase. False is the stand-alone mode, and true is the distributed mode. If false, Hbase and Zookeeper will run in the same JVM. Default: false
The external ZK must be true here, otherwise hbase will still use its own zk. If the external zookeeper is started, conflicts will occur and hbase will not start up
hbase.zookeeper.quorum
The address list of the cluster, separated by commas. For example: "192.168.10.5,192.168.10.6,192.168.10.7"
The default is localhost, this value is obviously unacceptable for distributed applications
ZK can be configured directly in hbase-site.xml, or it can be configured by adding a zoo.cfg file in the conf directory
hbase.zookeeper.property.clientPort
Zk client connection port
hbase.zookeeper.property.dataDir
ZK data storage location
Follow the zookeeper configuration dataLogDir=/home/hadoop/zookeeper-3.4.6/datalog path configuration in zoo.cfg
hbase.master.info.port
hbase-ui port, monitoring page http://localhost:60010/master-status -1 means ui is disabled, default 60010
More hbase configuration options.
Startup and basic commands
Hbase is a database, which must be started first like MySQL:
D:\hbase-2.3.3\hbase-2.3.3\bin>start-hbase.cmd
Common mistakes
1.Invalid UTF-8 start byte 0xa1 (at char #2277, byte #20)
Solution: copy in the source file
<property>
<name>hbase.tmp.dir</name>
<value>D:/hbase-2.3.3/hbase-2.3.3/hbdata/tmp</value>
</property>
Modifying the name and value values is otherwise difficult to solve.
2.FanOutOneBlockAsyncDFSOutputHelper异常
Solution:
vi /usr/hbase-2.1.6/conf/hbase-site.xml
添加:
<property>
<name>hbase.wal.provider</name>
<value>filesystem</value>
</property>
3. Missing jar package
If there is no error, the above message should appear. If there is an error, locate it according to the error message. I downloaded the hbase2.2.0 in the windows system and added the following jar packages to the lib directory under the hbase root directory to start successfully.
According to ClassNotFound, compare the jar package added by the dependent version of the source code.
4.Could not initialize class scala.tools.fusesource_embedded.jansi.internal.Kernel32
Access the web management interface
After the startup is successful, you can access the web interface through the browser to view related information.
http://localhost:60010/master-status
http://mycol-pc:16030/rs-status
Close hbase
Execute stop-hbase.cmd
Open hbase shell
D:\hbase-2.3.3\hbase-2.3.3\bin>hbase shell
Use the client to connect, the configuration is successful when the following screenshot appears-the connection time is relatively long, almost three minutes
You can start the client through the hbase shell to interact with the hbase database.
The hbase shell starts a client to connect to the hbase database, and then we can perform some basic operations such as adding and deleting.
HBase basic operation
Basic command
help: view command help
status: view hbase status
version: view hbase version
list_namespace: view table space
Table operations
create: create a table
exists: check if the table exists
list: view all tables
alter: modify the table
delete: delete column
disable: disable table
is_enabled: Check whether the table is disabled
desc: View table structure
drop: delete table
Insert data
put: insert data
Inquire
count: how many rows are in the statistics table
get: get data
scan: scan table or column