配置注意事项
1、 ssh
必须安装ssh , sshd 也必须运行,这样Hadoop的脚本才可以远程操控其他的Hadoop和HBase进程。ssh之间必须都打通,不用密码都可以登录,详细方法可以Google一下 ("ssh passwordless login").2、hostname
HBase使用本地 hostname 才获得IP地址. 正反向的DNS都是可以的.
如果你的机器有多个接口,HBase会使用hostname指向的主接口.
如果还不够,你可以设置 hbase.regionserver.dns.interface 来指定主接口。当然你的整个集群的配置文件都必须一致,每个主机都使用相同的网络接口
还有一种方法是设置 hbase.regionserver.dns.nameserver来指定nameserver,不使用系统带的.
3、/etc/hosts(本文使用ubuntu系统)
127.0.0.1 localhost
127.0.0.1 ubuntu.ubuntu-domain ubuntu
4、集群系统时间同步
集群的时钟要保证基本的一致。稍有不一致是可以容忍的,但是很大的不一致会造成奇怪的行为。 运行 NTP 或者其他什么东西来同步你的时间.
如果查询的时候或者是遇到奇怪的故障,可以检查一下系统时间是否正确。使用命令date。
5、Ubuntu上设置ulimit
如果你使用的是Ubuntu,你可以这样设置:
在文件 /etc/security/limits.conf 添加一行,如:
hadoop - nofile 32768
HBase 伪分布式模式配置:
伪分布式模式是一个相对简单的分布式模式。这个模式是用来测试的。不能把这个模式用于生产环节,也不能用于测试性能。
确认HDFS安装成功之后,就可以先编辑 conf/hbase-site.xml,在这个文件可以加入自己的配置。
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
/**
* Copyright 2010 The Apache Software Foundation
*
* 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>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>master</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
</configuration>
~
~
"hbase-site.xml" [readonly] 41L, 1345C
HDFS客户端配置
如果希望Hadoop集群上做HDFS 客户端配置 ,例如HDFS客户端的配置和服务端的不一样。按照如下的方法配置,HBase就能看到配置信息:在hbase-env.sh里将HBASE_CLASSPATH环境变量加上HADOOP_CONF_DIR 。
在${HBASE_HOME}/conf下面加一个 hdfs-site.xml (或者 hadoop-site.xml) ,最好是软连接
如果HDFS客户端的配置不多的话,可以把这些加到 hbase-site.xml上面.
例如HDFS的配置 dfs.replication.希望复制5份,而不是默认的3份。如果不照上面的做的话,HBase只会复制3份。
登陆web端
http://master:60010/master-status
常见错误及解决方法:
1、ERROR: org.apache.hadoop.hbase.MasterNotRunningException: Retried 7 times
查看日志:view + /usr/local/hadoop/hbase/hbase-0.94.11-security/logs/hbase-root-master-master.out
注:本文hbase的安装目录是:/usr/local/hadoop/hbase/hbase-0.94.11-security
错误原因:
A、可能还处于safe mode
B、RPC协议不一致(本文中在hbase的配置文件中将rootdir设置为hdfs,如果这两者的RPC协议不一致就会导致这个问题。)
C、查看日志发现是权限问题:
2013-09-09 10:28:02,878 WARN org.apache.hadoop.hbase.util.FSUtils: Unable to create version file at hdfs://master:9000/hbase, retrying: org.apache.hadoop.security.AccessControlException: Permission denied: user=root, access=WRITE, inode="hbase":hadoop:supergroup:rwxr-xr-x
2013-09-09 10:28:02,881 FATAL org.apache.hadoop.hbase.master.HMaster: Unhandled exception. Starting shutdown.
org.apache.hadoop.security.AccessControlException: org.apache.hadoop.security.AccessControlException: Permission denied: user=root, access=WRITE, inode="hbase":hadoop:supergroup:rwxr-xr-x
D、java.io.FileNotFoundException: /usr/local/hadoop/hbase/hbase-0.94.11-security/logs/SecurityAuth.audit (Permission denied)
解决方法:
A、使用命令查看hadoop是否处于安全模式,如果是,使离开。
$hadoop dfsadmin -safemode get
$hadoop dfsadmin -safemode leave
B、很简单,将hbase/lib目录下的hadoop-core的jar文件删除,将hadoop目录下的hadoop-x.y.z-core.jar拷贝到hbase/lib下面,然后重新启动hbase即可。
C、更改权限。
D、更改文件读写权限:
D、更改文件读写权限:
$sudo chmod a+rwx /usr/local/hadoop/hbase/hbase-0.94.11-security/bin/../logs/SecurityAuth.audit
2、ERROR: org.apache.hadoop.hbase.MasterNotRunningException: null
解决方法:
A、启动hadoop后,需要等一段时间,再开启hbase
B、去掉hadoop的安全模式:
hadoop dfsadmin -safemode leave