当前位置:   article > 正文

搭建HBase伪分布式集群_伪分布式集群搭建hbase

伪分布式集群搭建hbase

1. Install zookeeper
1) download zookeeper from https://zookeeper.apache.org/releases.html#download
2) extract binary

$ tar xvf apache-zookeeper-3.8.1-bin.tar.gz -C ~/bigdata/

3) configurate zoo.cfg

  1. $ cd ~/bigdata/zookeeper-3.8.1/conf
  2. $ cp zoo_sample.cfg zoo.cfg
  3. $ vi zoo.cfg # edit zoo.cfg
  4. $ diff -u zoo_sample.cfg zoo.cfg
  5. --- zoo_sample.cfg 2023-01-26 00:31:05.000000000 +0800
  6. +++ zoo.cfg 2023-06-16 18:19:01.510722864 +0800
  7. @@ -9,7 +9,7 @@
  8. # the directory where the snapshot is stored.
  9. # do not use /tmp for storage, /tmp here is just
  10. # example sakes.
  11. -dataDir=/tmp/zookeeper
  12. +dataDir=/home/sunxo/bigdata/zookeeper-3.8.1/tmp
  13. # the port at which the clients will connect
  14. clientPort=2181
  15. # the maximum number of client connections.
  16. @@ -25,7 +25,7 @@
  17. #autopurge.snapRetainCount=3
  18. # Purge task interval in hours
  19. # Set to "0" to disable auto purge feature
  20. -#autopurge.purgeInterval=1
  21. +autopurge.purgeInterval=1

4) start zookeeper

  1. $ cd ~/bigdata/zookeeper-3.8.1
  2. $ mkdir tmp # as config in zoo.cfg
  3. $ bin/zkServer.sh start
  4. ZooKeeper JMX enabled by default
  5. Using config: /root/bigdata/zookeeper-3.8.1/bin/../conf/zoo.cfg
  6. Starting zookeeper ... STARTED

5) try zookeeper

  1. $ netstat -lnpt | grep -i TCP | grep `jps | grep -w QuorumPeerMain | awk '{print $1}'`
  2. tcp6 0 0 :::2181 :::* LISTEN 240750/java
  3. tcp6 0 0 :::42277 :::* LISTEN 240750/java
  4. tcp6 0 0 :::8080 :::* LISTEN 240750/java
  5. $ bin/zkCli.sh -server 127.0.0.1:2181
  6. [zk: 127.0.0.1:2181(CONNECTED) 0] ls /
  7. [zookeeper]

Note: use following command to stop zookeeper

  1. $ cd ~/bigdata/zookeeper-3.8.1
  2. $ bin/zkServer.sh stop

2. Install Hadoop
1) download Hadoop from https://hadoop.apache.org/releases.html
2) extract binary

$ tar xvf hadoop-2.10.2.tar.gz -C ~/bigdata/

3) configurate

  1. $ cd $HADOOP_HOME/etc/hadoop
  2. $ vi hadoop-env.sh core-site.xml hdfs-site.xml mapred-site.xml yarn-site.xml
  3. $ diff -u hadoop-env.sh.orig hadoop-env.sh
  4. ...
  5. # The java implementation to use.
  6. -export JAVA_HOME=${JAVA_HOME}
  7. +export JAVA_HOME=/opt/jdk
  8. $ cat core-site.xml
  9. ...
  10. <configuration>
  11. <property>
  12. <name>fs.defaultFS</name>
  13. <value>hdfs://ubuntu:8020</value>
  14. </property>
  15. <property>
  16. <name>hadoop.tmp.dir</name>
  17. <value>/home/sunxo/bigdata/hadoop-2.10.2/data/tmp</value>
  18. </property>
  19. </configuration>
  20. $ cat hdfs-site.xml
  21. ...
  22. <configuration>
  23. <property>
  24. <name>dfs.replication</name>
  25. <value>1</value>
  26. </property>
  27. <property>
  28. <name>dfs.namenode.http-address</name>
  29. <value>ubuntu:50070</value>
  30. </property>
  31. <property>
  32. <name>dfs.datanode.address</name>
  33. <value>ubuntu:50010</value>
  34. </property>
  35. <property>
  36. <name>dfs.datanode.http.address</name>
  37. <value>ubuntu:50075</value>
  38. </property>
  39. <property>
  40. <name>dfs.datanode.ipc.address</name>
  41. <value>ubuntu:50020</value>
  42. </property>
  43. </configuration>
  44. $ cat mapred-site.xml
  45. ...
  46. <configuration>
  47. <property>
  48. <name>mapreduce.framework.name</name>
  49. <value>yarn</value>
  50. </property>
  51. <property>
  52. <name>mapreduce.jobhistory.address</name>
  53. <value>ubuntu:10020</value>
  54. </property>
  55. <property>
  56. <name>mapreduce.jobhistory.webapp.address</name>
  57. <value>ubuntu:19888</value>
  58. </property>
  59. </configuration>
  60. $ cat yarn-site.xml
  61. ...
  62. <configuration>
  63. <property>
  64. <name>yarn.resourcemanager.hostname</name>
  65. <value>ubuntu</value>
  66. </property>
  67. <property>
  68. <name>yarn.nodemanager.aux-services</name>
  69. <value>mapreduce_shuffle</value>
  70. </property>
  71. <property>
  72. <name>yarn.log-aggregation-enable</name>
  73. <value>true</value>
  74. </property>
  75. <property>
  76. <name>yarn.log-aggregation.retain-seconds</name>
  77. <value>604800</value>
  78. </property>
  79. <property>
  80. <name>yarn.resourcemanager.scheduler.class</name>
  81. <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler</value>
  82. </property>
  83. </configuration>

