hadoop下载链接
hbase下载链接
2、制作Dockerfile,
Dockerfile文件内容:
FROM centos:8
#环境配置
RUN yum install -y openssh openssh-clients openssh-server which net-tools
RUN ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa && cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys && chmod 0600 ~/.ssh/authorized_keys
RUN yum install -y java-1.8.0-openjdk-devel
#安装Hadoop
COPY ./hadoop-3.2.1.tar.gz /tmp/tar/hadoop-3.2.1.tar.gz
RUN cd /tmp/tar/ && tar -zxf hadoop-3.2.1.tar.gz -C /opt && rm -f hadoop-3.2.1.tar.gz
COPY ./.bashrc /root/.bashrc
COPY ./core-site.xml /opt/hadoop-3.2.1/etc/hadoop/core-site.xml
COPY ./hdfs-site.xml /opt/hadoop-3.2.1/etc/hadoop/hdfs-site.xml
COPY ./mapred-site.xml /opt/hadoop-3.2.1/etc/hadoop/mapred-site.xml
COPY ./yarn-site.xml /opt/hadoop-3.2.1/etc/hadoop/yarn-site.xml
#安装HBase
COPY ./hbase-2.3.1-bin.tar.gz /tmp/tar/hbase-2.3.1-bin.tar.gz
RUN cd /tmp/tar/ && tar -zxf hbase-2.3.1-bin.tar.gz -C /opt && rm -f hbase-2.3.1-bin.tar.gz
#修改$HBASE_HOME/conf/hbase-env.sh文件,添加JAVA_HOME配置
COPY ./hbase-env.sh /opt/hbase-2.3.1/conf/hbase-env.sh
#安装PostgreSQL
RUN yum install -y @postgresql:12
WORKDIR /opt
.bashrc文件内容:
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk/jre
export JRE_HOME=${JAVA_HOME}
export CLASSPAT=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
export HDFS_NAMENODE_USER=root
export HDFS_SECONDARYNAMENODE_USER=root
export HDFS_DATANODE_USER=root
export YARN_RESOURCEMANAGER_USER=root
export YARN_NODEMANAGER_USER=root
entrypoint.sh文件内容:
#!/bin/bash
systemctl start sshd
tail -f /dev/null
hbase-env.sh文件内容(配置hbase的JAVA_HOME):
#!/usr/bin/env bash
#修改了jre环境变量
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk/jre
以下几个xml文件是启动三种模式Hadoop集群所需要修改的配置:
Local (Standalone) Mode
Pseudo-Distributed Mode(core-site.xml、hdfs-site.xml)
Fully-Distributed Mode(mapred-site.xml、yarn-site.xml)
core-site.xml文件内容:
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://0.0.0.0:9000</value>
</property>
</configuration>
hdfs-site.xml文件内容:
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
mapred-site.xml文件内容:
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>mapreduce.application.classpath</name>
<value>$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/*:$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/lib/*
yarn-site.xml文件内容:
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.env-whitelist</name>
<value>JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_MAPRED_HOME</value>
</property>
</configuration>
docker exec -it hadoop bash
安装完成!