01.下载hbase解压生成文件hbase-2.1.1
(base) [root@192 opt]# ls -al
总用量 2526012
drwxr-xr-x. 19 root root 4096 4月 12 17:04 .
dr-xr-xr-x. 18 root root 236 3月 25 07:58 ..
drwxr-xr-x. 10 root root 184 3月 23 13:42 apache-hive-2.3.9-bin
-rw-r--r--. 1 root root 286170958 3月 23 13:41 apache-hive-2.3.9-bin.tar.gz
drwxr-xr-x. 8 root root 100 1月 26 03:31 Code
drwxr-xr-x. 2 root root 177 3月 2 2017 docker
-rw-r--r--. 1 root root 27816900 1月 25 11:53 docker-17.03.0-ce.tgz
drwxrwxr-x. 8 zzjz zzjz 125 12月 18 2018 flink-1.6.3
-rw-r--r--. 1 root root 301611742 1月 25 11:54 flink-1.6.3-bin-hadoop27-scala_2.11.tgz
drwxr-xr-x. 10 zzjz ftp 161 1月 25 17:14 hadoop-2.7.7
-rw-r--r--. 1 root root 218720521 1月 25 11:54 hadoop-2.7.7.tar.gz
drwxr-xr-x. 3 root root 17 1月 25 17:05 HadoopData
drwxr-xr-x. 7 root root 182 4月 12 16:55 hbase-2.1.1
-rw-r--r--. 1 root root 266060230 4月 12 16:54 hbase-2.1.1-bin.tar.gz
drwxr-xr-x. 2 root root 6 4月 12 17:04 HbaseData
-rw-r--r--. 1 root root 169983496 1月 25 12:01 jdk-8u131-linux-x64.rpm
drwxr-xr-x. 8 root root 144 4月 4 16:05 kafka_2.11-2.4.0
-rw-r--r--. 1 root root 70057083 1月 25 11:54 kafka_2.11-2.4.0.tgz
drwxr-xr-x. 2 root root 6 1月 25 18:18 KafkaData
drwxr-xr-x. 55 root root 4096 4月 12 17:08 KafkaLogs
drwxr-xr-x. 2 root root 21 2月 18 07:09 LYP
-rw-r--r--. 1 root root 94235922 1月 25 11:54 Miniconda3-latest-Linux-x86_64.sh
-rw-r--r--. 1 root root 498831872 1月 25 11:54 postgis.tar
-rw-r--r--. 1 root root 321790464 1月 25 11:54 postgres.tar
drwxr-xr-x. 2 root root 6 10月 31 2018 rh
drwxrwxr-x. 6 2000 2000 50 4月 17 2014 scala-2.11.0
-rw-r--r--. 1 root root 26007395 1月 25 11:54 scala-2.11.0.tgz
drwxr-xr-x. 13 zzjz zzjz 211 2月 3 2020 spark-2.4.5-bin-hadoop2.7
-rw-r--r--. 1 root root 232530699 1月 25 11:54 spark-2.4.5-bin-hadoop2.7.tgz
-rw-r--r--. 1 root root 35099505 1月 26 06:36 trajectory.sql
drwxr-xr-x. 14 2002 2002 4096 3月 7 2019 zookeeper-3.4.14
-rw-r--r--. 1 root root 37676320 1月 25 11:55 zookeeper-3.4.14.tar.gz
drwxr-xr-x. 3 root root 51 1月 25 18:14 ZookeeperData
02.在环境变量中添加如下:
#hbase
export HBASE_HOME=/opt/hbase-2.1.1
export PATH=$HBASE_HOME/bin:$PATH
03.vim hbase-env.sh
export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk
# Hbase启用自身的zookkeeper
export HBASE_MANAGES_ZK=true
04.vim hbase-site.xml
<configuration>
<!--HBase数据目录位置:在HDFS文件系统上的位置-->
<property>
<name>hbase.rootdir</name>
<value>/opt/HbaseData</value>
<description>The directory shared by region servers.</description>
</property>
</configuration>
05.启动hbase shell
(base) [root@192 conf]# hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.7/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hbase-2.1.1/lib/client-facing-thirdparty/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.1.1, rb60a92d6864ef27295027f5961cb46f9162d7637, Fri Oct 26 19:27:03 PDT 2018
Took 0.0034 seconds
hbase(main):001:0>
06.查看状态
出现报错:ERROR: KeeperErrorCode = NoNode for /hbase/master
hbase(main):001:0> status
ERROR: KeeperErrorCode = NoNode for /hbase/master
For usage try 'help "status"'
Took 8.2311 seconds
07.启动hbase提示zookeeper
(base) [root@192 bin]# ./start-hbase.sh
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.7/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hbase-2.1.1/lib/client-facing-thirdparty/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
running master, logging to /opt/hbase-2.1.1/logs/hbase-root-master-192.168.1.10.out
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.7/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hbase-2.1.1/lib/client-facing-thirdparty/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
Could not start ZK at requested port of 2181. ZK was started at port: 2182. Aborting as clients (e.g. shell) will not be able to find this ZK quorum.
07.修改如下:vim hbase-env.sh
export HBASE_MANAGES_ZK=false
08.再次启动 ./start-hbase.sh,没有最后的报错了
(base) [root@192 bin]# ./start-hbase.sh
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.7/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hbase-2.1.1/lib/client-facing-thirdparty/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
running master, logging to /opt/hbase-2.1.1/logs/hbase-root-master-192.168.1.10.out
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.7/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hbase-2.1.1/lib/client-facing-thirdparty/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
: running regionserver, logging to /opt/hbase-2.1.1/logs/hbase-root-regionserver-192.168.1.10.out
: SLF4J: Class path contains multiple SLF4J bindings.
: SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.7/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
: SLF4J: Found binding in [jar:file:/opt/hbase-2.1.1/lib/client-facing-thirdparty/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
: SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
: SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
09.使用hbase shell,可以看到status了
(base) [root@192 bin]# hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.7/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hbase-2.1.1/lib/client-facing-thirdparty/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.1.1, rb60a92d6864ef27295027f5961cb46f9162d7637, Fri Oct 26 19:27:03 PDT 2018
Took 0.0034 seconds
hbase(main):001:0> status
1 active master, 0 backup masters, 1 servers, 0 dead, 2.0000 average load
Took 0.3915 seconds
hbase(main):002:0>
10.status正常,建表错误:
hbase(main):003:0> list
TABLE
0 row(s)
Took 0.0510 seconds
=> []
hbase(main):004:0> create 'StudentAndCourse','student','course1','course2','course3'
ERROR: org.apache.hadoop.hbase.PleaseHoldException: Master is initializing
at org.apache.hadoop.hbase.master.HMaster.checkInitialized(HMaster.java:2992)
at org.apache.hadoop.hbase.master.HMaster.createTable(HMaster.java:1962)
at org.apache.hadoop.hbase.master.MasterRpcServices.createTable(MasterRpcServices.java:624)
at org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos$MasterService$2.callBlockingMethod(MasterProtos.java)
at org.apache.hadoop.hbase.ipc.RpcServer.call(RpcServer.java:413)
at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:130)
at org.apache.hadoop.hbase.ipc.RpcExecutor$Handler.run(RpcExecutor.java:324)
at org.apache.hadoop.hbase.ipc.RpcExecutor$Handler.run(RpcExecutor.java:304)
For usage try 'help "create"'
11.进入zookeeper种
(base) [root@192 zookeeper-3.4.14]# cd bin/
(base) [root@192 bin]# ls
README.txt zkCleanup.sh zkCli.cmd zkCli.sh zkEnv.cmd zkEnv.sh zkServer.cmd zkServer.sh zkTxnLogToolkit.cmd zkTxnLogToolkit.sh zookeeper.out
(base) [root@192 bin]# zkCli.sh
Connecting to localhost:2181
12.删除hbase
[zk: localhost:2181(CONNECTED) 4] ls /
[cluster, controller_epoch, controller, brokers, zookeeper, admin, isr_change_notification, consumers, log_dir_event_notification, latest_producer_id_block, config, hbase]
[zk: localhost:2181(CONNECTED) 5] rmr /hbase
[zk: localhost:2181(CONNECTED) 6] ls /
[cluster, controller_epoch, controller, brokers, zookeeper, admin, isr_change_notification, consumers, log_dir_event_notification, latest_producer_id_block, config]
[zk: localhost:2181(CONNECTED) 7]
13.重启hbase,进入hbase shell 建表,正常
(base) [root@192 bin]# cd $HBASE_HOME
(base) [root@192 hbase-2.1.1]# ./bin/start-hbase.sh
running master, logging to /opt/hbase-2.1.1/logs/hbase-root-master-192.168.1.10.out
: running regionserver, logging to /opt/hbase-2.1.1/logs/hbase-root-regionserver-192.168.1.10.out
(base) [root@192 hbase-2.1.1]# hbase shell
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.1.1, rb60a92d6864ef27295027f5961cb46f9162d7637, Fri Oct 26 19:27:03 PDT 2018
Took 0.0027 seconds
hbase(main):001:0> status
1 active master, 0 backup masters, 1 servers, 0 dead, 2.0000 average load
Took 0.3657 seconds
hbase(main):002:0> create 'StudentAndCourse','student','course1','course2','course3'
Created table StudentAndCourse
Took 0.8715 seconds
=> Hbase::Table - StudentAndCourse