zookeeper清空hbase_Hadoop学习---Zookeeper+Hbase配置学习

软件版本号:

JDK:jdk-8u45-linux-i586.tar.gz

Zookeeper:zookeeper-3.4.6

Hbase:hbase-1.0.0-bin

一、JDK版本更换

由于之前安装的jdk-6u45-linux-i586版本较低,与Hbase不兼容,因此更换为jdk-8u45-linux-i586

1.jdk 1.6卸载

(1)删除jdk目录:sudo rm -rf /opt/jdk1.6.0_45

(2)删除jdk环境变量:sudo gedit /etc/profile

删除代码段:

# java

export JAVA_HOME=/opt/jdk1.6.0_45

export JRE_HOME=$JAVA_HOME/jre

export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

2.jdk 1.8安装

(1)复制jdk-8u45-linux-i586.tar.gz到/opt目录下并解压为文件夹jdk

(2)配置jdk环境变量:sudo gedit /etc/profile

添加代码段:

# java

export JAVA_HOME=/opt/jdk1.8.0_45

export JRE_HOME=$JAVA_HOME/jre

export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

(3)执行命令,使配置生效:source /etc/profile;

(4)执行命令:java -version,若出现java版本号,则说明安装成功。

(5)修改/home/hduser/hadoop/etc/hadoop路径下hadoop-env.sh和yarn-env.sh中jdk的版本号

(6)Ubuntu2执行相同操作

二、Zookeeper配置

1.Zookeeper配置

(1)复制zookeeper-3.4.6.tar.gz到/home/hduser目录下并解压为文件夹zookeeper-3.4.6

(2)配置Zookeeper环境变量:sudo gedit /etc/profile

添加代码段:

#zookeeper

export ZOOKEEPER_HOME=/home/hduser/zookeeper-3.4.6

export PATH=$ZOOKEEPER_HOME/bin:$ZOOKEEPER_HOME/conf:$PATH

(3)新建zoo.cfg并修改:

hduser@Ubuntu1:~/zookeeper-3.4.6$ cp conf/zoo_sample.cfg conf/zoo.cfg

清空zoo.cfg中代码,然后添加以下代码段:

tickTime=2000

initLimit=10

syncLimit=5

dataDir=/home/hduser/zookeeper-3.4.6/zookeeper

dataLogDir=/home/hduser/zookeeper-3.4.6/log

clientPort=2181

server.1=Ubuntu1:2888:3888

server.2=Ubuntu2:2888:3888

(4)在/home/hduser/zookeeper-3.4.6目录下新建文件夹zookeeper,在其中新建文件myid,并写入“1”

(5)Ubuntu2执行相同操作,不同点是myid写入的值为“2”。

2.Zookeeper测试

(1)各节点启动:

hduser@Ubuntu1:~/zookeeper-3.4.6$ bin/zkServer.sh start

hduser@Ubuntu2:~/zookeeper-3.4.6$ bin/zkServer.sh start

(2)jps查看:3347 QuorumPeerMain

(3)查看状态:

hduser@Ubuntu1:~/zookeeper-3.4.6$ bin/zkServer.sh status

JMX enabled by default

Using config: /home/hduser/zookeeper-3.4.6/bin/../conf/zoo.cfg

Mode: follower

hduser@Ubuntu2:~/zookeeper-3.4.6$ bin/zkServer.sh status

JMX enabled by default

Using config: /home/hduser/zookeeper-3.4.6/bin/../conf/zoo.cfg

Mode: leader

(4)停止ZooKeeper:

hduser@Ubuntu1:~/zookeeper-3.4.6$ bin/zkServer.sh stop

三、Hbase配置

1.Hbase分布式配置

(1)下载安装包hbase-1.0.0-bin.tar.gz并复制到/home/hduser目录下并解压为文件夹hbase-1.0.0

(2)修改conf/hbase-site.xml文件:

添加代码段:

hbase.rootdir

hdfs://Ubuntu1:9000/hbase

hbase.cluster.distributed

true

hbase.zookeeper.property.clientPort

2181

hbase.zookeeper.quorum

Ubuntu1,Ubuntu2

hbase.zookeeper.property.dataDir

/home/hduser/zookeeper-3.4.6/zookeeper