4) format the filesystem

  1. $ cd $HADOOP_HOME
  2. $ mkdir data/tmp # as config in core-site.xml
  3. $ bin/hdfs namenode -format
  4. ...
  5. 23/06/16 15:39:53 INFO common.Storage: Storage directory /home/sunxo/bigdata/hadoop-2.10.2/data/tmp/dfs/name has been successfully formatted

5) start hadoop / yarn

  1. $ cd $HADOOP_HOME
  2. $ sbin/start-dfs.sh
  3. $ sbin/start-yarn.sh
  4. $ sbin/mr-jobhistory-daemon.sh start historyserver

6) try hadoop

  1. #!/bin/sh
  2. mr() {
  3. cd $HADOOP_HOME
  4. mkdir -p input
  5. echo test apache hadoop hadoop sqoop hue mapreduce sqoop oozie http > input/in.txt
  6. hdfs dfs -rm -f -r input
  7. hdfs dfs -mkdir input
  8. hdfs dfs -put input/in.txt input
  9. hdfs dfs -rm -f -r output
  10. hadoop jar $jarfile wordcount input output
  11. hdfs dfs -cat output/*
  12. }
  13. jarfile=$HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.10.2.jar
  14. mr
  1. $ cd $HADOOP_HOME
  2. $ bin/hdfs dfs -mkdir /user
  3. $ bin/hdfs dfs -mkdir /user/sunxo # build user home on hdfs
  4. $ ./mr.sh
  5. ...
  6. apache 1
  7. hadoop 2
  8. http 1
  9. hue 1
  10. mapreduce 1
  11. oozie 1
  12. sqoop 2
  13. test 1

Note: use followings commands to stop hadoop / yarn

  1. $ cd $HADOOP_HOME
  2. $ sbin/mr-jobhistory-daemon.sh stop historyserver
  3. $ sbin/stop-yarn.sh
  4. $ sbin/stop-dfs.sh

3. Install hbase
1) download HBase from https://hbase.apache.org/downloads.html
2) extract binary

$ tar xvf hbase-2.4.16-bin.tar.gz -C ~/bigdata/

3) configurate

  1. $ cd $HBASE_HOME/conf
  2. $ vi hbase-env.sh hbase-site.xml
  3. $ diff -u hbase-env.sh.orig hbase-env.sh
  4. $ diff -u hbase-site.xml.orig hbase-site.xml
  5. ...
  6. # The java implementation to use. Java 1.8+ required.
  7. -# export JAVA_HOME=/usr/java/jdk1.8.0/
  8. +export JAVA_HOME=/opt/jdk
  9. ...
  10. # Tell HBase whether it should manage it's own instance of ZooKeeper or not.
  11. -# export HBASE_MANAGES_ZK=true
  12. +export HBASE_MANAGES_ZK=false
  13. $ cat hbase-site.xml
  14. ...
  15. <configuration>
  16. <property>
  17. <name>hbase.cluster.distributed</name>
  18. <value>true</value>
  19. </property>
  20. <property>
  21. <name>hbase.rootdir</name>
  22. <value>hdfs://ubuntu:8020/hbase</value>
  23. </property>
  24. <property>
  25. <name>hbase.zookeeper.quorum</name>
  26. <value>localhost</value>
  27. </property>
  28. <property>
  29. <name>hbase.zookeeper.property.clientPort</name>
  30. <value>2181</value>
  31. </property>
  32. <property>
  33. <name>zookeeper.znode.parent</name>
  34. <value>/hbase</value>
  35. </property>
  36. <property>
  37. <name>phoenix.schema.isNamespaceMappingEnabled</name>
  38. <value>true</value>
  39. </property>
  40. <property>
  41. <name>phoenix.schema.mapSystemTablesToNamespace</name>
  42. <value>true</value>
  43. </property>
  44. </configuration>

4) start hbase

  1. $ cd $HBASE_HOME
  2. $ bin/start-hbase.sh

5) try hbase

  1. $ cd $HBASE_HOME
  2. $ bin/hbase shell
  3. > create_namespace 'manga'
  4. Took 0.1748 seconds
  5. > list_namespace
  6. NAMESPACE
  7. default
  8. hbase
  9. manga
  10. 3 row(s)
  11. Took 0.0209 seconds

Note: use followings commands to stop hbase

  1. $ cd $HBASE_HOME
  2. $ bin/stop-hbase.sh

reference:

https://zookeeper.apache.org/doc/r3.8.1/zookeeperStarted.html
https://hadoop.apache.org/docs/r2.10.2/hadoop-project-dist/hadoop-common/SingleCluster.html#Pseudo-Distributed_Operation
https://hbase.apache.org/book.html#quickstart

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/715118
推荐阅读
相关标签
  

闽ICP备14008679号