基于Hadoop集群的HBase集群的配置【2】

时间:2022-12-27 08:26:22

基于Hadoop集群的HBase集群的配置

1.准备工作

a.已经完成安装的Hadoop集群环境

b.所需要的软件包

zookeeper-3.4.4.tar.gz下载地址:

http://downloads.gotsoft.com/pub/apache/zookeeper/zookeeper-3.4.4/

 

hbase-0.94.6.1tar.gz下载地址:

http://labs.mop.com/apache-mirror/hbase/stable/hbase-0.94.6.1.tar.gz

 

2.单独安装的ZooKeeper集群,不基于Hbase集群管理

a.在Master节点上解压zookeeper

##建议使用hduser权限,避免之后出现SSH错误

hduser@master:/usr/local$sudo tar -zxvfzookeeper-3.4.4.tar.gz

 

##server后面的数字是zooKeeper识别时后的Id,需要与后面的设置保持一致

hduser@master:/usr/local$tvi /zookeeper/conf/zoo.cfg

 

tickTime=2000

      initLimit=5

      syncLimit=2

     dataDir=/data/zookeeper

      clientPort=2181

     server.1=master:2888:3888

     server.2=slave1:2888:3888

      server.3=slave2:2888:3888

 

root@master:/usr/local# chown -Rhduser:hadoop zookeeper

 

3.将zookeeper复制到其他机器

hduser@master:/usr/local$scp -r zookeeper-3.4.5hduser@slave1:/home/hduser

hduser@master:/usr/local$ scp -rzookeeper-3.4.5 hduser@slave2:/home/hduser

 

hduser@slave1:~#sudomv zookeeper-3.4.5/ /usr/local/zookeeper-3.4.5

 

hduser@slave2:~$sudomv zookeeper-3.4.5/ /usr/local/zookeeper-3.4.5

 

4.在每台机器配置的dataDir目录下面,创建myid文件标志当前主机

Master:     $touch /data/zookeeper/myid

                $echo "1" >/data/zookeeper/myid

Slave1:      $mkdir -p /data/zookeeper

                $touch /data/zookeeper/myid

                $echo "3" > /data/zookeeper/myid

Slave2:       $mkdir -p/data/zookeeper

                $touch /data/zookeeper/myid

                $echo "5" > /data/zookeeper/myid

 

5. 启动zookeeper集群

hduser@master:/usr/local/zookeeper/bin$./zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
问题1Starting zookeeper ... ./zkServer.sh: line 113:/data/zookeeper/zookeeper_server.pid: Permission denied
FAILED TO WRITE PID

原因是刚才/data/zookeeper是root权限,而不是hduser的,修改权限之~

问题1解决root@master:/# chown -Rhduser:hadoop /data

其他两个slave节点也一样~

然后问题解决:

hduser@master:/usr/local/zookeeper$ cd bin
hduser@master:/usr/local/zookeeper/bin$ ./zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

其他节点也同样启动zookeeper~
hduser@master:/usr/local/zookeeper/bin$ 

hduser@slave1:/usr/local/zookeeper/bin$./zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
问题2Error contacting service. It is probably notrunning.


1)查看zoopkeeper.out

r@232] - Unexpected exception,tries=0, connecting to slave1/192.168.123.12:2888
java.net.ConnectException: Connection refused
        atjava.net.PlainSocketImpl.socketConnect(Native Method)
        atjava.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
        atjava.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
        atjava.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
        atjava.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)

 


root@master:/usr/local/zookeeper/bin#cat zookeeper.out 

2013-04-27 00:22:37,595 [myid:] - INFO [main:QuorumPeerConfig@101] - Reading configuration from:/usr/local/zookeeper/bin/../conf/zoo.cfg

2013-04-27 00:22:37,615 [myid:] - ERROR[main:QuorumPeerMain@85] - Invalid config, exiting abnormally

org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException:Error processing /usr/local/zookeeper/bin/../conf/zoo.cfg

        at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:121)

        atorg.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:101)

        atorg.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)

