centos7 docker 安装hadoop 2.7.2记录


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_67
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export HADOOP_HOME=/root/soft/hadoop-2.7.2
export HADOOP_CONFIG_HOME=$HADOOP_HOME/etc/hadoop
export PATH=$PATH:$HADOOP_HOME/bin
export 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_dsa
root@8ef06706f88d:~# cd .ssh
root@8ef06706f88d:~/.ssh# cat id_dsa.pub >> authorized_keys

保存镜像副本

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

root@8ef06706f88d:~# exit
king@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>
 
 
 



 







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值