首页 > 代码库 > hbase centOS生产环境配置笔记 (1 NameNode, 1 ResourceManager, 3 DataNode)

hbase centOS生产环境配置笔记 (1 NameNode, 1 ResourceManager, 3 DataNode)

本次是第一次在生产环境部署HBase,本文若有配置上的不妥之处还请高手指正。

hadoop版本:hadoop-2.4.1

HBase版本:hbase-0.98.6.1-hadoop2

JDK:1.6

操作系统:centOS6.3 64bit

 

1. 安装snappy

#yum install snappy
Installed: snappy.x86_64 0:1.1.0-1.el6
#yum install snappy-devel

记录一下,当前GCC版本4.4.7

 

2. 由于hadoop官网下载的bin包中包含的native lib是32bit环境编译的,需要重新编译hadoop源码以获得64bit的native lib。

$ file libhadoop.so.1.0.0libhadoop.so.1.0.0: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped

(1) 在hadoop官网下载 hadoop-2.4.1-src.tar.gz。解压后打开 BUILDING.txt

Requirements:* Unix System* JDK 1.6+* Maven 3.0 or later* Findbugs 1.3.9 (if running findbugs)* ProtocolBuffer 2.5.0* CMake 2.6 or newer (if compiling native code)* Internet connection for first build (to fetch all Maven and Hadoop dependencies)

按照上述指示,

(2) 下载 Maven:http://maven.apache.org/download.cgi

(3) 下载 ProtocolBuffer 2.5.0: https://code.google.com/p/protobuf/downloads/list,解压编译

$ cd protobuf-2.6.1$ ./configure

出现以下错误:

configure: error: C++ preprocessor "/lib/cpp" fails sanity check

经过网上搜索,需要安装c++相关的库:

# yum install glibc-headers# yum install gcc-c++

再次执行 ./configure,这次通过了。

然后就可以make了

$ make# make install

安装成功后,可以在/usr/local/lib/下看到库文件:

-rw-r--r-- 1 root root 22955150 Oct 23 11:41 libprotobuf.a-rwxr-xr-x 1 root root      988 Oct 23 11:41 libprotobuf.la-rw-r--r-- 1 root root  2233428 Oct 23 11:41 libprotobuf-lite.a-rwxr-xr-x 1 root root     1023 Oct 23 11:41 libprotobuf-lite.lalrwxrwxrwx 1 root root       25 Oct 23 11:41 libprotobuf-lite.so -> libprotobuf-lite.so.9.0.1lrwxrwxrwx 1 root root       25 Oct 23 11:41 libprotobuf-lite.so.9 -> libprotobuf-lite.so.9.0.1-rwxr-xr-x 1 root root  1038614 Oct 23 11:41 libprotobuf-lite.so.9.0.1lrwxrwxrwx 1 root root       20 Oct 23 11:41 libprotobuf.so -> libprotobuf.so.9.0.1lrwxrwxrwx 1 root root       20 Oct 23 11:41 libprotobuf.so.9 -> libprotobuf.so.9.0.1-rwxr-xr-x 1 root root  9300568 Oct 23 11:41 libprotobuf.so.9.0.1-rw-r--r-- 1 root root 39008232 Oct 23 11:41 libprotoc.a-rwxr-xr-x 1 root root     1004 Oct 23 11:41 libprotoc.lalrwxrwxrwx 1 root root       18 Oct 23 11:41 libprotoc.so -> libprotoc.so.9.0.1lrwxrwxrwx 1 root root       18 Oct 23 11:41 libprotoc.so.9 -> libprotoc.so.9.0.1-rwxr-xr-x 1 root root 13252621 Oct 23 11:41 libprotoc.so.9.0.1

 

(4) 安装cmake

# yum install cmake

 

(5) 安装openssl 

# yum install openssl# yum install openssl-devel

 

(6) 安装zlib相关

# yum install zlib# yum install zlib-devel

 

(7) 下载 ant 1.9.4

