Linux CentOS单机安装Hadoop与HBase

版本兼容表

首选根据兼容表选择需要部署的版本,本文以HBase2.5.6、jdk1.8  Hadoop3.3.6为例

  • HBase与JDK兼容表

  • HBase与Hadoop兼容表

安装Java

JDK8基本兼容最新版本的HBase以及配套的Hadoop,这里安装jdk 1.8

  • yum search java|grep jdk

  • 选择版本安装 yum install -y java-1.8.0-openjdk*
  • 验证安装:java -version
  • 查找java安装地址: find / -name ‘java’

  • 这里以/www/server/java/jdk1.8.0_371/为我们要使用的java版本
  • vi ~/.bash_profile 添加java环境变量
    export JAVA_HOME=/www/server/java/jdk1.8.0_371
    PATH=PATH:JAVA_HOME/bin:$HOME/bin
  • source ~/.bash_profile 生效java环境变量

安装Hadoop

下载

  • 下载Hadoop最新版本,注意跟CPU架构匹配
  • 下载地址:https://hadoop.apache.org/releases.html
  • 下载到/data目录
  • 执行tar命令解压:tar -xzvf hadoop-3.3.6.tar.gz

配置

  • 新建hadoop用户以及设置密码用于执行hadoop启动
useradd hadoop
passwd hadoop
  • 配置hadoop用户免密登录
ssh-keygen -t rsa
ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub hadoop@localhost
  • 编辑hadoop-env.sh:
    vi /data/hadoop-3.3.6/etc/hadoop/hadoop-env.sh
    # set to the root of your Java installation
    export JAVA_HOME=/www/server/java/jdk1.8.0_371
    export HDFS_NAMENODE_USER=hadoop
    export HDFS_DATANODE_USER=hadoop
    export HDFS_SECONDARYNAMENODE_USER=hadoop
  • 编辑core-site.xml:
    vi /data/hadoop-3.3.6/etc/hadoop/core-site.xml
    <property>
        <name>fs.defaultFS</name>
        <value>hdfs://127.0.0.1:8020</value>
    </property>
    <property>
        <name>hadoop.tmp.dir</name>
        <value>/data/hadoop-3.3.6/tmp</value>
    </property>
</configuration> 
  • 编辑 hdfs-site.xml:
    vi /data/hadoop-3.3.6/etc/hadoop/mapred-site.xml
    <configuration>
         <property>
          <name>dfs.datanode.data.dir</name>
          <value>/data/hadoop-3.3.6/data</value>
         </property>
    </configuration>
  • 编辑 mapred-site.xml:
    vi /data/hadoop-3.3.6/etc/hadoop/mapred-site.xml
    <configuration>
        <property>
            <name>mapreduce.framework.name</name>
            <value>yarn</value>
        </property>
    </configuration>
  • 编辑yarn-site.xml:
    vi /data/hadoop-3.3.6/etc/hadoop/yarn-site.xml
    <configuration>
        <property>
            <name>yarn.nodemanager.aux-services</name>
            <value>mapreduce_shuffle</value>
        </property>
    </configuration>

启动

  • 切换为hadoop用户执行:
    su hadoop
  • 格式化系统:
    /data/hadoop-3.3.6/bin/hdfs namenode -format
  • 启动NameNode 与DataNode
    /data/hadoop-3.3.6/sbin/start-dfs.sh
    启动成功日志如图所示:

安装HBase

  • 下载hbase到/data目录: https://dlcdn.apache.org/hbase/2.5.6/
  • 执行tar命令解压:
    tar -xzvf hbase-2.5.6-bin.tar.gz
  • 修改hbase-site.xml:
    vi /data/hbase-2.5.6/conf/hbase-site.xml
  <property>
    <name>hbase.rootdir</name>
    <value>hdfs://127.0.0.1:8020/hbasermysj</value>
  </property>
  <property>
    <name>hbase.cluster.distributed</name>
    <value>true</value>
  </property>
  • 启动HBase进程
su hadoop
/data/hbase-2.5.6/bin/hbase-daemon.sh start zookeeper
/data/hbase-2.5.6/bin/hbase-daemon.sh start master
/data/hbase-2.5.6/bin/hbase-daemon.sh start regionserver

  • 执行hbase shell测试
/data/hbase-2.5.6/bin/hbase shell

hbase:002:0> create 'test','cf'
Created table test
Took 0.6884 seconds                                         
=> Hbase::Table - test
hbase:006:0> put 'test','rowkey1','cf:a', 'value1'
Took 0.0091 seconds  

  • 执行dfs查看hbase文件
