zookeeper安装好,并启动成功后,接下来开始安装hbase
#下载hbase
wget http://mirror.bit.edu.cn/apache/hbase/1.3.1/hbase-1.3.1-bin.tar.gz
[root@master home]# ll
total 103248
drwxr-xr-x. 8 root root 191 Sep 5 22:31 eclipse
drwxr-xr-x. 13 20415 101 195 Sep 5 21:29 hadoop-2.7.4
-rw-r--r--. 1 root root 105718722 Jun 20 18:41 hbase-1.3.1-bin.tar.gz
drwxr-xr-x. 8 10 143 255 Jul 22 13:11 jdk1.8.0
drwx------. 3 xiaochangwei xiaochangwei 78 Sep 5 01:01 xiaochangwei
drwxr-xr-x. 10 1001 1001 4096 Sep 7 22:05 zookeeper-3.4.10
[root@master home]#
#解压到当前的home目录
tar -zxvf hbase-1.3.1-bin.tar.gz
#添加环境变量
vi /etc/profile
#内容如下红色部分,其他为之前配置的
export JAVA_HOME=/home/jdk1.8.0
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME
export PATH
export CLASSPATH
export HADOOP_HOME=/home/hadoop-2.7.4
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export YARN_CONF_DIR=$HADOOP_HOME/etc/hadoop
export HBASE=/home/hbase-1.3.1
export PATH=$HBASE/bin:$PATH
#使配置立即生效并验证 [root@master hbase-1.3.1]# source /etc/profile [root@master hbase-1.3.1]# hbase Usage: hbase [<options>] <command> [<args>] Options: --config DIR Configuration direction to use. Default: ./conf --hosts HOSTS Override the list in 'regionservers' file --auth-as-server Authenticate to ZooKeeper using servers configuration Commands: Some commands take arguments. Pass no args or -h for usage. shell Run the HBase shell hbck Run the hbase 'fsck' tool snapshot Tool for managing snapshots snapshotinfo Tool for dumping snapshot information wal Write-ahead-log analyzer hfile Store file analyzer zkcli Run the ZooKeeper shell upgrade Upgrade hbase master Run an HBase HMaster node regionserver Run an HBase HRegionServer node zookeeper Run a Zookeeper server rest Run an HBase REST server thrift Run the HBase Thrift server thrift2 Run the HBase Thrift2 server clean Run the HBase clean up script classpath Dump hbase CLASSPATH mapredcp Dump CLASSPATH entries required by mapreduce pe Run PerformanceEvaluation ltt Run LoadTestTool canary Run the Canary tool version Print the version CLASSNAME Run the class named CLASSNAME [root@master hbase-1.3.1]#
#修改hbase的环境变量和jdk环境变量
vi /home/hbase-1.3.1/conf/hbase-env.sh
export JAVA_HOME=/home/jdk1.8.0/
export HBASE_CLASSPATH=/home/hbase-1.3.1/conf
#配置 vi /home/hbase-1.3.1/conf/hbase-site.xml #修改为 <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- /** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ --> <configuration> <property> <name>hbase.rootdir</name> <value>hdfs://master:9000/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> <property> <name>hbase.tmp.dir</name> <value>/tmp/hbase</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/home/dataDir/zookeeper</value> </property> </configuration>
注意 hbase.zookeeper.property.dataDir 这个地址一定不要配置在/tmp 目录下
(刚开始我没管这个,后来停止hbase时报错
[root@master ~]# /home/hbase-1.3.1/bin/stop-hbase.sh
stopping hbase....................
master: no zookeeper to stop because no pid file /tmp/hbase-root-zookeeper.pid
slave2: no zookeeper to stop because no pid file /tmp/hbase-root-zookeeper.pid
slave1: no zookeeper to stop because no pid file /tmp/hbase-root-zookeeper.pid
原因就是默认是在/tmp下,但tmp目录下的东西重启后基本就会删除,所以指定的目录都不要在 /tmp
)
#配置从节点
vi /home/hbase-1.3.1/conf/regionservers
#去掉里面的localhost,修改为
slave1
slave2
#分别拷贝到slave节点
scp -r /home/hbase-1.3.1/ slave1:/home/
scp -r /home/hbase-1.3.1/ slave2:/home/
接下来依次启动hadoop-》zookeeper(每个几点要分别启动)-》hbase
启动命令如下:
#master上执行 启动hadoop
/home/hadoop-2.7.4/sbin/start-all.sh
#master,slave1,slave2上执行 启动zookeeper
/home/zookeeper-3.4.10/bin/zkServer.sh start /home/zookeeper-3.4.10/conf/zoo.cfg
#全部执行完毕后可以通过下列命令查看状态,比如是leader还是follower
/home/zookeeper-3.4.10/bin/zkServer.sh status
注意:请所有节点都执行启动命令后再通过status进行状态查看,否则看见的是
[root@master ~]# /home/zookeeper-3.4.10/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/zookeeper-3.4.10/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
通过 less /home/zookeeper-3.4.10/zookeeper.out 查看提示无法连接到其他节点
当然了,其他节点都还没启动,所以等所有节点都启动了,再通过status命令查看
#master上执行 启动hbase
/home/hbase-1.3.1/bin/start-hbase.sh
启动日志如下:
[root@master ~]# /home/hbase-1.3.1/bin/start-hbase.sh
master: starting zookeeper, logging to /home/hbase-1.3.1/bin/../logs/hbase-root-zookeeper-master.out
slave1: starting zookeeper, logging to /home/hbase-1.3.1/bin/../logs/hbase-root-zookeeper-slave1.out
slave2: starting zookeeper, logging to /home/hbase-1.3.1/bin/../logs/hbase-root-zookeeper-slave2.out
starting master, logging to /home/hbase-1.3.1/bin/../logs/hbase-root-master-master.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
slave1: starting regionserver, logging to /home/hbase-1.3.1/bin/../logs/hbase-root-regionserver-slave1.out
slave2: starting regionserver, logging to /home/hbase-1.3.1/bin/../logs/hbase-root-regionserver-slave2.out
slave1: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
slave1: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
slave2: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
slave2: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
通过jps命令可以查看节点运行情况
#master
[root@master ~]# date
Fri Sep 8 21:06:42 CST 2017
[root@master ~]# jps
2657 QuorumPeerMain
3108 SecondaryNameNode
3269 ResourceManager
3909 HMaster
2902 NameNode
4281 Jps
[root@master ~]#
#slave1
[root@slave1 ~]# date
Fri Sep 8 21:07:10 CST 2017
[root@slave1 ~]# jps
3160 HRegionServer
2636 QuorumPeerMain
2748 DataNode
2877 NodeManager
3503 Jps
[root@slave1 ~]#
#slave2
[root@slave2 ~]# date
Fri Sep 8 21:07:32 CST 2017
[root@slave2 ~]# jps
2626 QuorumPeerMain
3146 HRegionServer
3467 Jps
2732 DataNode
2861 NodeManager
[root@slave2 ~]#
同时可以打开 http://master:16010/master-status 进行UI界面访问, 若需修改端口 ,请在hbase-site.xml中配置 hbase.master.info.port
官方参考配置及全部参数详解可以参考 http://hbase.apache.org/book.html#example_config
另外可以通过如下命令测试hbase是否搭建成功
hbase hbck
另外
HBase集群需要依赖于一个Zookeeperensemble。
HBase集群中的所有节点以及要访问HBase的客户端都需要能够访问到该Zookeeper ensemble。
此外,Zookeeper ensemble一般配置为奇数个节点,并且Hadoop集群、Zookeeper ensemble、HBase集群是三个互相独立的集群,并不需要部署在相同的物理节点上,他们之间是通过网络通信的。
Hbase不需要mapreduce,所以只要start-dfs.sh启动hdfs,然后到zookeeper各节点上启动zookeeper,最后再hbase-start.sh启动hbase即可.
至此,hbase配置、安装、启动完毕
下一篇将讲解Hbase的使用方法