Caused by:java.lang.IllegalArgumentException: dataLogDir /home/hduser/zookeeper/log ismissing.

        atorg.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:247)

        atorg.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:117)

        ... 2 more

Invalid config, exiting abnormally

 


【错误2解决】没有将zookeeper复制到其他的节点!!!

                   没有在每个节点启动zookeeper

6.安装配置Hbase集群

a>启动HDFS集群实例,并创建目录

##hdfs://master01:54310/hbase【注意与hadoop,core-site.xml中的fs.default.name中的端口号保持一致,统一设置为54310;hbase-site.xml中的hbase:rootdir中的端口号】

hduser@master:/usr/local/hadoop$bin/hadoop fs -mkdir /hbase

Warning: $HADOOP_HOME is deprecated.

 

13/04/27 02:08:46 INFO ipc.Client: Retryingconnect to server: master/127.0.1.1:54310. Already tried 0 time(s).

13/04/27 02:08:47 INFO ipc.Client: Retryingconnect to server: master/127.0.1.1:54310. Already tried 1 time(s).

13/04/27 02:08:48 INFO ipc.Client: Retryingconnect to server: master/127.0.1.1:54310. Already tried 2 time(s).

13/04/27 02:08:49 INFO ipc.Client: Retryingconnect to server: master/127.0.1.1:54310. Already tried 3 time(s).

13/04/27 02:08:50 INFO ipc.Client: Retryingconnect to server: master/127.0.1.1:54310. Already tried 4 time(s).

13/04/27 02:08:51 INFO ipc.Client: Retryingconnect to server: master/127.0.1.1:54310. Already tried 5 time(s).

13/04/27 02:08:52 INFO ipc.Client: Retryingconnect to server: master/127.0.1.1:54310. Already tried 6 time(s).

13/04/27 02:08:53 INFO ipc.Client: Retryingconnect to server: master/127.0.1.1:54310. Already tried 7 time(s).

13/04/27 02:08:54 INFO ipc.Client: Retryingconnect to server: master/127.0.1.1:54310. Already tried 8 time(s).

13/04/27 02:08:55 INFO ipc.Client: Retryingconnect to server: master/127.0.1.1:54310. Already tried 9 time(s).

Bad connection to FS. command aborted.exception: Call to master/127.0.1.1:54310 failed on connection exception:java.net.ConnectException: Connection refused

hduser@master:/usr/local/hadoop$ 

 

Call tomaster/127.0.1.1:54310 failed【修改localhost地址为127.0.0.1

 

 

HBASE SHELL 错误NativeException: org.apache.hadoop.hbase.MasterNotRunningException:null

【解决步骤:】

1、启动hadoop后,需要等一段时间,再开启hbase

2、去掉hadoop的安全模式:

hadoop dfsadmin -safemode leave

3、把/etc/hosts里的master01的IP改为服务器当前的IP

4、确认hbase的hbase-site.xml中

<name>hbase.rootdir</name>

<value>hdfs://localhost:8020/hbase</value>

与hadoop的core-site.xml中

<name>fs.default.name</name>

<value>hdfs://localhost:8020</value>

红字部分保持一致

5、确认hadoop版本是0.20.2,hbase版本是0.20.6

6、重新执行./start-hbase.sh之前,先kill掉当前的hbase和zookeeper进程

 

之后再执行:

$bin/hadoop fs -mkdir /hbase

 

 

 b> 解压hbase-0.94.5.tar.gz,修改配置文件,正式安装HBase:

l  #vi hbase-0.94.5/conf/hbase-env.sh 

 

      exportJAVA_HOME=/usr/java/jdk1.6.0_43

      exportHBASE_CLASSPATH=$HBASE_HOME/

      #exportHBASE_HEAPSIZE=128

      #exportHBASE_OPTS="-XX:+UseConcMarkSweepGC"

      exportHBASE_MANAGES_ZK=false

 

