推荐视频教程download: Hbase+Spring boot实战分布式文件存储 : http://www.notescloud.top/goods/detail/1256 新RabbitMQ精讲,项目驱动落地,分布式事务拔高 : http://www.notescloud.top/goods/detail/1249 应用Dubbo框架打造仿猫眼项目 理解微服务核心思想 : http://www.notescloud.top/goods/detail/1252
- 安装好对应版本的hadoop集群,并启动
- 安装好对应版本的zookeeper集群,并启动
- HBase集群安装部署
-
下载安装包并上传到node01服务器
-
安装包下载地址:
http://archive.cloudera.com/cdh5/cdh/5/hbase-1.2.0-cdh5.14.2.tar.gz
-
将安装包上传到node01服务器/kkb/soft路径下,并进行解压
[hadoop@node01 ~] tar -xzvf hbase-1.2.0-cdh5.14.2.tar.gz -C /kkb/install/
1.2 修改HBase配置文件
1.2.1 hbase-env.sh
修改文件
[hadoop@node01 soft] vim hbase-env.sh
修改如下两项内容,值如下
export JAVA_HOME =/kkb/install/jdk1.8.0_141
export HBASE_MANAGES_ZK=false
1.2.2 hbase-site.xml
<!-- -->
-
修改文件
[hadoop@node01 conf]$ vim hbase-site.xml -
内容如下
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://node01:8020/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property><property>
<name>hbase.master.port</name>
<value>16000</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>node01,node02,node03</value>
</property><property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/kkb/install/zookeeper-3.4.5-cdh5.14.2/zkdatas</value>
</property><property>
<name>zookeeper.znode.parent</name>
<value>/hbase</value>
</property>
</configuration>
1.2.3 regionservers
修改文件
vim regionservers
指定HBase集群的从节点;原内容清空,添加如下三行
node01
node02
node03
1.2.4 back-masters
创建back-masters配置文件,里面包含备份HMaster节点的主机名,每个机器独占一行,实现HMaster的高可用
vim backup-masters
将node02作为备份的HMaster节点,文件内容如下
node02
1.3 分发安装包
将node01上的HBase安装包,拷贝到其他机器上
[hadoop@node01 conf] scp -r hbase-1.2.0-cdh5.14.2/ node02: scp -r hbase-1.2.0-cdh5.14.2/ node03:$PWD
1.4创建软连接
注意:三台机器均做如下操作
因为HBase集群需要读取hadoop的core-site.xml、hdfs-site.xml的配置文件信息,所以我们==三台机器==都要执行以下命令,在相应的目录创建这两个配置文件的软连接
ln -s /kkb/install/hadoop-2.6.0-cdh5.14.2/etc/hadoop/core-site.xml /kkb/install/hbase-1.2.0-cdh5.14.2/conf/core-site.xml
ln -s /kkb/install/hadoop-2.6.0-cdh5.14.2/etc/hadoop/hdfs-site.xml /kkb/install/hbase-1.2.0-cdh5.14.2/conf/hdfs-site.xml
1.5 添加HBase环境变量
- 注意:三台机器均执行以下命令,添加环境变量
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" spellcheck="false" mdtype="fences" cid="n89">sudo vim /etc/profile</pre>
- 文件末尾添加如下内容
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" spellcheck="false" mdtype="fences" cid="n93">export HBASE_HOME=/kkb/install/hbase-1.2.0-cdh5.14.2
export PATH=HBASE_HOME/bin</pre>
- 重新编译/etc/profile,让环境变量生效
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" spellcheck="false" mdtype="fences" cid="n97">source /etc/profile</pre>
1.6 HBase的启动与停止
-
需要提前启动HDFS及ZooKeeper集群
-
第一台机器node01(HBase主节点)执行以下命令,启动HBase集群
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" spellcheck="false" mdtype="fences" cid="n104">[hadoop@node01 ~]$ start-hbase.sh</pre>
-
启动完后,jps查看HBase相关进程
node01、node02上有进程HMaster、HRegionServer
node03上有进程HRegionServer
-
警告提示:HBase启动的时候会产生一个警告,这是因为jdk7与jdk8的问题导致的,如果linux服务器安装jdk8就会产生这样的一个警告
[图片上传失败...(image-681cb6-1585394988335)]
-
可以注释掉所有机器的hbase-env.sh当中的
"HBASE_MASTER_OPTS"和"HBASE_REGIONSERVER_OPTS"配置 来解决这个问题。
不过警告不影响我们正常运行,可以不用解决
-
我们也可以执行以下命令,单节点启动相关进程
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" spellcheck="false" mdtype="fences" cid="n120">#HMaster节点上启动HMaster命令
hbase-daemon.sh start master
启动HRegionServer命令
hbase-daemon.sh start regionserver</pre>
1.7 访问WEB页面
-
浏览器页面访问
[图片上传失败...(image-7227ee-1585394988335)]
1.8 停止HBase集群
-
停止HBase集群的正确顺序
-
node01上运行
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" lang="shell" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" spellcheck="false" mdtype="fences" cid="n133">[hadoop@node01 ~]$ stop-hbase.sh</pre>
- 若需要关闭虚拟机,则还需要关闭ZooKeeper、Hadoop集群