/data/hadoop-3.3.6/bin/hdfs dfs -ls /hbasermysj

 

%0A%23%23%23%20%E7%89%88%E6%9C%AC%E5%85%BC%E5%AE%B9%E8%A1%A8%0A%0A*%20HBase%E4%B8%8EJDK%E5%85%BC%E5%AE%B9%E8%A1%A8%0A!%5Bc6cc8adafc069919b03b529e80080465.png%5D(evernotecid%3A%2F%2F06C3B248-2EE2-4B19-BF30-9CD3AEFB7F97%2Fappyinxiangcom%2F19010725%2FENResource%2Fp145)%0A*%20HBase%E4%B8%8EHadoop%E5%85%BC%E5%AE%B9%E8%A1%A8%0A!%5B49d1c12c5d6b3c9ed53fe43670e2ff0b.png%5D(evernotecid%3A%2F%2F06C3B248-2EE2-4B19-BF30-9CD3AEFB7F97%2Fappyinxiangcom%2F19010725%2FENResource%2Fp146)%0A!%5B28d90f0e96f40b1b59930db214cb3333.png%5D(evernotecid%3A%2F%2F06C3B248-2EE2-4B19-BF30-9CD3AEFB7F97%2Fappyinxiangcom%2F19010725%2FENResource%2Fp147)%0A!%5B84e5e50a6a756387c01ef2f957048478.png%5D(evernotecid%3A%2F%2F06C3B248-2EE2-4B19-BF30-9CD3AEFB7F97%2Fappyinxiangcom%2F19010725%2FENResource%2Fp148)%0A%0A%0A%0A%23%23%23%20%E5%AE%89%E8%A3%85Java%0AJDK8%E5%9F%BA%E6%9C%AC%E5%85%BC%E5%AE%B9%E6%9C%80%E6%96%B0%E7%89%88%E6%9C%AC%E7%9A%84HBase%E4%BB%A5%E5%8F%8A%E9%85%8D%E5%A5%97%E7%9A%84Hadoop%EF%BC%8C%E8%BF%99%E9%87%8C%E5%AE%89%E8%A3%85jdk%201.8%0A*%20yum%20search%20java%7Cgrep%20jdk%0A!%5B8943d8ff506b8d0c937c46d28478c308.png%5D(evernotecid%3A%2F%2F06C3B248-2EE2-4B19-BF30-9CD3AEFB7F97%2Fappyinxiangcom%2F19010725%2FENResource%2Fp149)%0A*%20%20%E9%80%89%E6%8B%A9%E7%89%88%E6%9C%AC%E5%AE%89%E8%A3%85%20yum%20install%20-y%20java-1.8.0-openjdk*%0A*%20%E9%AA%8C%E8%AF%81%E5%AE%89%E8%A3%85%EF%BC%9Ajava%20-version%0A*%20%E6%9F%A5%E6%89%BEjava%E5%AE%89%E8%A3%85%E5%9C%B0%E5%9D%80%EF%BC%9A%20find%20%2F%20-name%20’java’%0A!%5Bf8f7606ce02d08249b83e312462380dc.png%5D(evernotecid%3A%2F%2F06C3B248-2EE2-4B19-BF30-9CD3AEFB7F97%2Fappyinxiangcom%2F19010725%2FENResource%2Fp150)%0A*%20%E8%BF%99%E9%87%8C%E4%BB%A5%2Fwww%2Fserver%2Fjava%2Fjdk1.8.0_371%2F%E4%B8%BA%E6%88%91%E4%BB%AC%E8%A6%81%E4%BD%BF%E7%94%A8%E7%9A%84java%E7%89%88%E6%9C%AC%0A*%20vi%20~%2F.bash_profile%20%E6%B7%BB%E5%8A%A0java%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%0Aexport%20JAVA_HOME%3D%2Fwww%2Fserver%2Fjava%2Fjdk1.8.0_371%0APATH%3D%24PATH%3A%24JAVA_HOME%2Fbin%3A%24HOME%2Fbin%0A*%20source%20~%2F.bash_profile%20%E7%94%9F%E6%95%88java%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%0A%0A%0A%0A%23%23%23%20%E5%AE%89%E8%A3%85Hadoop%0A%0A%23%23%23%23%20%E4%B8%8B%E8%BD%BD%0A*%20%E4%B8%8B%E8%BD%BDHadoop%E6%9C%80%E6%96%B0%E7%89%88%E6%9C%AC%EF%BC%8C%E6%B3%A8%E6%84%8F%E8%B7%9FCPU%E6%9E%B6%E6%9E%84%E5%8C%B9%E9%85%8D%0A*%20%E4%B8%8B%E8%BD%BD%E5%9C%B0%E5%9D%80%EF%BC%9Ahttps%3A%2F%2Fhadoop.apache.org%2Freleases.html%0A*%20!%5B7bfd76cb5221f2021a47609b5eae055c.png%5D(evernotecid%3A%2F%2F06C3B248-2EE2-4B19-BF30-9CD3AEFB7F97%2Fappyinxiangcom%2F19010725%2FENResource%2Fp144)%0A*%20%E4%B8%8B%E8%BD%BD%E5%88%B0%2Fdata%E7%9B%AE%E5%BD%95%0A*%20%E6%89%A7%E8%A1%8Ctar%E5%91%BD%E4%BB%A4%E8%A7%A3%E5%8E%8B%EF%BC%9Atar%20-xzvf%20hadoop-3.3.6.tar.gz%0A%0A%23%23%23%23%20%E9%85%8D%E7%BD%AE%0A*%20%E6%96%B0%E5%BB%BAhadoop%E7%94%A8%E6%88%B7%E4%BB%A5%E5%8F%8A%E8%AE%BE%E7%BD%AE%E5%AF%86%E7%A0%81%E7%94%A8%E4%BA%8E%E6%89%A7%E8%A1%8Chadoop%E5%90%AF%E5%8A%A8%0A%60%60%60%0Auseradd%20hadoop%0Apasswd%20hadoop%0A%60%60%60%0A*%20%E9%85%8D%E7%BD%AEhadoop%E7%94%A8%E6%88%B7%E5%85%8D%E5%AF%86%E7%99%BB%E5%BD%95%20%0A%60%60%60%0Assh-keygen%20-t%20rsa%0Assh-copy-id%20-i%20%2Fhome%2Fhadoop%2F.ssh%2Fid_rsa.pub%20hadoop%40localhost%0A%60%60%60%0A*%20%E7%BC%96%E8%BE%91hadoop-env.sh%3A%20%0A%60vi%20%2Fdata%2Fhadoop-3.3.6%2Fetc%2Fhadoop%2Fhadoop-env.sh%60%0A%0A%60%60%60%20%0A%20%20%20%20%23%20set%20to%20the%20root%20of%20your%20Java%20installation%0A%20%20%20%20export%20JAVA_HOME%3D%2Fwww%2Fserver%2Fjava%2Fjdk1.8.0_371%0A%20%20%20%20export%20HDFS_NAMENODE_USER%3Dhadoop%0A%20%20%20%20export%20HDFS_DATANODE_USER%3Dhadoop%0A%20%20%20%20export%20HDFS_SECONDARYNAMENODE_USER%3Dhadoop%0A%60%60%60%0A%0A*%20%E7%BC%96%E8%BE%91core-site.xml%3A%20%0A%60vi%20%2Fdata%2Fhadoop-3.3.6%2Fetc%2Fhadoop%2Fcore-site.xml%60%0A%60%60%60%3Cconfiguration%3E%0A%20%20%20%20%3Cproperty%3E%0A%20%20%20%20%20%20%20%20%3Cname%3Efs.defaultFS%3C%2Fname%3E%0A%20%20%20%20%20%20%20%20%3Cvalue%3Ehdfs%3A%2F%2F192.168.0.122%3A8020%3C%2Fvalue%3E%0A%20%20%20%20%3C%2Fproperty%3E%0A%20%20%20%20%3Cproperty%3E%0A%20%20%20%20%20%20%20%20%3Cname%3Ehadoop.tmp.dir%3C%2Fname%3E%0A%20%20%20%20%20%20%20%20%3Cvalue%3E%2Fdata%2Fhadoop-3.3.6%2Ftmp%3C%2Fvalue%3E%0A%20%20%20%20%3C%2Fproperty%3E%0A%3C%2Fconfiguration%3E%20%0A%60%60%60%0A%0A*%20%E7%BC%96%E8%BE%91%20hdfs-site.xml%3A%20%0A%60vi%20%2Fdata%2Fhadoop-3.3.6%2Fetc%2Fhadoop%2Fmapred-site.xml%60%0A%60%60%60%0A%20%20%20%20%3Cconfiguration%3E%0A%20%20%20%20%20%20%20%20%20%3Cproperty%3E%0A%20%20%20%20%20%20%20%20%20%20%3Cname%3Edfs.datanode.data.dir%3C%2Fname%3E%0A%20%20%20%20%20%20%20%20%20%20%3Cvalue%3E%2Fdata%2Fhadoop-3.3.6%2Fdata%3C%2Fvalue%3E%0A%20%20%20%20%20%20%20%20%20%3C%2Fproperty%3E%0A%20%20%20%20%3C%2Fconfiguration%3E%0A%60%60%60%0A%0A*%20%E7%BC%96%E8%BE%91%20mapred-site.xml%3A%20%0A%60vi%20%2Fdata%2Fhadoop-3.3.6%2Fetc%2Fhadoop%2Fmapred-site.xml%60%0A%60%60%60%0A%20%20%20%20%3Cconfiguration%3E%0A%20%20%20%20%20%20%20%20%3Cproperty%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Cname%3Emapreduce.framework.name%3C%2Fname%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Cvalue%3Eyarn%3C%2Fvalue%3E%0A%20%20%20%20%20%20%20%20%3C%2Fproperty%3E%0A%20%20%20%20%3C%2Fconfiguration%3E%0A%60%60%60%0A%0A*%20%E7%BC%96%E8%BE%91yarn-site.xml%3A%20%0A%60vi%20%2Fdata%2Fhadoop-3.3.6%2Fetc%2Fhadoop%2Fyarn-site.xml%60%0A%60%60%60%0A%20%20%20%20%3Cconfiguration%3E%0A%20%20%20%20%20%20%20%20%3Cproperty%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Cname%3Eyarn.nodemanager.aux-services%3C%2Fname%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Cvalue%3Emapreduce_shuffle%3C%2Fvalue%3E%0A%20%20%20%20%20%20%20%20%3C%2Fproperty%3E%0A%20%20%20%20%3C%2Fconfiguration%3E%0A%60%60%60%0A%0A%23%23%23%23%20%E5%90%AF%E5%8A%A8%0A*%20%E5%88%87%E6%8D%A2%E4%B8%BAhadoop%E7%94%A8%E6%88%B7%E6%89%A7%E8%A1%8C%EF%BC%9A%20%0A%60su%20hadoop%60%0A*%20%E6%A0%BC%E5%BC%8F%E5%8C%96%E7%B3%BB%E7%BB%9F%3A%0A%60%2Fdata%2Fhadoop-3.3.6%2Fbin%2Fhdfs%20namenode%20-format%60%0A*%20%E5%90%AF%E5%8A%A8NameNode%20%E4%B8%8EDataNode%0A%60%2Fdata%2Fhadoop-3.3.6%2Fsbin%2Fstart-dfs.sh%60%0A%E5%90%AF%E5%8A%A8%E6%88%90%E5%8A%9F%E6%97%A5%E5%BF%97%E5%A6%82%E5%9B%BE%E6%89%80%E7%A4%BA%EF%BC%9A%0A!%5Bffbf38690ea4274e40e11dcd704594a1.png%5D(evernotecid%3A%2F%2F06C3B248-2EE2-4B19-BF30-9CD3AEFB7F97%2Fappyinxiangcom%2F19010725%2FENResource%2Fp152)%0A%0A%0A%0A%23%23%23%20%E5%AE%89%E8%A3%85HBase%0A%0A*%20%E4%B8%8B%E8%BD%BDhbase%E5%88%B0%2Fdata%E7%9B%AE%E5%BD%95%EF%BC%9A%20https%3A%2F%2Fdlcdn.apache.org%2Fhbase%2F2.5.6%2F%0A!%5Bffb6316576cdce4533c8b8e4841e79b0.png%5D(evernotecid%3A%2F%2F06C3B248-2EE2-4B19-BF30-9CD3AEFB7F97%2Fappyinxiangcom%2F19010725%2FENResource%2Fp153)%0A*%20%E6%89%A7%E8%A1%8Ctar%E5%91%BD%E4%BB%A4%E8%A7%A3%E5%8E%8B%EF%BC%9A%0A%60tar%20-xzvf%20hbase-2.5.6-bin.tar.gz%60%0A*%20%E4%BF%AE%E6%94%B9hbase-site.xml%3A%20%0A%60vi%20%2Fdata%2Fhbase-2.5.6%2Fconf%2Fhbase-site.xml%60%20%0A%60%60%60%0A%20%20%3Cproperty%3E%0A%20%20%20%20%3Cname%3Ehbase.rootdir%3C%2Fname%3E%0A%20%20%20%20%3Cvalue%3Ehdfs%3A%2F%2F127.0.0.1%3A8020%2Fhbasermysj%3C%2Fvalue%3E%0A%20%20%3C%2Fproperty%3E%0A%20%20%3Cproperty%3E%0A%20%20%20%20%3Cname%3Ehbase.cluster.distributed%3C%2Fname%3E%0A%20%20%20%20%3Cvalue%3Etrue%3C%2Fvalue%3E%0A%20%20%3C%2Fproperty%3E%0A%60%60%60%0A*%20%E5%90%AF%E5%8A%A8HBase%E8%BF%9B%E7%A8%8B%0A%60%60%60%0Asu%20hadoop%0A%2Fdata%2Fhbase-2.5.6%2Fbin%2Fhbase-daemon.sh%20start%20zookeeper%0A%2Fdata%2Fhbase-2.5.6%2Fbin%2Fhbase-daemon.sh%20start%20master%0A%2Fdata%2Fhbase-2.5.6%2Fbin%2Fhbase-daemon.sh%20start%20regionserver%0A%0A%60%60%60%0A*%20%E6%89%A7%E8%A1%8Chbase%20shell%E6%B5%8B%E8%AF%95%0A%60%60%60%0A%2Fdata%2Fhbase-2.5.6%2Fbin%2Fhbase%20shell%0A%0Ahbase%3A002%3A0%3E%20create%20’test’%2C’cf’%0ACreated%20table%20test%0ATook%200.6884%20seconds%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%3D%3E%20Hbase%3A%3ATable%20-%20test%0Ahbase%3A006%3A0%3E%20put%20’test’%2C’rowkey1’%2C’cf%3Aa’%2C%20’value1’%0ATook%200.0091%20seconds%20%20%0A%0A%60%60%60%0A*%20%E6%89%A7%E8%A1%8Cdfs%E6%9F%A5%E7%9C%8Bhbase%E6%96%87%E4%BB%B6%0A%60%60%60%0A%2Fdata%2Fhadoop-3.3.6%2Fbin%2Fhdfs%20dfs%20-ls%20%2Fhbasermysj%0A%60%60%60%0A!%5B8b016b0947ba9bd51496b4e29a4c71a6.png%5D(evernotecid%3A%2F%2F06C3B248-2EE2-4B19-BF30-9CD3AEFB7F97%2Fappyinxiangcom%2F19010725%2FENResource%2Fp154)%0A%0A%0A*%20dfs%20%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6%0A%60%60%60%0A%5Broot%40ecs-7b38%20data%5D%23%20su%20hadoop%0A%5Bhadoop%40ecs-7b38%20data%5D%24%20%2Fdata%2Fhadoop-3.3.6%2Fbin%2Fhdfs%20dfs%20-mkdir%20%2Fhbasermysj%2Fjar%0A%5Bhadoop%40ecs-7b38%20data%5D%24%20%2Fdata%2Fhadoop-3.3.6%2Fbin%2Fhdfs%20dfs%20-put%20%2Fdata%2Freferencebook-1.0-SNAPSHOT.jar%20%2Fhbasermysj%2Fjar%0A%60%60%60%0A%0A%23%23%23%20HBase%20Shell%E5%8A%A0%E8%BD%BD%E5%8D%8F%E5%A4%84%E7%90%86%E5%99%A8%0A%60%60%60%0Adrop%20’s_behavior’%0Acreate%20’s_behavior’%2C%20%7BNAME%20%3D%3E%20’cf’%7D%0Adisable%20’s_behavior’%0Aalter%20’s_behavior’%2C%20METHOD%20%3D%3E%20’table_att’%2C%20%0A’Coprocessor’%3D%3E’hdfs%3A%2F%2F127.0.0.1%3A8020%2Fhbasermysj%2Fjar%2Freferencebook-1.0-SNAPSHOT.jar%7C%20com.mt.hbase.chpt08.coprocessor.KeyWordFilterRegionObserver%7C%2012345%7C%20arg1%3D1%2Carg2%3D2’%0Aenable%20’s_behavior’%0Aput%20’s_behavior’%2C’user1behavior1’%2C’cf%3Ao’%2C’%E9%98%BF%E9%87%8C%E5%B7%B4%E5%B7%B4this%20is%20order%201’%0Ascan%20’s_behavior’%0A%60%60%60%0A!%5Bc3e33f019fa9b022c47e58c9a403e82b.png%5D(evernotecid%3A%2F%2F06C3B248-2EE2-4B19-BF30-9CD3AEFB7F97%2Fappyinxiangcom%2F19010725%2FENResource%2Fp155)%0A

发表回复

Copyright © 2024 aiapaas.com 粤ICP备 18086566号