下载 http://ant.apache.org/bindownload.cgi

也可以直接 yum install ant

 

(8) 设置环境变量: 

export JAVA_HOME=/usr/java/jdk1.6.0_43
export PATH="$JAVA_HOME/bin:$PATH"

export MAVEN_HOME=/data2/hadoop_source/apache-maven-3.2.3
export PATH="$MAVEN_HOME/bin:$PATH"
export ANT_HOME=/data2/hadoop_source/apache-ant-1.9.4export PATH="$PATH:$ANT_HOME/bin"

 

(9) 编译hadoop的native库:

/data2/hadoop_source/apache-maven-3.2.3/bin/mvn package -X -Pdist,native -Dtar -DskipTests -Drequire.snappy

 最后即使有部分project编译出错也没有关系,只要 hadoop-hdfs-project,hadoop-common-project 编译通过就可以了。

 (10) 编译完成后,可以找到native lib:

# find . -name lib*.so*./hadoop-hdfs-project/hadoop-hdfs/target/hadoop-hdfs-2.4.1/lib/native/libhdfs.so./hadoop-hdfs-project/hadoop-hdfs/target/hadoop-hdfs-2.4.1/lib/native/libhdfs.so.0.0.0./hadoop-hdfs-project/hadoop-hdfs/target/native/target/usr/local/lib/libhdfs.so./hadoop-hdfs-project/hadoop-hdfs/target/native/target/usr/local/lib/libhdfs.so.0.0.0./hadoop-common-project/hadoop-common/target/hadoop-common-2.4.1/lib/native/libhadoop.so.1.0.0./hadoop-common-project/hadoop-common/target/hadoop-common-2.4.1/lib/native/libhadoop.so./hadoop-common-project/hadoop-common/target/native/target/usr/local/lib/libhadoop.so.1.0.0./hadoop-common-project/hadoop-common/target/native/target/usr/local/lib/libhadoop.so

将库文件拷贝至系统目录 /usr/local/lib64/