dfs.support.append

true

(3)修改conf/regionservers文件:

添加:Ubuntu1

Ubuntu2

(4)修改conf/hbase-env.sh文件:

添加:

export JAVA_HOME=/opt/jdk1.7.0_07

export HBASE_MANAGES_ZK=false

export HBASE_HOME=/home/hduser/hbase-1.0.0

export HADOOP_HOME=/home/hduser/hadoop

(5)修改各节点Hadoop的hdfs-site.xml文件:

添加:

dfs.datanode.max.xcievers

4096

注:该参数限制了datanode所允许同时执行的发送和接受任务的数量,缺省为256

(6)Ubuntu2执行相同操作

Hbase配置

1.Hbase配置单机

(1)下载安装包hbase-1.0.0-bin.tar.gz并复制到到/home/hduser目录下并解压为文件夹hbase-1.0.0

(2)修改conf/hbase-site.xml文件:

添加代码段:

hbase.rootdir

hdfs://Ubuntu1:9000/hbase

hbase.cluster.distributed

false

hbase.zookeeper.property.clientPort

2181

hbase.zookeeper.quorum

Ubuntu1

hbase.zookeeper.property.dataDir

/home/hduser/zookeeper-3.4.6/zookeeper

dfs.support.append

true

(3)修改conf/regionservers文件:

添加:Ubuntu1

(4)修改conf/hbase-env.sh文件:

添加:

export JAVA_HOME=/opt/jdk1.8.0_45

export HBASE_MANAGES_ZK=true

export HBASE_HOME=/home/hduser/hbase-1.0.0

export HADOOP_HOME=/home/hduser/hadoop

(5)修改各节点Hadoop的hdfs-site.xml文件:

添加:

dfs.datanode.max.xcievers

4096

注:该参数限制了datanode所允许同时执行的发送和接受任务的数量,缺省为256

2.Hbase测试

启动顺序:Hadoop→Zookeeper→Hbase,结束顺序:Hbase→Zookeeper→Hadoop

(1)启动Hbase:

hduser@Ubuntu1:~/hbase-1.0.0$ bin/start-hbase.sh

(2)jps查看:

# 主节点 Ubuntu1: jps

3491 HMaster

2887 NameNode

3640 HRegionServer

3347 QuorumPeerMain

3010 DataNode

3727 Jps

3168 SecondaryNameNode

# 从节点Ubuntu2:

2870 DataNode

3280 Jps

2953 QuorumPeerMain

3054 HRegionServer

(3)进入hbase shell:

hduser@Ubuntu1:~/hbase-1.0.0$ bin/hbase shell

(4)查看集群状态

hbase(main):001:0> status

(5)建表测试:

hbase(main):003:0> create 'test1','id1'

0 row(s) in 1.8420 seconds

=>Hbase::Table - test1

=>Hbase::Table - test1

hbase(main):004:0> list

TABLE

test

test1

2 row(s) in 0.1770 seconds

=> ["test", "test1"]

注:如果jps之后显示没有安装jdk,则执行source /etc/profile后再jps

其他

注意:有时会出现Can't get master address from ZooKeeper; znode data == null

解决方法是关掉Hbase 关掉Zookeeper 删除zookeeper数据目录下相关文件(myid文件保留),启动zookeeper ,启动Hbase,

如果不行,还可以关掉hadoop,格式化namenode。

还不行,查看hbase的启动日志。可能是端口被占用,用相关命令查询。比如下面日志例子:

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.

说明进程占用了默认的2181端口导致ZK不能正常启动。使用lsof -i:2181命令查看2181端口的进程情况:

如果Hadoop用户的java进程在使用。Kill对应进程,,重新启动Hbase shell。

启动HDFS:./sbin/start-dfs.sh

停止HDFS:./sbin/stop-dfs.sh

启动yarn:./sbin/start-yarn.sh

停止yarn:./sbin/stop-yarn.sh

启动Zookeeper:bin/zkServer.sh start

停止Zookeeper:bin/zkServer.sh stop

启动Hbase:bin/start-hbase.sh

停止Hbase:bin/stop-hbase.sh

你可能感兴趣的:(zookeeper清空hbase_Hadoop学习---Zookeeper+Hbase配置学习)