centos7 docker 安装hadoop 2.7.2记录

来源:互联网 发布:软件开发公司网站 编辑:程序博客网 时间:2024/06/03 16:38


docker常用命令:

运行镜像:<code>docker run -i -t centos  /bin/bash</code>提交镜像:<code>docker commit 3a09b2588478 ubuntu:mynewimage</code>挂载目录:docker run --privileged=true  -v /home/admin/Downloads:/mnt -i -t centos复制文件:cp hostpath dockerpath

下载:

hadoop-2.7.2.tar.gz

jdk-7u67-linux-x64.tar.gz


解压文件:

<pre><code>tar xvzf hadoop-2.7.2.tar.gz</code>

<span style="color:#3366ff;"><span style="color:#000000;"><strong>设置环境变量:</strong>vi /etc/profile</span></span><code></code>文件。在文件末尾加入下面配置信息:export JAVA_HOME=/root/soft/jdk1.7.0_67export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport PATH=$PATH:$JAVA_HOME/binexport HADOOP_HOME=/root/soft/hadoop-2.7.2export HADOOP_CONFIG_HOME=$HADOOP_HOME/etc/hadoopexport PATH=$PATH:$HADOOP_HOME/binexport PATH=$PATH:$HADOOP_HOME/sbin使之立即生效source /etc/profile<strong>配置hadoop:</strong><pre><code>cd $HADOOP_CONFIG_HOME</code>

cp mapred-site.xml.template mapred-site.xml

[root@a875783df7bc hadoop]# cat core-site.xml                                                                                                    
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
    <property>
            <name>hadoop.tmp.dir</name>
            <value>/root/soft/hadoop-2.7.2/tmp</value>
            <description>A base for other temporary directories.</description>
    </property>

    <property>
            <name>fs.default.name</name>
            <value>hdfs://master:9000</value>
            <final>true</final>
            <description>The name of the default file system.  A URI whose
            scheme and authority determine the FileSystem implementation.  The
            uri's scheme determines the config property (fs.SCHEME.impl) naming
            the FileSystem implementation class.  The uri's authority is used to
            determine the host, port, etc. for a filesystem.</description>
    </property>
</configuration>


[root@a875783df7bc hadoop]# vi hdfs-site.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
   <property>
        <name>dfs.replication</name>
        <value>2</value>
        <final>true</final>
        <description>Default block replication.
        The actual number of replications can be specified when the file is created.
        The default is used if replication is not specified in create time.
        </description>
    </property>

    <property>
        <name>dfs.namenode.name.dir</name>
        <value>/root/soft/hadoop-2.7.2/namenode</value>
        <final>true</final>
    </property>

    <property>
        <name>dfs.datanode.data.dir</name>
        <value>/root/soft/hadoop-2.7.2/datanode</value>
        <final>true</final>
    </property>

</configuration>


[root@a875783df7bc hadoop]# vi mapred-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>
   <property>
        <name>mapred.job.tracker</name>
        <value>master:9001</value>
        <description>The host and port that the MapReduce job tracker runs
        at.  If "local", then jobs are run in-process as a single map
        and reduce task.
        </description>
    </property>
</configuration>


格式化 namenode,进入 hadoop/bin目录下执行
hdfs namenode -format

安装ssh
yum install openssh-server
yum -y install openssh-clients
生成访问密钥
root@8ef06706f88d:/# cd ~/root@8ef06706f88d:~# ssh-keygen -t rsa -P '' -f ~/.ssh/id_dsaroot@8ef06706f88d:~# cd .sshroot@8ef06706f88d:~/.ssh# cat id_dsa.pub >> authorized_keys

保存镜像副本

这里我们将安装好Hadoop的镜像保存为一个副本。

root@8ef06706f88d:~# exitking@king:~$ docker commit -m "hadoop-2.7.2 install" 8ef06706f88d centos:hadoop

查看docker ip
docker inspect --format '{{.NetworkSettings.IPAddress}}' 33d36f3b5c4c

<pre><code></code><pre name="code" class="plain"><pre><code>docker run -d -ti --name master -h master centos:hadoop</code>

<pre><code>docker run -d -ti --name slave1 -h slave1 centos:hadoop</code>

<pre><code></code><pre name="code" class="plain"><pre><code>docker run -d -ti --name slave2 -h slave2 centos:hadoop</code>









0 0