cp ./hadoop-hdfs-project/hadoop-hdfs/target/hadoop-hdfs-2.4.1/lib/native/* /usr/local/lib64/cp ./hadoop-common-project/hadoop-common/target/hadoop-common-2.4.1/lib/native/* /usr/local/lib64/

进入/usr/local/lib64/,创建symbol link

# ln -s libhdfs.so.0.0.0 libhdfs.so# ln -s libhadoop.so.1.0.0 libhadoop.so

 

(11) 下载hbase, http://mirrors.cnnic.cn/apache/hbase/hbase-0.98.7/

解压后进入目录,确认native lib是否已经安装成功:

$ LD_LIBRARY_PATH=/usr/local/lib64 ./bin/hbase org.apache.hadoop.util.NativeLibraryChecker

log4j:WARN No appenders could be found for logger (org.apache.hadoop.util.NativeCodeLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Native library checking:
hadoop: true /usr/local/lib64/libhadoop.so.1.0.0
zlib: true /lib64/libz.so.1
snappy: true /usr/lib64/libsnappy.so.1
lz4: true revision:99
bzip2: false

由于打算仅使用snappy作为压缩算法,所以仅仅需要确认 hadoop, snappy 是true就行了。

本次编译native lib过程中,出现了各种错误,都是因为上面列出的某些软件未安装。

 

无须在每个机器上再次编译,只需将编译过程中产生的那些 .a, .so, 文件拷贝至每个机器即可。当然了,symbol link还是要重新创建的。

---------------------------- 分割线 上方是 hadoop native lib 的编译 ------------------------------------------

 3. 配置hbase分布式环境的总体流程

本次安装部署的服务器为5台,hbase-0为NameNode, hbase-r为ResourceManager,hbase-1、hbase-2、hbase-3为DataNode。

所有服务器的安装的目录为:

hadoop程序目录:/hbase/hadoop

hbase程序目录:/hbase/hbase

zookeeper的程序目录:/hbase/zookeeper

hdfs数据目录(data node用):/hbase/hdfs

hdfs元数据目录(name node用):/hbase/hdfsmeta

hdfs临时目录:/hbase/hdfstmp

yarn中间数据目录:/hbase/yarnlocal

yarn日志目录:/hbase/yarnlog

job history server的临时目录:/hbase/mr-history/tmp

job history server的done目录:/hbase/mr-history/done

各个deameon的pid目录(安全起见,目录权限700):/hbase/var/pid

zookeeper的数据目录:/hbase/zookeeperdata

zookeeper的log目录:/hbase/zookeeperlog

hbase临时目录:/hbase/hbasetmp

 

ZooKeeper的下载地址:http://mirrors.cnnic.cn/apache/zookeeper/stable/

本次下载的是 ZooKeeper3.4.6。

本次安装采用独立的ZooKeeper,不使用hbase自带的ZooKeeper。

 

 

(1) 配置host name, /etc/hosts,为了方便使用,我将hostname配置成了以下样子:

10.161.150.10 hbase-010.161.150.20 hbase-r10.161.150.11 hbase-110.161.150.12 hbase-210.161.150.13 hbase-3 

为了方便,还添加了1个 hbase-me,代表当前服务器的内网IP。

注意:上述配置hostname要放在靠前的位置,hbase的Master启动的时候,会根据ip查找hostname,相同ip的有多个hostname的时候,排在第1个的会被采用,然后被传播到RegionServer。

同时,将主机hostname修改成对应的名字。修改/etc/sysconfig/network,或者立即生效:

hostname hbase-0

 

(2) 配置免密码ssh

参考我的另一篇文章:http://www.cnblogs.com/got-my-way/p/4030923.html

(3) 解压hadoop包。

(4) 解压hbase包。

(5) 为了方便运行,将需要的环境变量配置在当前用户的.bashrc

vi ~/.bashrc

如下:

# For hadoop and hbase -------------------------------------export JAVA_HOME="/usr/java/jdk1.6.0_43"export PATH="$JAVA_HOME/bin:$PATH"export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib64:/usr/lib64:/usr/local/lib"export HADOOP_PREFIX="/hbase/hadoop"export HADOOP_YARN_HOME=$HADOOP_PREFIXexport HADOOP_CONF_DIR="/hbase/hadoop/etc/hadoop"export HBASE_HOME="/hbase/hbase"export HBASE_CONF_DIR="/hbase/hbase/conf"export ZOOKEEPER_HOME="/hbase/zookeeper"#log dir -----export HADOOP_LOG_DIR="/hbase/var/log"export YARN_LOG_DIR="/hbase/var/log"#pid dir -----export HADOOP_PID_DIR="/hbase/var/pid"export HADOOP_SECURE_DN_PID_DIR="/hbase/var/pid"export HADOOP_MAPRED_PID_DIR="/hbase/var/pid"#java options -----export HADOOP_JVM_GC_OPTS="-XX:PermSize=512m -XX:MaxPermSize=512m -XX:+DisableExplicitGC -XX:SurvivorRatio=1 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0 -XX:+CMSClassUnloadingEnabled -XX:LargePageSizeInBytes=128M -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=80 -XX:SoftRefLRUPolicyMSPerMB=0"export HADOOP_JVM_SECURITY_OPTS="-Djava.security.krb5.realm=OX.AC.UK -Djava.security.krb5.kdc=kdc0.ox.ac.uk:kdc1.ox.ac.uk"export HADOOP_NAMENODE_OPTS="${HADOOP_JVM_SECURITY_OPTS} ${HADOOP_JVM_GC_OPT}"export HADOOP_DATANODE_OPTS="${HADOOP_JVM_SECURITY_OPTS} ${HADOOP_JVM_GC_OPT}"export HADOOP_SECONDARYNAMENODE_OPTS="${HADOOP_JVM_SECURITY_OPTS} ${HADOOP_JVM_GC_OPT}"export YARN_RESOURCEMANAGER_OPTS="${HADOOP_JVM_SECURITY_OPTS} ${HADOOP_JVM_GC_OPT}"export YARN_NODEMANAGER_OPTS="${HADOOP_JVM_SECURITY_OPTS} ${HADOOP_JVM_GC_OPT}"export YARN_PROXYSERVER_OPTS="${HADOOP_JVM_SECURITY_OPTS} ${HADOOP_JVM_GC_OPT}"export HADOOP_JOB_HISTORYSERVER_OPTS="${HADOOP_JVM_SECURITY_OPTS} ${HADOOP_JVM_GC_OPT}"export HADOOP_HEAPSIZE="1536"export YARN_HEAPSIZE="1024"export HBASE_OPTS="-XX:MaxDirectMemorySize=128m ${HADOOP_JVM_SECURITY_OPTS} ${HADOOP_JVM_GC_OPT}"export HBASE_HEAPSIZE="2048"export HBASE_MANAGES_ZK=false#export YARN_RESOURCEMANAGER_HEAPSIZE=#export YARN_NODEMANAGER_HEAPSIZE=#export YARN_PROXYSERVER_HEAPSIZE=#export HADOOP_JOB_HISTORYSERVER_HEAPSIZE=

 

(6) 安装上述“编译native lib”步骤中所安装过的包

yum install snappyyum install snappy-develyum install glibc-headersyum install gcc-c++yum install cmakeyum install opensslyum install openssl-develyum install zlibyum install zlib-devel

至此基本的环境准备好了。接下来是具体的配置

 

4. 进入hadoop程序目录,配置hadoop (参考文档:http://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-common/ClusterSetup.html)

(1) 修改配置文件

  a. etc/hadoop/core-site.xml 

<configuration>    <property>           <name>fs.defaultFS</name>           <value>hdfs://hbase-0:9000/</value>      </property>    <property>        <name>io.file.buffer.size</name>        <value>131072</value>    </property>    <property>        <name>hadoop.tmp.dir</name>        <value>/hbase/hdfstmp</value>    </property>    <property>        <name>hadoop.logfile.size</name>        <value>104857600</value>    </property>    <property>        <name>hadoop.logfile.count</name>        <value>20</value>    </property>    <property>        <name>io.bytes.per.checksum</name>        <value>1024</value>    </property>    <property>        <name>io.skip.checksum.errors</name>        <value>false</value>    </property>    <property>        <name>io.serializations</name>        <value>org.apache.hadoop.io.serializer.WritableSerialization</value>    </property>    <property>        <name>io.seqfile.compress.blocksize</name>        <value>1048576</value>    </property>    <property>        <name>io.compression.codecs</name>        <value>org.apache.hadoop.io.compress.DefaultCodec,org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.SnappyCodec</value>    </property></configuration>

 

  b. etc/hadoop/hdfs-site.xml

<configuration>    <property>        <name>dfs.replication</name>        <value>3</value>    </property>    <property>        <name>dfs.blocksize</name>        <value>2147483648</value>    </property>    <property>        <name>dfs.namenode.handler.count</name>        <value>128</value>    </property>        <!-- config for NameNode below -->    <property>        <name>dfs.namenode.name.dir</name>        <value>/hbase/hdfsmeta</value>    </property>    <!-- config for DataNode below -->    <property>        <name>dfs.datanode.data.dir</name>        <value>/hbase/hdfs</value>    </property></configuration>

 

  c. etc/hadoop/yarn-site.xml

<configuration><!-- Site specific YARN configuration properties -->    <!-- config for Node Manager below -->    <property>        <name>yarn.nodemanager.aux-services</name>        <value>mapreduce_shuffle</value>    </property>    <property>        <name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>        <value>org.apache.hadoop.mapred.ShuffleHandler</value>    </property>    <property>        <name>yarn.nodemanager.resource.memory-mb</name>        <value>1024</value>    </property>    <property>        <name>yarn.nodemanager.local-dirs</name>        <value>/hbase/yarnlocal</value>    </property>    <property>        <name>yarn.nodemanager.log-dirs</name>        <value>/hbase/yarnlog</value>    </property>    <property>        <name>yarn.nodemanager.log.retain-seconds</name>        <value>10800</value>    </property>        <!-- config for Resource Manager below -->    <property>        <name>yarn.resourcemanager.address</name>        <value>hbase-me:18040</value>    </property>    <property>        <name>yarn.resourcemanager.scheduler.address</name>        <value>hbase-me:18030</value>    </property>    <property>        <name>yarn.resourcemanager.resource-tracker.address</name>        <value>hbase-me:18025</value>    </property>    <property>        <name>yarn.resourcemanager.admin.address</name>        <value>hbase-me:18141</value>    </property>    <property>        <name>yarn.resourcemanager.webapp.address</name>        <value>hbase-me:18088</value>    </property>    <property>        <name>yarn.resourcemanager.scheduler.class</name>        <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler</value>    </property>    <property>        <name>yarn.scheduler.minimum-allocation-mb</name>        <value>256</value>    </property>    <property>        <name>yarn.scheduler.maximum-allocation-mb</name>        <value>1024</value>    </property>        </configuration>

 

  d. etc/hadoop/mapred-site.xml

<configuration>    <!-- config for MapReduce Applications below -->    <property>        <name>mapreduce.framework.name</name>        <value>yarn</value>    </property>    <property>      <name>mapred.output.compress</name>      <value>true</value>      <description>Should the job outputs be compressed?</description>    </property>    <property>        <name>mapred.output.compression.type</name>        <value>RECORD</value>    </property>    <property>        <name>mapred.output.compression.codec</name>        <value>org.apache.hadoop.io.compress.SnappyCodec</value>    </property>    <property>        <name>mapred.compress.map.output</name>        <value>true</value>    </property>    <property>        <name>mapred.map.output.compression.codec</name>        <value>org.apache.hadoop.io.compress.SnappyCodec</value>    </property>    <property>        <name>mapreduce.map.memory.mb</name>        <value>1536</value>    </property>    <property>        <name>mapreduce.map.java.opts</name>        <value>-Xmx1024M</value>    </property>    <property>        <name>mapreduce.reduce.memory.mb</name>        <value>2048</value>    </property>    <property>        <name>mapreduce.reduce.java.opts</name>        <value>-Xmx2048M</value>    </property>    <property>        <name>mapreduce.task.io.sort.mb</name>        <value>512</value>    </property>    <property>        <name>mapreduce.task.io.sort.factor</name>        <value>100</value>    </property>    <property>        <name>mapreduce.reduce.shuffle.parallelcopies</name>        <value>50</value>    </property>        <!-- config for MapReduce JobHistory Server below -->    <property>        <name>mapreduce.jobhistory.intermediate-done-dir</name>        <value>/hbase/mr-history/tmp</value>    </property>    <property>        <name>mapreduce.jobhistory.done-dir</name>        <value>/hbase/mr-history/done</value>    </property>

 

  f. etc/hadoop/slaves

  将作为DataNode的host name添加进去:

hbase-1hbase-2hbase-3

 

  

  g. 上述配置好的hadoop目录复制到各台服务器。

5. 进入zookeeper目录,修改配置文件

  (1) cp conf/zoo_sample.cfg conf/zoo.cfg,修改conf/zoo.cfg以下配置:

dataDir=/hbase/zookeeperdatadataLogDir=/hbase/zookeeperlog

server.1=hbase-0:2888:3888
server.2=hbase-r:2888:3888
server.3=hbase-1:2888:3888
server.4=hbase-2:2888:3888
server.5=hbase-3:2888:3888

  (2) 在各台机器上 /hbase/zookeeperdata/下建立文件名myid,分别写入对应的1,2,3,4,5 ZooKeeper序号。

 

6. 进入hbase程序目录,配置hbase (参考文档:http://hbase.apache.org/book.html#quickstart-fully-distributed )

  本次配置的架构为:hbase-0为Master,hbase-1、hbase-2、 hbase-3为RegionServer,ZooKeeper配置在所有服务器(文档中推荐3,5,7)。

  (1) 修改配置文件

  a. conf/regionservers

hbase-1hbase-2hbase-3

  b. conf/backup-masters

  将hbase-r设置为master的backup

hbase-r

 

  c. conf/hbase-env.sh

export HBASE_OPTS="-XX:+UseConcMarkSweepGC ${HBASE_OPTS}"

 

  d. conf/hbase-site.xml

 

<configuration>    <property>        <name>hbase.tmp.dir</name>        <value>/hbase/hbasetmp</value>    </property>    <property>      <name>hbase.rootdir</name>      <value>hdfs://hbase-0:9000/hbase</value>    </property>    <property>        <name>hbase.cluster.distributed</name>        <value>true</value>    </property>    <property>        <name>hbase.master.info.port</name>        <value>16010</value>    </property>    <property>        <name>hbase.master.info.bindAddress</name>        <value>0.0.0.0</value>    </property>    <property>        <name>hbase.column.max.version</name>        <value>1</value>    </property>        <!-- for Zoo Keeper -->    <property>        <name>hbase.zookeeper.quorum</name>        <value>hbase-0,hbase-r,hbase-1,hbase-2,hbase-3</value>    </property>    <property>      <name>hbase.zookeeper.property.dataDir</name>      <value>/hbase/zookeeperdata</value>    </property>    <property>        <name>hbase.zookeeper.property.clientPort</name>        <value>2181</value>    </property>    <property>        <name>hbase.zookeeper.property.maxClientCnxns</name>        <value>300</value>    </property>    <property>        <name>zookeeper.session.timeout</name>        <value>90000</value>    </property>        <!-- setting for region server -->    <property>        <name>hbase.hregion.max.filesize</name>        <value>2147483648</value>    </property>    <property>        <name>hbase.regionserver.port</name>        <value>16020</value>    </property>    <property>        <name>hbase.regionserver.codecs</name>        <value>snappy,lz4</value>    </property>    <property>        <name>hbase.regionserver.info.port</name>        <value>16030</value>    </property>    <property>        <name>hbase.regionserver.info.bindAddress</name>        <value>hbase-me</value>    </property>    <property>            <name>hbase.regionserver.handler.count</name>            <value>128</value>        </property>    <property>        <name>hbase.ipc.server.callqueue.read.ratio</name>        <value>0.2</value>    </property>    <property>        <name>hbase.ipc.server.callqueue.scan.ratio</name>        <value>0.2</value>    </property>    <property>        <name>hbase.zookeeper.peerport</name>        <value>2888</value>    </property>    <property>        <name>hbase.zookeeper.leaderport</name>        <value>3888</value>    </property>    <property>        <name>hbase.offpeak.start.hour</name>        <value>0</value>    </property>    <property>        <name>hbase.offpeak.end.hour</name>        <value>7</value>    </property>    <property>        <name>hbase.rpc.timeout</name>        <value>60000</value>    </property>    <property>        <name>hbase.rpc.shortoperation.timeout</name>        <value>10000</value>    </property>    <property>        <name>hbase.ipc.client.tcpnodelay</name>        <value>true</value>    </property>    <property>        <name>hbase.rest.port</name>        <value>19080</value>    </property>        <!-- setting for client -->    <property>      <name>hbase.client.pause</name>      <value>100</value>    </property>    <property>      <name>hbase.ipc.client.tcpnodelay</name>      <value>false</value>    </property>     <property>      <name>ipc.ping.interval</name>      <value>10000</value>    </property>        <property>        <name>hbase.client.write.buffer</name>        <value>2097152</value>    </property>    <property>        <name>hbase.client.retries.number</name>        <value>35</value>    </property>    <property>        <name>hbase.client.max.total.tasks</name>        <value>100</value>    </property>    <property>        <name>hbase.client.max.perserver.tasks</name>        <value>20</value>    </property>    <property>        <name>hbase.client.max.perregion.tasks</name>        <value>1</value>    </property>    <property>        <name>hbase.client.scanner.caching</name>        <value>100</value>    </property>        </configuration>

 

7. 检查某些系统设置

 (1) 各台服务器关闭防火墙,或者将下列端口加入防火墙允许访问列表(/etc/sysconfig/iptables)

 以下列表中部分端口号没有在配置的xml出现过,是hadoop或hbase的缺省值。

2181hbase.zookeeper.property.clientPort
2888hbase.zookeeper.peerport
3888hbase.zookeeper.leaderport
9000fs.defaultFS
10020mapreduce.jobhistory.address
16010hbase.master.info.port
16020hbase.regionserver.port
16030hbase.regionserver.info.port
18025yarn.resourcemanager.resource-tracker.address
18030yarn.resourcemanager.scheduler.address
18040yarn.resourcemanager.address
18088yarn.resourcemanager.webapp.address
18141yarn.resourcemanager.admin.address
19080hbase.rest.port
19888mapreduce.jobhistory.webapp.address
50010hdfs client
60000hbase.master.port
60020hbase.regionserver.port
33651catalog.CatalogTracker
40641zookeeper.ClientCnxn

 


   (2) 检查ulimit, /etc/security/limits.conf

   此处暂时设置为(假设启动hadoop的用户为admin)

admin        -       nofile  65536admin        -       nproc   65536

   

 8. 启动hadoop

  (1) 初次启动之前,在hbase-0上格式化NameNode

$HADOOP_PREFIX/bin/hdfs namenode -format hbase-0

 

  在hbase-r上格式化NameNode

$HADOOP_PREFIX/bin/hdfs namenode -format hbase-r

 

  (2) 在hbase-0启动NameNode

$HADOOP_PREFIX/sbin/hadoop-daemon.sh --config $HADOOP_CONF_DIR --script hdfs start namenode

  (3) 分别在hbase-1,hbase-2, hbase-3 上启动DataNode

$HADOOP_PREFIX/sbin/hadoop-daemon.sh --config $HADOOP_CONF_DIR --script hdfs start datanode

  (4) 在hbase-r上启动ResourceManager

$HADOOP_YARN_HOME/sbin/yarn-daemon.sh --config $HADOOP_CONF_DIR start resourcemanager

  (5) 在hbase-1, hbase-2, hbase-3上启动NodeManager

$HADOOP_YARN_HOME/sbin/yarn-daemon.sh --config $HADOOP_CONF_DIR start nodemanager

  (6) 在hbase-r上启动Yarn的WebAppProxy Server

$HADOOP_YARN_HOME/sbin/yarn-daemon.sh start proxyserver --config $HADOOP_CONF_DIR

  (7) 在hbase-r上启动MapReduce JobHistory Server

$HADOOP_PREFIX/sbin/mr-jobhistory-daemon.sh start historyserver --config $HADOOP_CONF_DIR

 

9. 停止hadoop

  (1) hbase-0上停止NameNode

$HADOOP_PREFIX/sbin/hadoop-daemon.sh --config $HADOOP_CONF_DIR --script hdfs stop namenode

  (2) 分别在hbase-1,hbase-2, hbase-3 上停止DataNode

$HADOOP_PREFIX/sbin/hadoop-daemon.sh --config $HADOOP_CONF_DIR --script hdfs stop datanode

  (3) 在hbase-r上停止ResourceManager

$HADOOP_YARN_HOME/sbin/yarn-daemon.sh --config $HADOOP_CONF_DIR stop resourcemanager

  (4) 在hbase-1, hbase-2, hbase-3上停止NodeManager

$HADOOP_YARN_HOME/sbin/yarn-daemon.sh --config $HADOOP_CONF_DIR stop nodemanager

  (5) 在hbase-r上停止Yarn的WebAppProxy Server

$HADOOP_YARN_HOME/sbin/yarn-daemon.sh stop proxyserver --config $HADOOP_CONF_DIR

  (6) 在hbase-r上停止MapReduce JobHistory Server

$HADOOP_PREFIX/sbin/mr-jobhistory-daemon.sh stop historyserver --config $HADOOP_CONF_DIR

 

10. 启动zookeeper

  (1) 在所有机器上启动zookeeper

${ZOOKEEPER_HOME}/bin/zkServer.sh start

 

  (2) 在各台机器上确认启动状态

${ZOOKEEPER_HOME}/bin/zkServer.sh statusJMX enabled by defaultUsing config: /hbase/zookeeper/bin/../conf/zoo.cfgMode: leader

  其中Mode:leader应该只有1个,其他的都是Mode: follower

 

11. 启动hbase

  (1) 在hbase-0上启动hbase。按照文档中的描述,会按照ZooKeeper、Master、RegionServers、Backup masters的顺序启动。

$HBASE_HOME/bin/start-hbase.sh

  (2) 在各个结点上执行 jps指令,确认启动状况

  hbase-0:

$ jps14761 NameNode15644 Bootstrap10145 QuorumPeerMain21312 HMaster24155 Jps16377 Bootstrap

 

  hbase-r:

$ jps14229 ResourceManager19301 Bootstrap1119 Bootstrap15188 JobHistoryServer20920 Jps10831 QuorumPeerMain

 

  hbase-1:

 

$ jps9015 HRegionServer4402 DataNode10906 Bootstrap1145 QuorumPeerMain15282 Bootstrap10763 Jps
10876 NodeManager

 

  hbase-2:

$ jps17856 HRegionServer13396 DataNode17399 QuorumPeerMain18258 Jps
28873 NodeManager

 hbase-3:

 

$ jps5660 Jps3825 HRegionServer24410 Bootstrap5509 NodeManager31687 DataNode28529 QuorumPeerMain9915 Bootstrap

 

 

可以看到,

hadoop:1个NameNode, 3个DataNode,3个NodeManager,1个ResourceManager, 1个JobHistoryServer

hbase:1个HMaster,3个RegionServer,

5个ZooKeeper,

全部启动完成了。

 

  (2) 停止hbase 

$HBASE_PREFIX/bin/stop-hbase.sh

 12. 一些基本的测试

  (1) Snappy压缩测试

$ $HBASE_HOME/bin/hbase shell> create test1, { NAME => cf1, COMPRESSION => SNAPPY }> put test1, row1, cf1:a, value1> scan test1ROW                      COLUMN+CELL                                                         row1                    column=cf1:a, timestamp=1414480111169, value=http://www.mamicode.com/value1                 1 row(s) in 0.0370 seconds

  (2) 去hadoop看刚才创建的记录

$HADOOP_PREFIX/bin/hdfs dfs -ls /hbase/data/default/test1/
drwxr-xr-x   - admin supergroup          0 2014-10-28 15:07 /hbase/data/default/test1/.tabledesc
drwxr-xr-x   - admin supergroup          0 2014-10-28 15:07 /hbase/data/default/test1/.tmp
drwxr-xr-x   - admin supergroup          0 2014-10-28 15:07 /hbase/data/default/test1/003d38c6f213f8c589eea5065785ce57

 

  (3) 浏览器访问hbase-0:50070/,通过管理界面可以看到Live Nodes: 3

  (4) 浏览器访问hbase-0:16010/,通过管理界面可以看到Region Servers 一共3台: hbase-1, hbase-2, hbase-3全部运行中。

 

 

-------------------------------------- 结束 -----------------------------------------

此次部署过程遇到了各种各样的错误,通过查看启动日志,搜索其他人的博文,最终成功安装上去了。希望本文能为后来者省点时间,也为下次自己再次部署的时候作为参考。

 

hbase centOS生产环境配置笔记 (1 NameNode, 1 ResourceManager, 3 DataNode)