1、准备三台机器,每天机器关闭防火墙,设置hosts文件,配置免密登录

  • 关闭防火墙
servie iptables stop
chkconfig iptables off  && setenforce 0
  • 设置hosts
192.168.140.128 node01 zk01 kafka01 storm01 maven flume
192.168.140.129 node02 zk02 kafka02 storm02 redis
192.168.140.130 node03 zk03 kafka03 storm03 mysql
  • 免密登录,在node01执行以下命令。
ssh-keygen 四个回车
ssh-copy-id node1
ssh-copy-id node2
ssh-copy-id node3

如果免密登录失败,在每台机器上执行以下命令,然后在重试。

yum -y install openssh-clients

2、下载Hadoop安装包,也可以编译自己编译

3、配置文件部分

  • core-site.xml
<configuration>
        <!-- 指定hdfs的nameservice为ns1 -->
        <property>
                <name>fs.defaultFS</name>
                <value>hdfs://ns1/</value>
        </property>
        <!-- 指定hadoop临时目录 -->
        <property>
                <name>hadoop.tmp.dir</name>
                <value>/export/data/hdp/</value>
        </property>
        <!-- 指定zookeeper地址 -->
        <property>
                <name>ha.zookeeper.quorum</name>
                <value>node01:2181,node02:2181,node03:2181</value>
        </property>
</configuration>
  • hdfs-site.xml
<configuration>
        <!--指定hdfs的nameservice为ns1,需要和core-site.xml中的保持一致 -->
        <property>
                <name>dfs.nameservices</name>
                <value>ns1</value>
        </property>
        <!-- ns1下面有两个NameNode,分别是nn1,nn2 -->
        <property>
                <name>dfs.ha.namenodes.ns1</name>
                <value>nn1,nn2</value>
        </property>
        <!-- nn1的RPC通信地址 -->
        <property>
                <name>dfs.namenode.rpc-address.ns1.nn1</name>
                <value>node01:9000</value>
        </property>
        <!-- nn1的http通信地址 -->
        <property>
                <name>dfs.namenode.http-address.ns1.nn1</name>
                <value>node01:50070</value>
        </property>
        <!-- nn2的RPC通信地址 -->
        <property>
                <name>dfs.namenode.rpc-address.ns1.nn2</name>
                <value>node03:9000</value>
        </property>
        <!-- nn2的http通信地址 -->
        <property>
                <name>dfs.namenode.http-address.ns1.nn2</name>
                <value>node03:50070</value>
        </property>
                <!-- 指定NameNode的edits元数据在JournalNode上的存放位置 -->
        <property>
                <name>dfs.namenode.shared.edits.dir</name>
                <value>qjournal://node01:8485;node02:8485;node03:8485/ns1</value>
        </property>
        <!-- 指定JournalNode在本地磁盘存放数据的位置 -->
        <property>
                <name>dfs.journalnode.edits.dir</name>
                <value>/export/data/journaldata</value>
        </property>
        <!-- 开启NameNode失败自动切换 -->
        <property>
                <name>dfs.ha.automatic-failover.enabled</name>
                <value>true</value>
        </property>
        <!-- 配置失败自动切换实现方式 -->
        <property>
                <name>dfs.client.failover.proxy.provider.ns1</name>
                <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
        </property>
        <!-- 配置隔离机制方法,多个机制用换行分割,即每个机制暂用一行-->
        <property>
                <name>dfs.ha.fencing.methods</name>
                <value>
                        sshfence
                        shell(/bin/true)
                </value>
        </property>
        <!-- 使用sshfence隔离机制时需要ssh免登陆 -->
        <property>
                <name>dfs.ha.fencing.ssh.private-key-files</name>
                <value>/root/.ssh/id_rsa</value>
        </property>
        <!-- 配置sshfence隔离机制超时时间 -->
        <property>
                <name>dfs.ha.fencing.ssh.connect-timeout</name>
                <value>30000</value>
        </property>
</configuration>
  • yarn-site.xml
<?xml version="1.0"?>
<configuration>
        <property>
                <name>yarn.resourcemanager.hostname</name>
                <value>node01</value>
        </property>
        <property>
                <name>yarn.nodemanager.aux-services</name>
                <value>mapreduce_shuffle</value>
        </property>
</configuration>
  • hadoop-env.sh
# export JAVA_HOME=${JAVA_HOME}
export JAVA_HOME=/export/servers/jdk
  • mapred-site.xml 配置JDK
# export JAVA_HOME=/home/y/libexec/jdk1.6.0/
export JAVA_HOME=/export/servers/jdk
  • slaves
node01
node02
node03

4、初始化服务并启动

  • 拷贝安装包到其他节点
scp -r /export/servers/hadoop/ node02:/export/servers/
scp -r /export/servers/hadoop/ node03:/export/servers/
  • 配置环境变量,每台机器,并生效
export HADOOP_HOME=/export/servers/hadoop
export PATH=${HADOOP_HOME}/sbin:${HADOOP_HOME}/bin:$PATH

让环境变量生效

