环境:docker
目录:hadoop将会安装在/root/hadoop
获取centos镜像及创建容器
docker pull centos
docker run -it --name hadoop centos /bin/bash
安装java
yum install -y java-1.8.0-openjdk.x86_64
yum install -y java-1.8.0-openjdk-devel.x86_64
安装工具
yum install wget.x86_64
yum -y install openssh-server openssh-clients
安装hadoop
wget http://mirrors.hust.edu.cn/apache/hadoop/common/hadoop-2.8.5/hadoop-2.8.5.tar.gz
tar -zxvf hadoop-2.8.5.tar.gz
mv hadoop-2.8.5/ hadoop
配置环境变量
vi ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/
export HADOOP_HOME=/root/hadoop
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
source ~/.bashrc
配置hadoop
cd /root/hadoop/etc/hadoop
//vi hadoop-env.sh
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/
//hdfs-site.xml
<!--配置HDFS的冗余度-->
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<!--配置是否检查权限-->
<property>
<name>dfs.permissions</name>
<value>false</value>
</property>
//core-site.xml
<!--配置HDFS的NameNode-->
<property>
<name>fs.defaultFS</name>
<value>hdfs://192.168.88.11:9000</value>
</property>
<!--配置DataNode保存数据的位置-->
<property>
<name>hadoop.tmp.dir</name>
<value>/root/hadoop-2.4.1/tmp</value>
</property>
//mapred-site.xml
<!--配置MR运行的框架-->
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
// yarn-site.xml
<!--配置ResourceManager的地址-->
<property>
<name>yarn.resourcemanager.hostname</name>
<value>192.168.88.11</value>
</property>
<!--配置NodeManager执行任务的方式-->
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
配置ssh无密码登陆
ssh-keygen -t rsa
cd ~/.ssh/
cat id_rsa.pub >> authorized_keys
格式化及启动停止
/root/hadoop/bin/hdfs namenode -format
sh /root/hadoop/sbin/start-all.sh
sh /root/hadoop/sbin/stop-all.sh
查看运行情况
netstat -nultp //查看端口号
jps //查看java服务是否开启