实验前提:HBase依赖Hadoop和ZooKeeper,本实验紧接Hadoop完全分布式和ZooKeeper集群部署实验,在Hadoop完全分布式和Zookeeper实验完成并运行成功的基础上继续进行Hbase完全分布式(非HA)部署演示
实验目标:在3台主机组成的小型集群上部署分布式数据库HBase ,用于教学演示
环境要求: 虚拟机VirtualBox 操作系统 Centos7 ZooKeeper版本 zookeeper-3.4.5-cdh5.7.0.tar.gz Hbase版本hbase-1.2.0-cdh5.7.0.tar.tz
集群规划:无需复制虚拟机,直接利用完全分布式集群的3台主机master,slave1,slave2完成Hbase完全分布式(非HA)部署
| 主机IP | 主机名 | 集群角色 |
|---|---|---|
| 192.168.56.10 | master | QuorumPeerMain NameNode DataNode HMaster |
| 192.168.56.11 | slave1 | QuorumPeerMain DataNode HRegionServer |
| 192.168.56.12 | slave2 | QuorumPeerMain DataNode HRegionServer |
〇 首先要部署完成并运行成功Hadoop完全分布式集群和ZooKeeper集群
一 搭建Hadoop完全分布式(非HA)集群的实验步骤
1)启动完全分布式集群中的3台主机master,slave1和slave2
2)在win7用XSHELL远程登录,注意VirtualBox主机网络管理器的虚拟网卡IP(192.168.56.1)地址必须和虚拟机Linux处于一个网段
3)解压缩hbase-1.2.0-cdh5.7.0.tar.gz安装包到指定目录/usr/local
在master, slave1,slave2三台主机上都要依次(不要同时)解压缩安装包:
tar -zxvf hbase-1.2.0-cdh5.7.0.tar.gz -C /usr/local/ 解压缩到/usr/local目录
特别提醒:千万不同时在3台虚拟机执行解压缩命令,很有可能造成死机!!!
5)设置环境变量并使之生效
在master, slave1,slave2三台主机上都要设置环境变量
vi /etc/profile 在配置文件profile的末尾增加以下内容:
# HBase
export HBASE_HOME=/usr/local/hbase-1.2.0-cdh5.7.0
export PATH=$HBASE_HOME/bin:$PATH
6)关闭防火墙firewall和SeLinux
执行关闭防火墙命令 systemctl disable firewalld 执行关闭SeLinux命令 setenforce 0
7)检查master, slave1,slave2互相之间的SSH免密登录(特别重要)
在每台主机上都要依次执行ssh master, ssh slave2, ssh slave2命令,检查免密登录,免密登录成功后,必须输入exit退出并返回原会话,以免搞混
8)修改配置文件(关键步骤)
cd /usr/local/hbase-1.2.0-cdh5.7.0/conf 切换到hbase-env.sh配置文件所在目录
a)先在master主机上修改hbase-env.sh
vi hbase-env.sh 修改以下参数:
export JAVA_HOME=/usr/local/java/jdk1.8
export HBASE_MANAGES_ZK=false
b)在master主机上修改hbase-site.xml
vi hbase-site.xml修改以下参数:
在<configuration> </configuration>之间增加蓝色字体配置参数
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://master:8020/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>master,slave1,slave2</value>
</property>
</configuration>
c)修改regionservers文件
vi regionservers
新添加三行:
master
slave1
slave2
9)拷贝Hadoop的两个配置文件core-site.xml和hdfs-site.xml到HBase的配置文件目录(有依赖关系)
依次执行命令 cp /usr/local/hadoop-2.6.0-cdh5.7.0/etc/hadoop/core-site.xml /usr/local/hbase-1.2.0-cdh5.7.0/conf
cp /usr/local/hadoop-2.6.0-cdh5.7.0/etc/hadoop/hdfs-site.xml /usr/local/hbase-1.2.0-cdh5.7.0/conf
10)将master上的多个配置文件远程拷贝复制到另外两台主机slave1和slave2
cd /usr/local/hbase-1.2.0-cdh5.7.0/conf 切换到配置文件所在目录
依次执行命令
scp hbase-env.sh hbase-site.xml core-site.xml hdfs-site.xml regionservers [email protected]:/usr/local/hbase-1.2.0-cdh5.7.0/conf/
scp hbase-env.sh hbase-site.xml core-site.xml hdfs-site.xml regionservers [email protected]:/usr/local/hbase-1.2.0-cdh5.7.0/conf/
11)在master执行start-dfs.sh启动HDFS,三台依次执行shServer.sh start启动ZooKeeper(如果已经启动可跳过本步骤)
12)启动HBase集群
在master主机执行HBase启动脚本start-hbase.sh,该脚本的作用是启动HBase的所有相关进程,一定要在master主机执行启动命令
13)执行java进程查看命令jps,在三台主机分别出现以下进程,说明HDFS,ZooKeeper和HBase全部都启动成功:
[[email protected] conf]# jps
4912 HMaster
5057 HRegionServer
2308 NameNode
2137 QuorumPeerMain
5580 Jps
[[email protected]
[[email protected] conf]# jps
2229 DataNode
2135 QuorumPeerMain
2285 SecondaryNameNode
3341 Jps
2975 HRegionServer
[[email protected] conf]# jps
3139 Jps
2822 HRegionServer
2264 DataNode
2142 QuorumPeerMain
14)在win7下,用chrome浏览器访问HBase自带的web配置网站 http://192.168.56.10:60010 ,能出现如下页面说明访问成功:
15)执行命令hbase shell进入hbase shell环境
[[email protected] conf]# hbase shell
2019-12-27 11:32:06,893 INFO [main] Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available
2019-12-27 11:32:08,974 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hbase-1.2.0-cdh5.7.0/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop-2.6.0-cdh5.7.0/share/hadoop/common/lib/slf4j-log4j12-1.7.5.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; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.2.0-cdh5.7.0, rUnknown, Wed Mar 23 11:46:29 PDT 2016
hbase(main):001:0>