搭建企业级Hbase

搭建Hbase步骤

1.查看linux系统最大进程数和最大文件打开数

ulimit-a

查看open files(最大文件打开数)、max user processes(最大进程数),默认为1024。

2.设置linux系统最大进程数和最大文件打开数

su

vim /etc/security/limits.conf

例如对root和hadoop用户进行配置:

root    soft  nproc  50000

root    hard  nproc  50000

root    soft  nofile  25535

root    hard  nofile  25535

hadoop    soft  nproc  50000

hadoop    hard  nproc  50000

hadoop    soft  nofile  25535

hadoop    hard  nofile  25535

3.调整linux内核参数

vim /etc/sysctl.conf

添加下述配置:

net.ipv4.ip_forward= 0

net.ipv4.conf.default.rp_filter= 1

net.ipv4.conf.default.accept_source_route= 0

kernel.core_users_pid= 1

net.ipv4.tcp_syncookies= 1

net.bridge.bridge-nf-call-ip6tables= 0

net.bridge.bridge-nf-call-iptables= 0

net.bridge.bridge-nf-call-arptables= 0

kernel.mggmnb= 65536

kernel.mggmax= 65536

kernel.shmmax= 68719476736

kernel.shmall= 268435456

net.ipv4.tcp_max_syn_backlog= 65000

net.core.netdev_max_backlog= 32768

net.core.somaxconn= 32768

fs.file-max= 65000

net.core.wmem_default= 8388608

net.core.rmem_default= 8388608

net.core.rmem_max= 16777216

net.core.wmem_max= 16777216

net.ipv4.tcp_timestamps= 1

net.ipv4.tcp_synack_retries= 2

net.ipv4.tcp_syn_retries= 2

net.ipv4.tcp_mem= 94500000 915000000 927000000

net.ipv4.tcp_max_orphans= 3276800

net.ipv4.tcp_tw_reuse= 1

net.ipv4.tcp_tw_recycle= 1

net.ipv4.tcp_keepalive_time= 1200

net.ipv4.tcp_syncookies= 1

net.ipv4.tcp_fin_timeout= 10

net.ipv4.tcp_keepalive_intvl= 15

net.ipv4.tcp_keepalive_probes= 3

net.ipv4.ip_local_port_range= 1024 65535

net.ipv4.conf.eml.send_redirects= 0

net.ipv4.conf.lo.send_redirects= 0

net.ipv4.conf.default.send_redirects= 0

net.ipv4.conf.all.send_redirects= 0

net.ipv4.icmp_echo_ignore_broadcasts= 1

net.ipv4.conf.eml.accept_source_route= 0

net.ipv4.conf.lo.accept_source_route= 0

net.ipv4.conf.default.accept_source_route= 0

net.ipv4.conf.all.accept_source_route= 0

net.ipv4.icmp_ignore_bogus_error_responses= 1

kernel.core_pattern= /tmp/core

vm.overcommit_memory= 1

执行生效:
sysctl -p

4.配置环境

(1)修改hbase-env.sh

cd  ./hbase-1.2.0-cdh5.7.1/conf/

vim hbase-env.sh

具体设置如下:

# 配置Java home
export JAVA_HOME=/home/hadoop/app/jdk1.7.0_79

# 设置HBase内存堆的大小
export HBASE_HEAPSIZE=1024

# 设置HMaster最大可用内存
export HBASE_MASTER_OPTS="-Xmx512m"

# 设置HRegionServer最大可用内存
export HBASE_REGIONSERVER_OPTS="-Xmx512m"

# 设置HBase的日志目录
export HBASE_LOG_DIR=${HBASE_HOME}/logs

# 设置HBase的pid目录
export HBASE_PID_DIR=${HBASE_HOME}/pids

# 使用独立的ZooKeeper集群
export HBASE_MANAGES_ZK=false

(2)配置hbase-site.xml

vim hbase-site.xml