source /etc/profile
  • 初始化zookeeper里面的信息
start-dfs.sh 
hadoop namenode -format
scp -r /export/data/hdp/dfs  node03:/export/data/hdp/ 
stop-dfs.sh
-
startzk.sh 说明:这个是一键启动zk的脚本
hdfs zkfc -formatZK
  • 启动集群
start-dfs.sh
  • 访问集群
    http://node01:50070/dfshealth.html#tab-overview

标签: none

相关文章推荐

已有 2 条评论

  1. 17/11/17 18:06:34 WARN io.ReadaheadPool: Failed readahead on ifile
    EBADF: Bad file descriptor
    at org.apache.hadoop.io.nativeio.NativeIO$POSIX.posix_fadvise(Native Method)
    at org.apache.hadoop.io.nativeio.NativeIO$POSIX.posixFadviseIfPossible(NativeIO.java:267)
    at org.apache.hadoop.io.nativeio.NativeIO$POSIX$CacheManipulator.posixFadviseIfPossible(NativeIO.java:146)
    at org.apache.hadoop.io.ReadaheadPool$ReadaheadRequestImpl.run(ReadaheadPool.java:206)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

    毛祥溢 回复
  2. 1.安装hadoop集群启动成功
    部署架构:
    m1 NameNode
    m2 ResourceManager SecondaryNameNode
    m3 DataNode NodeManager
    m4 DataNode NodeManager
    m5 DataNode NodeManager
    启动成功:
    17/11/19 22:52:38 INFO common.Storage: Storage directory /home/hadoop/data/name has been successfully formatted.
    17/11/19 22:52:38 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
    17/11/19 22:52:38 INFO util.ExitUtil: Exiting with status 0
    17/11/19 22:52:38 INFO namenode.NameNode: SHUTDOWN_MSG:
    /************************************************************
    SHUTDOWN_MSG: Shutting down NameNode at m1/10.0.0.26
    ************************************************************/
    [root@m1 hadoop-2.6.4]# sbin/start-dfs.sh
    17/11/19 22:52:50 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    Starting namenodes on [m1]
    m1: starting namenode, logging to /home/hadoop/apps/hadoop-2.6.4/logs/hadoop-root-namenode-m1.out
    m5: starting datanode, logging to /home/hadoop/apps/hadoop-2.6.4/logs/hadoop-root-datanode-m5.out
    m3: starting datanode, logging to /home/hadoop/apps/hadoop-2.6.4/logs/hadoop-root-datanode-m3.out
    m4: starting datanode, logging to /home/hadoop/apps/hadoop-2.6.4/logs/hadoop-root-datanode-m4.out
    Starting secondary namenodes [m2]
    m2: starting secondarynamenode, logging to /home/hadoop/apps/hadoop-2.6.4/logs/hadoop-root-secondarynamenode-m2.out
    17/11/19 22:53:11 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    [root@m1 hadoop-2.6.4]#
    [root@m1 hadoop-2.6.4]# sbin/start-yarn.sh
    starting yarn daemons
    starting resourcemanager, logging to /home/hadoop/apps/hadoop-2.6.4/logs/yarn-root-resourcemanager-m1.out
    m3: starting nodemanager, logging to /home/hadoop/apps/hadoop-2.6.4/logs/yarn-root-nodemanager-m3.out
    m5: starting nodemanager, logging to /home/hadoop/apps/hadoop-2.6.4/logs/yarn-root-nodemanager-m5.out
    m4: starting nodemanager, logging to /home/hadoop/apps/hadoop-2.6.4/logs/yarn-root-nodemanager-m4.out
    [root@m1 hadoop-2.6.4]# sbin/start-yarn.sh
    starting yarn daemons
    starting resourcemanager, logging to /home/hadoop/apps/hadoop-2.6.4/logs/yarn-root-resourcemanager-m1.out
    m4: nodemanager running as process 1657. Stop it first.
    m3: nodemanager running as process 1651. Stop it first.
    m5: nodemanager running as process 1667. Stop it first.
    问题:
    运算wordcount时出错:求毛老师指点:
    [root@m1 mapreduce]# hadoop jar hadoop-mapreduce-examples-2.6.4.jar wordcount /wordcount/input /wordcount/output
    17/11/19 23:09:16 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    17/11/19 23:09:17 INFO client.RMProxy: Connecting to ResourceManager at m2/10.0.0.27:8032
    17/11/19 23:09:19 INFO ipc.Client: Retrying connect to server: m2/10.0.0.27:8032. Already tried 0 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1000 MILLISECONDS)
    17/11/19 23:09:20 INFO ipc.Client: Retrying connect to server: m2/10.0.0.27:8032. Already tried 1 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1000 MILLISECONDS)
    17/11/19 23:09:21 INFO ipc.Client: Retrying connect to server: m2/10.0.0.27:8032. Already tried 2 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1000 MILLISECONDS)

    云二期风一样的男人 回复
  3. 楼主好人一生平安

    LIAONADUO 回复

添加新评论,含*的栏目为必填