Dcoker安装Hadoop2.7.7
2019-08-10 本文已影响0人
Yinawake
安装JDK:
- 下载
jdk-8u221-linux-x64.tar.gz
。 - 解压
tar -xzvf jdk-8u221-linux-x64.tar.gz
- 配置环境变量
vim .bashrc
export JAVA_HOME=/opt/jdk1.8
export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
安装Hadoop
- 下载
hadoop-2.7.7.tar.gz
。 - 解压
tar -xzvf hadoop-2.7.7.tar.gz
注:
遇到解压后问价夹的用户和组都是不当前用户,所以涉及修改文件夹所在组,用户。如下:
chown -R root /hadoop
chgrp -R root /hadoop
- 修改hadoop/etc/hadoop/下:
- mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
- core.site.xml
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://YARN001:8020</value>
</property>
</configuration>
- yarn.site.xml
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce-shuffle</value>
</property>
</configuration>
- hfds.site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
因为docker
中修改hosts
不生效,所以需要每次启动时增加hostname
docker run --add-host YARN001:127.0.0.1 -it ubuntu:java
报错
hdfs//YARN001:8020 has no authority
安装ssh
apt-get install ssh
sudo apt-get install pdsh
$ ssh-keygen -t rsa
$ cd .ssh/
$ cat id_rsa.pub >> authorized_keys
- 格式化HDFS
bin/hadoop namenode -format
- 启动HDFS
sbin/hadoop-deamon.sh start namenode
sbin/hadoop-deamon.sh start datanode
或者sbin/ start-dfs.sh
- 启动YARN
sbin/yarn-daemon.sh start resourcemanager
sbin/yarn-daemon.sh start nodemanager
或者sbin/start-yarn.sh
使用jps
查看是否启动成功
root@df087d56cf7c:/opt/hadoop2.7.7# jps
1461 NodeManager
1493 Jps
1034 DataNode
1213 ResourceManager
941 NameNode
访问:
http://192.168.99.100:8088/cluster
http://192.168.99.100:50070/dfshealth.html#tab-overview
image.png问题
0.0.0.0: ssh: connect to host 0.0.0.0 port 22: Connection refused
安装ssh
apt-get install openssh-server
docker中安装sshd后不会默认启动,所以需要在.bashrc
中配置service ssh start
。
命令启动:
docker run --add-host YARN001:127.0.0.1 -it -p8088:8088 -p 50070:50070 ubuntu:hadoop
sbin/hadoop-deamon.sh start namenode
sbin/hadoop-deamon.sh start datanode
sbin/yarn-deamon.sh start resourcemanager
sbin/yarn-deamon.sh start nodemanager