配置如下:

  <!-- 关闭分布式日志拆分 -->
  <property>
    <name>hbase.master.distributed.log.splitting</name>
    <value>false</value>
  </property>

  <!-- hbase部署至hdfs的根路径 -->
  <property>
    <name>hbase.rootdir</name>
    <value>hdfs://educluster/hbase</value>
  </property>

    <!-- 开启分布式模式 -->
  <property>
    <name>hbase.cluster.distributed</name>
    <value>true</value>
  </property>

  <!-- 设置HMaster的端口 -->
  <property>
    <name>hbase.master.port</name>
    <value>60000</value>
  </property>

    <!-- 指定ZooKeeper集群位置 -->
  <property>
    <name>hbase.zookeeper.quorum</name>
    <value>namenode1,namenode2,datanode</value>
  </property>

  <!--指定Zookeepe快照存储目录,需要与ZooKeeper集群上配置相一致 -->
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/opt/hadoopdata/zookeeperdata</value>
  </property>

  <!-- hbase客户端rpc扫描一次获取的行数 -->
  <property>
    <name>hbase.client.scanner.caching</name>
    <value>2000</value>
  </property>

 <!-- HRegion分裂前最大的文件大小(10G) -->
  <property>
    <name>hbase.hregion.max.filesize</name>
    <value>10737418240</value>
  </property>
  
  <!-- 设置HMaster的http端口 -->
  <property>
    <name>hbase.master.info.port</name>
    <value>16010</value>
  </property>
  
  <!-- 指定缓存文件存储的路径 -->
  <property>
    <name>hbase.tmp.dir</name>
    <value>/home/hadoop/app/cdh/hbase-1.2.0-cdh5.7.1/tmp</value>
  </property>
 
  
  <!-- 指定ZooKeeper集群端口 -->
  <property>
    <name>hbase.zookeeper.property.clientPort</name>
    <value>2181</value>
  </property>
 
 
  <!-- HRegionServer中最大的region数量 -->
  <property>
    <name>hbase.regionserver.reginoSplitLimit</name>
    <value>2000</value>
  </property>
  
  <!-- StoreFile的个数超过这个数就开始合并 -->
  <property>
    <name>hbase.hstore.compactionThreshold</name>
    <value>6</value>
  </property>
  
  <!-- 当某一个region的storefile个数达到该值则block写入,等待compact -->
  <property>
    <name>hbase.hstore.blockingStoreFiles</name>
    <value>14</value>
  </property>
  
  <!-- 超过memstore大小的倍数达到该值则block所有写入请求,自我保护 -->
  <property>
    <name>hbase.hregion.memstore.block.multiplier</name>
    <value>20</value>
  </property>
  
  <!-- service工作的sleep间隔 -->
  <property>
    <name>hbase.server.thread.wakefrequency</name>
    <value>500</value>
  </property>
  
  <!-- ZooKeeper客户端同时访问的并发连接数 -->
  <property>
    <name>hbase.zookeeper.property.maxClientCnxns</name>
    <value>2000</value>
  </property>
  
  <!-- 根据业务情况进行配置 -->
  <property>
    <name>hbase.regionserver.global.memstore.lowerLimit</name>
    <value>0.3</value>
  </property>
  <property>
    <name>hbase.regionserver.global.memstore.upperLimit</name>
    <value>0.39</value>
  </property>
  <property>
    <name>hbase.block.cache.size</name>
    <value>0.4</value>
  </property>
  
  <!-- RegionServer的请求处理IO线程数 -->
  <property>
    <name>hbase.reginoserver.handler.count</name>
    <value>300</value>
  </property>
  
  <!-- 客户端最大重试次数 -->
  <property>
    <name>hbase.client.retries.number</name>
    <value>5</value>
  </property>
  
  <!-- 客户端重试的休眠时间 -->
  <property>
    <name>hbase.client.pause</name>
    <value>100</value>
  </property>
</configuration>

待续…

    原文作者:ahzhaojj
    原文地址: https://www.jianshu.com/p/ea70eb3b259d
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