#vi hbase-0.94.5/conf/regionservers

 

    slave1

    slave2

 

l  将hbase-webapps目录改名为webapps

hduser@master:/usr/local/hbase-0.94.6$ mvhbase-webapps/ /webapps

 

l  检查HBase配置,复制到其他的slave节点:

hduser@master:/usr/local$ scp -rhbase-0.94.6 hduser@slave1:/home/hduser/

hduser@master:/usr/local$ scp -rhbase-0.94.6 hduser@slave2:/home/hduser/

 

l  启动HBase:

hduser@master:/usr/local$ ./hbase-0.94.6/bin/start-hbase.sh
starting master, logging to/usr/local/hbase-0.94.6/bin/../logs/hbase-hduser-master-master.out
slave2: starting regionserver, logging to/usr/local/hbase-0.94.6/bin/../logs/hbase-hduser-regionserver-slave2.out
slave1: starting regionserver, logging to/usr/local/hbase-0.94.6/bin/../logs/hbase-hduser-regionserver-slave1.out

 

l  查看相关进程:

hduser@master:/usr/local$ jps

3339 QuorumPeerMain

8210 JobTracker

7894 DataNode

9187 HMaster

8126 SecondaryNameNode

8459 TaskTracker

9328 Jps

7659 NameNode

hduser@master:/usr/local$

 

hduser@slave1:~$ jps

5416 TaskTracker

5879 Jps

5210 DataNode

3323 QuorumPeerMain

hduser@slave1:~$

 

 

 hduser@slave2:/usr/local/hbase-0.94.6$ jps

5083 TaskTracker

5544 Jps

4877 DataNode

3042 QuorumPeerMain

 

【错误】13/04/27 05:47:21ERROR client.HConnectionManager$HConnectionImplementation: Check the valueconfigured in 'zookeeper.znode.parent'. There could be a mismatch with the oneconfigured in the master.

 


l  去掉hadoop的安全模式

hduser@master:/usr/local/hadoop$ bin/hadoopdfsadmin -safemode leave
Warning: $HADOOP_HOME is deprecated.

Safe mode is OFF

 

【解决方法】:http://blog.sina.com.cn/s/blog_718335510100zchp.html

 

 

l  检验HBase安装完成:

hbase(main):003:0> create'member','member_id','address','info'
0 row(s) in 1.6400 seconds


hbase(main):004:0> list
TABLE                                                                          
member                                                                         
1 row(s) in 0.0730 seconds

 

hbase(main):006:0* describe 'member'
DESCRIPTION                                         ENABLED                   
{NAME => 'member', FAMILIES => [{NAME => 'address',true                      
  DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER =>'NON                           
E', REPLICATION_SCOPE => '0', VERSIONS => '3', COMP                           
RESSION => 'NONE', MIN_VERSIONS => '0', TTL =>'214                           
7483647', KEEP_DELETED_CELLS => 'false',BLOCKSIZE                            
=> '65536', IN_MEMORY => 'false', ENCODE_ON_DISK=>                           
  'true', BLOCKCACHE => 'true'}, {NAME => 'info',DA                           
TA_BLOCK_ENCODING => 'NONE', BLOOMFILTER =>'NONE',                           
  REPLICATION_SCOPE => '0', VERSIONS => '3',COMPRES                           
SION => 'NONE', MIN_VERSIONS => '0', TTL =>'214748                           
3647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE=>                            
'65536', IN_MEMORY => 'false', ENCODE_ON_DISK =>'t                           
rue', BLOCKCACHE => 'true'}, {NAME =>'member_id',                            
DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER =>'NONE                           
', REPLICATION_SCOPE => '0', VERSIONS => '3',COMPR                           
ESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147                           
483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE=                           
> '65536', IN_MEMORY => 'false', ENCODE_ON_DISK=>                            
'true', BLOCKCACHE =>'true'}]}                                               
1 row(s) in 0.2170 seconds