centos7.6 配置Hbase 和 zookeeper
源码和jar包地址
1 zookeeper安装部署
1.1 进入到Zookeeper安装包路径下
cd /opt/software/
1.2 解压安装文件到/opt/module下面
[shine@huachuan01 software]$ ll
total 514236
-rw-rw-r-- 1 shine shine 214092195 Jan 17 16:14 hadoop-2.7.3.tar.gz
-rw-rw-r-- 1 shine shine 104497899 Jan 17 16:28 hbase-1.2.4-bin.tar.gz
-rw-rw-r-- 1 shine shine 195013152 Jan 17 17:16 jdk-8u212-linux-x64.tar.gz
-rw-rw-r-- 1 shine shine 22724574 Jan 17 16:11 zookeeper-3.4.9.tar.gz
[shine@huachuan01 conf]$ tar -zxvf /opt/software/zookeeper-3.4.9.tar.gz -C /opt/module/
1.3 查看是否解压成功
[shine@huachuan01 software]$ ls /opt/module/
zookeeper-3.4.9
1.4 进入zookeeper的conf目录并查看目录下的文件
[shine@huachuan01 conf]$cd /opt/module/zookeeper-3.4.9/conf
[shine@huachuan01 conf]$ ll
total 12
-rw-rw-r-- 1 shine shine 535 Aug 23 2016 configuration.xsl
-rw-rw-r-- 1 shine shine 2161 Aug 23 2016 log4j.properties
-rw-rw-r-- 1 shine shine 922 Aug 23 2016 zoo_sample.cfg
[shine@huachuan01 conf]$
1.5 复制 zoo_sample.cfg 改名为zoo.cfg 到本目录
[shine@huachuan01 conf]$ cp zoo_sample.cfg zoo.cfg
[shine@huachuan01 conf]$ ll
total 16
-rw-rw-r-- 1 shine shine 535 Aug 23 2016 configuration.xsl
-rw-rw-r-- 1 shine shine 2161 Aug 23 2016 log4j.properties
-rw-rw-r-- 1 shine shine 922 Jan 17 19:46 zoo.cfg
-rw-rw-r-- 1 shine shine 922 Aug 23 2016 zoo_sample.cfg
1.6 修改zoo.cfg配置文件
在最后一行添加
server.1=localhost:2888:3888
1.7创建/tmp/zookeeper目录
[shine@huachuan01 /]$ mkdir /tmp/zookeeper
1.8 在/tmp/zookeeper/下创建myid文件,在myid中第一行添加 1
[shine@huachuan01 zookeeper]$ touch /tmp/zookeeper/myid
[shine@huachuan01 zookeeper]$ vim /tmp/zookeeper/myid
1
1.9启动zookeeper并查看状态
[shine@huachuan01 zookeeper-3.4.9]$ /opt/module/zookeeper-3.4.9/bin/zkServer.sh start
[shine@huachuan01 zookeeper-3.4.9]$ /opt/module/zookeeper-3.4.9/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.4.9/bin/../conf/zoo.cfg
Mode: standalone
看到Mode: standalone 说明启动成功
2 Hbase的部署
2.1 在Linux系统下的opt目录中查看软件包是否导入成功
[shine@huachuan01 bin]$ ls /opt/software/
看到hbase-1.2.4-bin.tar.gz文件说明导入成功
2.2 解压Hbase到/opt/module目录下
[shine@huachuan01 bin]$ tar -zxvf /opt/software/hbase-1.2.4-bin.tar.gz -C /opt/module/
2.3 查看是否解压成功
[shine@huachuan01 bin]$ ls /opt/module/
hbase-1.2.4
2.4 进入Hbase的配置文件目录并查看
[shine@huachuan01 bin]$ cd /opt/module/hbase-1.2.4/conf/
[shine@huachuan01 conf]$ ll
total 40
-rw-r--r-- 1 shine shine 1811 Dec 27 2015 hadoop-metrics2-hbase.properties
-rw-r--r-- 1 shine shine 4537 Jan 29 2016 hbase-env.cmd
-rw-r--r-- 1 shine shine 7468 Jan 29 2016 hbase-env.sh
-rw-r--r-- 1 shine shine 2257 Dec 27 2015 hbase-policy.xml
-rw-r--r-- 1 shine shine 934 Dec 27 2015 hbase-site.xml
-rw-r--r-- 1 shine shine 4339 Jan 29 2016 log4j.properties
-rw-r--r-- 1 shine shine 10 Dec 27 2015 regionservers
2.5 将hadoop的配置文件core-site.xml hdfs-site.xml 拷贝到hbase的conf目录下
[shine@huachuan01 conf]$ cp /opt/module/hadoop-2.7.3/etc/hadoop/core-site.xml /opt/module/hbase-1.2.4/conf
[shine@huachuan01 conf]$ cp /opt/module/hadoop-2.7.3/etc/hadoop/hdfs-site.xml /opt/module/hbase-1.2.4/conf
[shine@huachuan01 conf]$ ll /opt/module/hbase-1.2.4/conf/
total 48
-rw-r--r-- 1 shine shine 1085 Jan 17 19:00 core-site.xml
-rw-r--r-- 1 shine shine 1811 Dec 27 2015 hadoop-metrics2-hbase.properties
-rw-r--r-- 1 shine shine 4537 Jan 29 2016 hbase-env.cmd
-rw-r--r-- 1 shine shine 7468 Jan 29 2016 hbase-env.sh
-rw-r--r-- 1 shine shine 2257 Dec 27 2015 hbase-policy.xml
-rw-r--r-- 1 shine shine 934 Dec 27 2015 hbase-site.xml
-rw-r--r-- 1 shine shine 1214 Jan 17 19:00 hdfs-site.xml
-rw-r--r-- 1 shine shine 4339 Jan 29 2016 log4j.properties
-rw-r--r-- 1 shine shine 10 Dec 27 2015 regionservers
2.6 配置habase-env.sh 配置环境变量
[shine@huachuan01 conf]$ vim hbase-env.sh
修改
修改一:
在# export JAVA_HOME=/usr/java/jdk1.6.0/ 下一行添加
export JAVA_HOME=/opt/module/jdk1.8.0_212
修改二:
注释下面两行
export HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS -XX:PermSize=128m -XX:MaxPermSize=128m"
export HBASE_REGIONSERVER_OPTS="$HBASE_REGIONSERVER_OPTS -XX:PermSize=128m -XX:MaxPermSize=128m"
修改后
#export HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS -XX:PermSize=128m -XX:MaxPermSize=128m"
#export HBASE_REGIONSERVER_OPTS="$HBASE_REGIONSERVER_OPTS -XX:PermSize=128m -XX:MaxPermSize=128m"
修改三:
将#export HBASE_MANAGES_ZK=true 修改为
export HBASE_MANAGES_ZK=false
2.7 修改hbase-site.xml
在最下面的configuration中添加
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:9000/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/opt/module/hadoop-2.7.3/hadoop_data/zookeeper</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>localhost</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
<property>
<name>hbase.hregion.menstore.flush.size</name>
<value>268435456</value>
</property>
<property>
<name>hbase.hregion.max.filesize</name>
<value>107374182400</value>
</property>
<property>
<name>hbase.hregion.majorcompaction</name>
<value>0</value>
</property>
3 habse要想运行,先启动zookeeper在启动hadoop最后启动hbase
[shine@huachuan01 module]$ /opt/module/zookeeper-3.4.9/bin/zkServer.sh start
[shine@huachuan01 module]$ start-dfs.sh
[shine@huachuan01 module]$ start-yarn.sh
[shine@huachuan01 conf]$ /opt/module/hbase-1.2.4/bin/start-hbase.sh
3.1 查看后台进程 jps
[shine@huachuan01 conf]$ jps
8786 HMaster
8325 ResourceManager
7877 NameNode
8008 DataNode
9916 Jps
7709 QuorumPeerMain
8173 SecondaryNameNode
8910 HRegionServer
3.2 进入hbase shell命令创建表
[shine@huachuan01 conf]$ /opt/module/hbase-1.2.4/bin/hbase shell
hbase(main):002:0> create 'stu','info'
hbase(main):002:0> list
TABLE
stu
1 row(s) in 0.0160 seconds
=> ["stu"]
能够查询到创建的表 说明hbase已经配置成功 哈哈~