Spark集羣搭建【Spark+Hadoop+Scala+Zookeeper】

1.安裝Linuxhtml

  須要:3臺CentOS7虛擬機java

  IP:192.168.245.130,192.168.245.131,192.168.245.132(相似,儘可能保持連續,方便記憶)node

  

  注意:python

    3臺虛擬機的網絡設置爲NAT模式,這樣安裝好後的3臺虛擬機的IP是挨着的,否則還要修改IP,以達到便於配置集羣的目的!git

    NAT模式能夠在斷網的狀況下鏈接上虛擬機而橋架模式不行!web

2.安裝JDKredis

  參考個人博客:https://www.cnblogs.com/yszd/p/10140327.htmlshell

3.運行Spark預編譯包中的實例apache

  1.測試Scala代碼實例json

    執行:

     運行Scala版本計算Pi的代碼實例結果:

      

    表示運行成功!

   2.測試python代碼實例

    執行:,運行python版本計算Pi的代碼實例

    注意,若要是遇到下面的異常:

   表示沒有指定ip,這是須要修改配置文件spark-env.sh,前往conf目錄下執行

     

   拷貝配置模板文件,並修改成spark-env.sh,執行

     

   打開配置文件,添加,指定默認ip。

     

   而後繼續執行計算Pi代碼命令:

         

   結果以下:   

     

   表示執行成功!

 4.本地體驗Spark

  1.執行命令進入Spark交互模式

  2.編寫簡單代碼實例

    

    執行結果:

    

 5.Zookeeper集羣部署

  1.上傳zookeeper到集羣的各個節點

    

  2.修改配置,指定datadir和集羣節點配置

  initLimit=10
  syncLimit=5
  dataDir=/hadoop/zookeeper
  dataLogDir=/usr/local/soft/zookeeper-3.4.12/log
  clientPort=2181
  #maxClientCnxns=60
  server.1 = master:2888:3888
  server.2 = worker1:2888:3888
  server.3 = worker2:2888:3888

  3.配置myid

    

    注意:內容爲上面server.x中的x

  4.啓動zookeeper節點,查看節點運行狀態

    

    

    

    注意:節點zhen啓動異常,查看zoo.cfg配置是否正確及防火牆是否已經關閉,肯定無誤後等待zookeeper自啓!

     

    異常節點zhen啓動成功,zookeeper集羣搭建完成!

6.Spark Standalone集羣搭建

  1.配置集羣免密碼登陸

    參考個人博客:https://www.cnblogs.com/yszd/p/10123911.html

  2.安裝scala環境

    

    上傳scala安裝包,執行命令:rpm -ivh scala-2.11.8.rpm安裝scala環境

    

    輸入scala檢測是否安裝成功

    

    表示安裝成功!

    配置環境變量,編輯etc/profile,添加:

    

7.Hadoop2.7.3徹底分佈式搭建

  1.下載文件

    http://www-eu.apache.org/dist/hadoop/common/hadoop-2.7.3/hadoop-2.7.3.tar.gz

  2.上傳並解壓Hadoop文件

    

  3.修改相應配置文件

    3.1 etc/profile:

      

    3.2 HADOOP_HOME/etc/hadoop/hadoop-env.sh

       

    3.3 HADOOP_HOME/etc/hadoop/slaves

       

    3.4 HADOOP_HOME/etc/hadoop/core-site.xml   

    <configuration>
          <property>
                <name>fs.default.name</name>
                <value>hdfs://master:9000</value>
          </property>
          <property>
                <name>io.file.buffer.size</name>
                <value>131072</value>
          </property>
          <property>
                <name>hadoop.tmp.dir</name>
                <value>/usr/local/soft/hadoop-2.7.3/tmp</value>
          </property>
    </configuration>

    3.5 HADOOP_HOME/etc/hadoop/hdfs-site.xml   

    <configuration>
          <property>
                <name>dfs.replication</name>
                <value>2</value>
          </property>
          <property>
                <name>dfs.namenode.name.dir</name>
                <value>file:/usr/local/soft/hadoop-2.7.3/hdfs/name</value>
          </property>
          <property>
                <name>dfs.datanode.data.dir</name>
                <value>file:/usr/local/soft/hadoop-2.7.3/hdfs/data</value>
          </property>
          <property>
                <name>dfs.namenode.secondary.http-address</name>
                <value>master:50090</value>
          </property>
    </configuration>

    3.6 HADOOP_HOME/etc/hadoop/mapred-site.xml      

    <configuration>
          <property>
                <name>mapreduce.framework.name</name>
                <value>yarn</value>
          </property>
    </configuration>

    3.7 HADOOP_HOME/etc/hadoop/yarn-site.xml    

    <configuration>
          <property>
                <name>yarn.nodemanager.aux-services</name>
                <value>mapreduce_shuffle</value>
          </property>
          <property>
                <name>yarn.resourcemanager.hostname</name>
                <value>master</value>
          </property>
          <property>
                <name>yarn.log-aggregation-enable</name>
                <value>true</value>
          </property>
          <property>
                <name>yarn.log-aggregation.retain-seconds</name>
                <value>604800</value>
          </property>
    </configuration>

     3.8 格式化Hadoop

      執行:hdfs namenode -format

      執行結果:

[root@zhen etc]# hdfs namenode format
19/01/24 15:28:58 INFO namenode.NameNode: STARTUP_MSG: 
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG:   host = zhen-03.zookeeper.com/192.168.245.133
STARTUP_MSG:   args = [format]
STARTUP_MSG:   version = 2.7.3
STARTUP_MSG:   classpath = /usr/local/soft/hadoop-2.7.3/etc/hadoop:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/activation-1.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/apacheds-i18n-2.0.0-M15.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/apacheds-kerberos-codec-2.0.0-M15.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/api-asn1-api-1.0.0-M20.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/api-util-1.0.0-M20.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/asm-3.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/avro-1.7.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-beanutils-1.7.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-beanutils-core-1.8.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-cli-1.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-codec-1.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-collections-3.2.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-compress-1.4.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-configuration-1.6.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-digester-1.8.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-httpclient-3.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-io-2.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-lang-2.6.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-logging-1.1.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-math3-3.1.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-net-3.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/curator-client-2.7.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/curator-framework-2.7.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/curator-recipes-2.7.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/gson-2.2.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/guava-11.0.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/hadoop-annotations-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/hadoop-auth-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/hamcrest-core-1.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/htrace-core-3.1.0-incubating.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/httpclient-4.2.5.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/httpcore-4.2.5.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jackson-core-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jackson-jaxrs-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jackson-xc-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/java-xmlbuilder-0.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jaxb-api-2.2.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jaxb-impl-2.2.3-1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jersey-core-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jersey-json-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jersey-server-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jets3t-0.9.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jettison-1.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jetty-6.1.26.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jetty-util-6.1.26.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jsch-0.1.42.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jsp-api-2.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jsr305-3.0.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/junit-4.11.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/log4j-1.2.17.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/mockito-all-1.8.5.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/netty-3.6.2.Final.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/paranamer-2.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/protobuf-java-2.5.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/servlet-api-2.5.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/slf4j-api-1.7.10.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/snappy-java-1.0.4.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/stax-api-1.0-2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/xmlenc-0.52.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/xz-1.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/zookeeper-3.4.6.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/hadoop-common-2.7.3-tests.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/hadoop-common-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/hadoop-nfs-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/asm-3.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-cli-1.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-codec-1.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-daemon-1.0.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-io-2.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-lang-2.6.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-logging-1.1.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/guava-11.0.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/htrace-core-3.1.0-incubating.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/jackson-core-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/jersey-core-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/jersey-server-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/jetty-6.1.26.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/jetty-util-6.1.26.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/jsr305-3.0.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/leveldbjni-all-1.8.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/log4j-1.2.17.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/netty-3.6.2.Final.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/netty-all-4.0.23.Final.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/protobuf-java-2.5.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/servlet-api-2.5.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/xercesImpl-2.9.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/xml-apis-1.3.04.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/xmlenc-0.52.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/hadoop-hdfs-2.7.3-tests.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/hadoop-hdfs-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/hadoop-hdfs-nfs-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/activation-1.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/aopalliance-1.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/asm-3.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/commons-cli-1.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/commons-codec-1.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/commons-collections-3.2.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/commons-compress-1.4.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/commons-io-2.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/commons-lang-2.6.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/commons-logging-1.1.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/guava-11.0.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/guice-3.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/guice-servlet-3.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jackson-core-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jackson-jaxrs-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jackson-xc-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/javax.inject-1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jaxb-api-2.2.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jaxb-impl-2.2.3-1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jersey-client-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jersey-core-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jersey-guice-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jersey-json-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jersey-server-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jettison-1.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jetty-6.1.26.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jetty-util-6.1.26.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jsr305-3.0.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/leveldbjni-all-1.8.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/log4j-1.2.17.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/netty-3.6.2.Final.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/protobuf-java-2.5.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/servlet-api-2.5.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/stax-api-1.0-2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/xz-1.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/zookeeper-3.4.6-tests.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/zookeeper-3.4.6.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-api-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-applications-distributedshell-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-applications-unmanaged-am-launcher-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-client-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-common-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-registry-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-applicationhistoryservice-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-common-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-nodemanager-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-resourcemanager-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-sharedcachemanager-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-tests-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-web-proxy-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/aopalliance-1.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/asm-3.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/avro-1.7.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/commons-compress-1.4.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/commons-io-2.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/guice-3.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/guice-servlet-3.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/hadoop-annotations-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/hamcrest-core-1.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/jackson-core-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/javax.inject-1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/jersey-core-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/jersey-guice-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/jersey-server-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/junit-4.11.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/leveldbjni-all-1.8.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/log4j-1.2.17.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/netty-3.6.2.Final.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/paranamer-2.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/protobuf-java-2.5.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/snappy-java-1.0.4.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/xz-1.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-app-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-common-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-plugins-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.7.3-tests.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-shuffle-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/contrib/capacity-scheduler/*.jar
STARTUP_MSG:   build = https://git-wip-us.apache.org/repos/asf/hadoop.git -r baa91f7c6bc9cb92be5982de4719c1c8af91ccff; compiled by 'root' on 2016-08-18T01:41Z
STARTUP_MSG:   java = 1.8.0_172
************************************************************/
19/01/24 15:28:58 INFO namenode.NameNode: registered UNIX signal handlers for [TERM, HUP, INT]
19/01/24 15:28:58 INFO namenode.NameNode: createNameNode [format]
Usage: java NameNode [-backup] | 
    [-checkpoint] | 
    [-format [-clusterid cid ] [-force] [-nonInteractive] ] | 
    [-upgrade [-clusterid cid] [-renameReserved<k-v pairs>] ] | 
    [-upgradeOnly [-clusterid cid] [-renameReserved<k-v pairs>] ] | 
    [-rollback] | 
    [-rollingUpgrade <rollback|downgrade|started> ] | 
    [-finalize] | 
    [-importCheckpoint] | 
    [-initializeSharedEdits] | 
    [-bootstrapStandby] | 
    [-recover [ -force] ] | 
    [-metadataVersion ]  ]

19/01/24 15:29:00 INFO namenode.NameNode: SHUTDOWN_MSG: 
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at zhen-03.zookeeper.com/192.168.245.133
************************************************************/
View Code

  4.拷貝Hadoop到Worker節點

    執行命令:scp -r /usr/local/soft/hadoop-2.7.3 root@worker1:/usr/local/soft

    執行命令:scp -r /usr/local/soft/hadoop-2.7.3 root@worker2:/usr/local/soft  

   5.在瀏覽器上輸入:master:50070查看

    

    

    表示安裝成功!

 8.Spark-2.1.1徹底分佈式搭建

  1.下載安裝文件

    http://d3kbcqa49mib13.cloudfront.net/spark-2.1.1-bin-hadoop2.7.tgz

  2.上傳並解壓安裝文件

    

  3.修改相應的配置文件

    3.1 etc/profile

      

    3.2 SPARK_HOME/conf/spark-env.sh

      

    3.3 SPARK_HOME/conf/slaves

      

9.編輯集羣的腳本

  1.啓動腳本

#!/bin/bash
echo -e "=========================Start spark cluster=================================="
echo -e "Starting Hadoop..."
/usr/local/soft/hadoop-2.7.3/sbin/start-all.sh
echo -e "Starting Spark..."
/usr/local/soft/spark-2.1.1-bin-hadoop2.7/sbin/start-all.sh
echo -e "The Result of the Command \"jps\""
jps
echo -e "=================================End=========================================="

  2.啓動結果

=========================Start spark cluster==================================
Starting Hadoop...
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /usr/local/soft/hadoop-2.7.3/lib/native/libhadoop.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
19/01/25 14:22:24 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Starting namenodes on [master]
master: starting namenode, logging to /usr/local/soft/hadoop-2.7.3/logs/hadoop-root-namenode-zhen.out
worker2: starting datanode, logging to /usr/local/soft/hadoop-2.7.3/logs/hadoop-root-datanode-CentOS9.com.out
worker1: starting datanode, logging to /usr/local/soft/hadoop-2.7.3/logs/hadoop-root-datanode-CentOS.com.out
Starting secondary namenodes [master]
master: starting secondarynamenode, logging to /usr/local/soft/hadoop-2.7.3/logs/hadoop-root-secondarynamenode-zhen.out
Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /usr/local/soft/hadoop-2.7.3/lib/native/libhadoop.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
19/01/25 14:22:58 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
starting yarn daemons
starting resourcemanager, logging to /usr/local/soft/hadoop-2.7.3/logs/yarn-root-resourcemanager-zhen.out
worker1: starting nodemanager, logging to /usr/local/soft/hadoop-2.7.3/logs/yarn-root-nodemanager-CentOS.com.out
worker2: starting nodemanager, logging to /usr/local/soft/hadoop-2.7.3/logs/yarn-root-nodemanager-CentOS9.com.out
Starting Spark...
starting org.apache.spark.deploy.master.Master, logging to /usr/local/soft/spark-2.1.1-bin-hadoop2.7/logs/spark-root-org.apache.spark.deploy.master.Master-1-zhen.out
failed to launch: nice -n 0 /usr/local/soft/spark-2.1.1-bin-hadoop2.7/bin/spark-class org.apache.spark.deploy.master.Master --host zhen --port 7077 --webui-port 8080
full log in /usr/local/soft/spark-2.1.1-bin-hadoop2.7/logs/spark-root-org.apache.spark.deploy.master.Master-1-zhen.out
master: starting org.apache.spark.deploy.worker.Worker, logging to /usr/local/soft/spark-2.1.1-bin-hadoop2.7/logs/spark-root-org.apache.spark.deploy.worker.Worker-1-zhen.out
worker2: starting org.apache.spark.deploy.worker.Worker, logging to /usr/local/soft/spark-2.1.1-bin-hadoop2.7/logs/spark-root-org.apache.spark.deploy.worker.Worker-1-CentOS9.com.out
worker1: starting org.apache.spark.deploy.worker.Worker, logging to /usr/local/soft/spark-2.1.1-bin-hadoop2.7/logs/spark-root-org.apache.spark.deploy.worker.Worker-1-CentOS.com.out
worker2: failed to launch: nice -n 0 /usr/local/soft/spark-2.1.1-bin-hadoop2.7/bin/spark-class org.apache.spark.deploy.worker.Worker --webui-port 8081 spark://zhen:7077
worker2: full log in /usr/local/soft/spark-2.1.1-bin-hadoop2.7/logs/spark-root-org.apache.spark.deploy.worker.Worker-1-CentOS9.com.out
worker1: failed to launch: nice -n 0 /usr/local/soft/spark-2.1.1-bin-hadoop2.7/bin/spark-class org.apache.spark.deploy.worker.Worker --webui-port 8081 spark://zhen:7077
worker1: full log in /usr/local/soft/spark-2.1.1-bin-hadoop2.7/logs/spark-root-org.apache.spark.deploy.worker.Worker-1-CentOS.com.out
The Result of the Command "jps"
3584 Master
3872 Jps
3361 SecondaryNameNode
3505 ResourceManager
3841 Worker
=================================End==========================================
View Code

  注意:若是jps沒有namenode,則說明namenode元數據損壞,這時須要前往bin目錄下,執行:hadoop namenode -format重建一下 

  結果以下:

DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

19/01/25 14:44:56 INFO namenode.NameNode: STARTUP_MSG: 
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG:   host = zhen/123.129.254.12
STARTUP_MSG:   args = [-format]
STARTUP_MSG:   version = 2.7.3
STARTUP_MSG:   classpath = /usr/local/soft/hadoop-2.7.3/etc/hadoop:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/activation-1.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/apacheds-i18n-2.0.0-M15.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/apacheds-kerberos-codec-2.0.0-M15.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/api-asn1-api-1.0.0-M20.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/api-util-1.0.0-M20.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/asm-3.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/avro-1.7.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-beanutils-1.7.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-beanutils-core-1.8.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-cli-1.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-codec-1.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-collections-3.2.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-compress-1.4.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-configuration-1.6.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-digester-1.8.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-httpclient-3.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-io-2.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-lang-2.6.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-logging-1.1.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-math3-3.1.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/commons-net-3.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/curator-client-2.7.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/curator-framework-2.7.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/curator-recipes-2.7.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/gson-2.2.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/guava-11.0.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/hadoop-annotations-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/hadoop-auth-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/hamcrest-core-1.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/htrace-core-3.1.0-incubating.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/httpclient-4.2.5.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/httpcore-4.2.5.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jackson-core-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jackson-jaxrs-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jackson-xc-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/java-xmlbuilder-0.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jaxb-api-2.2.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jaxb-impl-2.2.3-1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jersey-core-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jersey-json-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jersey-server-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jets3t-0.9.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jettison-1.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jetty-6.1.26.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jetty-util-6.1.26.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jsch-0.1.42.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jsp-api-2.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/jsr305-3.0.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/junit-4.11.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/log4j-1.2.17.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/mockito-all-1.8.5.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/netty-3.6.2.Final.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/paranamer-2.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/protobuf-java-2.5.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/servlet-api-2.5.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/slf4j-api-1.7.10.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/snappy-java-1.0.4.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/stax-api-1.0-2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/xmlenc-0.52.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/xz-1.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/lib/zookeeper-3.4.6.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/hadoop-common-2.7.3-tests.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/hadoop-common-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/common/hadoop-nfs-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/asm-3.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-cli-1.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-codec-1.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-daemon-1.0.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-io-2.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-lang-2.6.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-logging-1.1.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/guava-11.0.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/htrace-core-3.1.0-incubating.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/jackson-core-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/jersey-core-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/jersey-server-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/jetty-6.1.26.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/jetty-util-6.1.26.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/jsr305-3.0.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/leveldbjni-all-1.8.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/log4j-1.2.17.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/netty-3.6.2.Final.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/netty-all-4.0.23.Final.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/protobuf-java-2.5.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/servlet-api-2.5.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/xercesImpl-2.9.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/xml-apis-1.3.04.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/lib/xmlenc-0.52.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/hadoop-hdfs-2.7.3-tests.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/hadoop-hdfs-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/hdfs/hadoop-hdfs-nfs-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/activation-1.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/aopalliance-1.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/asm-3.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/commons-cli-1.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/commons-codec-1.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/commons-collections-3.2.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/commons-compress-1.4.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/commons-io-2.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/commons-lang-2.6.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/commons-logging-1.1.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/guava-11.0.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/guice-3.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/guice-servlet-3.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jackson-core-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jackson-jaxrs-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jackson-xc-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/javax.inject-1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jaxb-api-2.2.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jaxb-impl-2.2.3-1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jersey-client-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jersey-core-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jersey-guice-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jersey-json-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jersey-server-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jettison-1.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jetty-6.1.26.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jetty-util-6.1.26.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/jsr305-3.0.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/leveldbjni-all-1.8.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/log4j-1.2.17.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/netty-3.6.2.Final.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/protobuf-java-2.5.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/servlet-api-2.5.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/stax-api-1.0-2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/xz-1.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/zookeeper-3.4.6-tests.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/lib/zookeeper-3.4.6.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-api-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-applications-distributedshell-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-applications-unmanaged-am-launcher-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-client-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-common-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-registry-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-applicationhistoryservice-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-common-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-nodemanager-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-resourcemanager-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-sharedcachemanager-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-tests-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-web-proxy-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/aopalliance-1.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/asm-3.2.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/avro-1.7.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/commons-compress-1.4.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/commons-io-2.4.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/guice-3.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/guice-servlet-3.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/hadoop-annotations-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/hamcrest-core-1.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/jackson-core-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/javax.inject-1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/jersey-core-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/jersey-guice-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/jersey-server-1.9.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/junit-4.11.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/leveldbjni-all-1.8.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/log4j-1.2.17.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/netty-3.6.2.Final.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/paranamer-2.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/protobuf-java-2.5.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/snappy-java-1.0.4.1.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/lib/xz-1.0.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-app-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-common-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-plugins-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.7.3-tests.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-shuffle-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar:/usr/local/soft/hadoop-2.7.3/contrib/capacity-scheduler/*.jar:/usr/local/soft/hadoop-2.7.3/contrib/capacity-scheduler/*.jar
STARTUP_MSG:   build = https://git-wip-us.apache.org/repos/asf/hadoop.git -r baa91f7c6bc9cb92be5982de4719c1c8af91ccff; compiled by 'root' on 2016-08-18T01:41Z
STARTUP_MSG:   java = 1.8.0_172
************************************************************/
19/01/25 14:44:56 INFO namenode.NameNode: registered UNIX signal handlers for [TERM, HUP, INT]
19/01/25 14:44:56 INFO namenode.NameNode: createNameNode [-format]
Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /usr/local/soft/hadoop-2.7.3/lib/native/libhadoop.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
19/01/25 14:44:58 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Formatting using clusterid: CID-27b9e297-649c-4dfc-8792-46ded8f0e5fd
19/01/25 14:45:00 INFO namenode.FSNamesystem: No KeyProvider found.
19/01/25 14:45:00 INFO namenode.FSNamesystem: fsLock is fair:true
19/01/25 14:45:00 INFO blockmanagement.DatanodeManager: dfs.block.invalidate.limit=1000
19/01/25 14:45:00 INFO blockmanagement.DatanodeManager: dfs.namenode.datanode.registration.ip-hostname-check=true
19/01/25 14:45:00 INFO blockmanagement.BlockManager: dfs.namenode.startup.delay.block.deletion.sec is set to 000:00:00:00.000
19/01/25 14:45:00 INFO blockmanagement.BlockManager: The block deletion will start around 2019 一月 25 14:45:00
19/01/25 14:45:00 INFO util.GSet: Computing capacity for map BlocksMap
19/01/25 14:45:00 INFO util.GSet: VM type       = 64-bit
19/01/25 14:45:00 INFO util.GSet: 2.0% max memory 966.7 MB = 19.3 MB
19/01/25 14:45:00 INFO util.GSet: capacity      = 2^21 = 2097152 entries
19/01/25 14:45:00 INFO blockmanagement.BlockManager: dfs.block.access.token.enable=false
19/01/25 14:45:00 INFO blockmanagement.BlockManager: defaultReplication         = 2
19/01/25 14:45:00 INFO blockmanagement.BlockManager: maxReplication             = 512
19/01/25 14:45:00 INFO blockmanagement.BlockManager: minReplication             = 1
19/01/25 14:45:00 INFO blockmanagement.BlockManager: maxReplicationStreams      = 2
19/01/25 14:45:00 INFO blockmanagement.BlockManager: replicationRecheckInterval = 3000
19/01/25 14:45:00 INFO blockmanagement.BlockManager: encryptDataTransfer        = false
19/01/25 14:45:00 INFO blockmanagement.BlockManager: maxNumBlocksToLog          = 1000
19/01/25 14:45:00 INFO namenode.FSNamesystem: fsOwner             = root (auth:SIMPLE)
19/01/25 14:45:00 INFO namenode.FSNamesystem: supergroup          = supergroup
19/01/25 14:45:00 INFO namenode.FSNamesystem: isPermissionEnabled = true
19/01/25 14:45:00 INFO namenode.FSNamesystem: HA Enabled: false
19/01/25 14:45:00 INFO namenode.FSNamesystem: Append Enabled: true
19/01/25 14:45:02 INFO util.GSet: Computing capacity for map INodeMap
19/01/25 14:45:02 INFO util.GSet: VM type       = 64-bit
19/01/25 14:45:02 INFO util.GSet: 1.0% max memory 966.7 MB = 9.7 MB
19/01/25 14:45:02 INFO util.GSet: capacity      = 2^20 = 1048576 entries
19/01/25 14:45:02 INFO namenode.FSDirectory: ACLs enabled? false
19/01/25 14:45:02 INFO namenode.FSDirectory: XAttrs enabled? true
19/01/25 14:45:02 INFO namenode.FSDirectory: Maximum size of an xattr: 16384
19/01/25 14:45:02 INFO namenode.NameNode: Caching file names occuring more than 10 times
19/01/25 14:45:02 INFO util.GSet: Computing capacity for map cachedBlocks
19/01/25 14:45:02 INFO util.GSet: VM type       = 64-bit
19/01/25 14:45:02 INFO util.GSet: 0.25% max memory 966.7 MB = 2.4 MB
19/01/25 14:45:02 INFO util.GSet: capacity      = 2^18 = 262144 entries
19/01/25 14:45:02 INFO namenode.FSNamesystem: dfs.namenode.safemode.threshold-pct = 0.9990000128746033
19/01/25 14:45:02 INFO namenode.FSNamesystem: dfs.namenode.safemode.min.datanodes = 0
19/01/25 14:45:02 INFO namenode.FSNamesystem: dfs.namenode.safemode.extension     = 30000
19/01/25 14:45:02 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.window.num.buckets = 10
19/01/25 14:45:02 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.num.users = 10
19/01/25 14:45:02 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.windows.minutes = 1,5,25
19/01/25 14:45:02 INFO namenode.FSNamesystem: Retry cache on namenode is enabled
19/01/25 14:45:02 INFO namenode.FSNamesystem: Retry cache will use 0.03 of total heap and retry cache entry expiry time is 600000 millis
19/01/25 14:45:02 INFO util.GSet: Computing capacity for map NameNodeRetryCache
19/01/25 14:45:02 INFO util.GSet: VM type       = 64-bit
19/01/25 14:45:02 INFO util.GSet: 0.029999999329447746% max memory 966.7 MB = 297.0 KB
19/01/25 14:45:02 INFO util.GSet: capacity      = 2^15 = 32768 entries
19/01/25 14:45:43 INFO namenode.FSImage: Allocated new BlockPoolId: BP-294533571-123.129.254.12-1548398742917
19/01/25 14:45:43 INFO common.Storage: Storage directory /usr/local/soft/hadoop-2.7.3/hdfs/name has been successfully formatted.
19/01/25 14:45:43 INFO namenode.FSImageFormatProtobuf: Saving image file /usr/local/soft/hadoop-2.7.3/hdfs/name/current/fsimage.ckpt_0000000000000000000 using no compression
19/01/25 14:45:44 INFO namenode.FSImageFormatProtobuf: Image file /usr/local/soft/hadoop-2.7.3/hdfs/name/current/fsimage.ckpt_0000000000000000000 of size 351 bytes saved in 0 seconds.
19/01/25 14:45:44 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
19/01/25 14:45:44 INFO util.ExitUtil: Exiting with status 0
19/01/25 14:45:44 INFO namenode.NameNode: SHUTDOWN_MSG: 
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at zhen/123.129.254.12
************************************************************/
View Code

  從新啓動以下:

=========================Start spark cluster==================================
Starting Hadoop...
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /usr/local/soft/hadoop-2.7.3/lib/native/libhadoop.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
19/01/25 14:47:54 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Starting namenodes on [master]
master: starting namenode, logging to /usr/local/soft/hadoop-2.7.3/logs/hadoop-root-namenode-zhen.out
worker1: starting datanode, logging to /usr/local/soft/hadoop-2.7.3/logs/hadoop-root-datanode-CentOS.com.out
worker2: starting datanode, logging to /usr/local/soft/hadoop-2.7.3/logs/hadoop-root-datanode-CentOS9.com.out
Starting secondary namenodes [master]
master: starting secondarynamenode, logging to /usr/local/soft/hadoop-2.7.3/logs/hadoop-root-secondarynamenode-zhen.out
Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /usr/local/soft/hadoop-2.7.3/lib/native/libhadoop.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
19/01/25 14:48:30 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
starting yarn daemons
starting resourcemanager, logging to /usr/local/soft/hadoop-2.7.3/logs/yarn-root-resourcemanager-zhen.out
worker2: starting nodemanager, logging to /usr/local/soft/hadoop-2.7.3/logs/yarn-root-nodemanager-CentOS9.com.out
worker1: starting nodemanager, logging to /usr/local/soft/hadoop-2.7.3/logs/yarn-root-nodemanager-CentOS.com.out
Starting Spark...
starting org.apache.spark.deploy.master.Master, logging to /usr/local/soft/spark-2.1.1-bin-hadoop2.7/logs/spark-root-org.apache.spark.deploy.master.Master-1-zhen.out
master: starting org.apache.spark.deploy.worker.Worker, logging to /usr/local/soft/spark-2.1.1-bin-hadoop2.7/logs/spark-root-org.apache.spark.deploy.worker.Worker-1-zhen.out
worker1: starting org.apache.spark.deploy.worker.Worker, logging to /usr/local/soft/spark-2.1.1-bin-hadoop2.7/logs/spark-root-org.apache.spark.deploy.worker.Worker-1-CentOS.com.out
worker2: starting org.apache.spark.deploy.worker.Worker, logging to /usr/local/soft/spark-2.1.1-bin-hadoop2.7/logs/spark-root-org.apache.spark.deploy.worker.Worker-1-CentOS9.com.out
The Result of the Command "jps"
7808 Worker
7729 Master
7494 SecondaryNameNode
7641 ResourceManager
7836 Jps
7341 NameNode
=================================End==========================================
View Code

  表示啓動成功!

  3.關閉腳本

#!/bin/bash
echo -e "=========================Stop spark cluster=================================="
echo -e "Stoping Hadoop..."
/usr/local/soft/hadoop-2.7.3/sbin/stop-all.sh
echo -e "Stoping Spark..."
/usr/local/soft/spark-2.1.1-bin-hadoop2.7/sbin/stop-all.sh
echo -e "The Result of the Command \"jps\""
jps
echo -e "=================================End=========================================="

  4.執行結果

=========================Stop spark cluster==================================
Stoping Hadoop...
This script is Deprecated. Instead use stop-dfs.sh and stop-yarn.sh
Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /usr/local/soft/hadoop-2.7.3/lib/native/libhadoop.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
19/01/25 14:53:01 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Stopping namenodes on [master]
master: stopping namenode
worker1: stopping datanode
worker2: stopping datanode
Stopping secondary namenodes [master]
master: stopping secondarynamenode
Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /usr/local/soft/hadoop-2.7.3/lib/native/libhadoop.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
19/01/25 14:53:33 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
stopping yarn daemons
stopping resourcemanager
worker2: stopping nodemanager
worker1: stopping nodemanager
no proxyserver to stop
Stoping Spark...
master: no org.apache.spark.deploy.worker.Worker to stop
worker2: no org.apache.spark.deploy.worker.Worker to stop
worker1: no org.apache.spark.deploy.worker.Worker to stop
no org.apache.spark.deploy.master.Master to stop
The Result of the Command "jps"
8563 Jps
=================================End==========================================
View Code

10.測試

  1.測試Hadoop

    1.1 建立測試文件    

    

    1.2 編輯內容

      spark scala hadoop spark hadoop java redis hbase hive kafka flume

    1.3 建立Hadoop文件夾,用於保存測試文件

      hadoop fs -mkdir -p /hadoop/data

     1.4 把建立好的測試文件導入到Hadoop中

      hadoop fs -put /wordcount.txt

    1.5 運行程序

         hadoop jar /usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount /hadoop/data /hadoop/output

    1.6 執行日誌

[root@master data]# hadoop jar /usr/local/soft/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount /hadoop/data /hadoop/output
19/03/29 17:38:50 INFO client.RMProxy: Connecting to ResourceManager at master/192.168.245.136:8032
19/03/29 17:38:56 INFO input.FileInputFormat: Total input paths to process : 1
19/03/29 17:38:56 INFO mapreduce.JobSubmitter: number of splits:1
19/03/29 17:38:57 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1553851703365_0002
19/03/29 17:39:00 INFO impl.YarnClientImpl: Submitted application application_1553851703365_0002
19/03/29 17:39:00 INFO mapreduce.Job: The url to track the job: http://master:8088/proxy/application_1553851703365_0002/
19/03/29 17:39:00 INFO mapreduce.Job: Running job: job_1553851703365_0002
19/03/29 17:39:50 INFO mapreduce.Job: Job job_1553851703365_0002 running in uber mode : false
19/03/29 17:39:50 INFO mapreduce.Job:  map 0% reduce 0%
19/03/29 17:40:22 INFO mapreduce.Job:  map 100% reduce 0%
19/03/29 17:40:56 INFO mapreduce.Job:  map 100% reduce 100%
19/03/29 17:40:58 INFO mapreduce.Job: Job job_1553851703365_0002 completed successfully
19/03/29 17:40:59 INFO mapreduce.Job: Counters: 49
    File System Counters
        FILE: Number of bytes read=113
        FILE: Number of bytes written=237519
        FILE: Number of read operations=0
        FILE: Number of large read operations=0
        FILE: Number of write operations=0
        HDFS: Number of bytes read=176
        HDFS: Number of bytes written=71
        HDFS: Number of read operations=6
        HDFS: Number of large read operations=0
        HDFS: Number of write operations=2
    Job Counters 
        Launched map tasks=1
        Launched reduce tasks=1
        Data-local map tasks=1
        Total time spent by all maps in occupied slots (ms)=28026
        Total time spent by all reduces in occupied slots (ms)=28758
        Total time spent by all map tasks (ms)=28026
        Total time spent by all reduce tasks (ms)=28758
        Total vcore-milliseconds taken by all map tasks=28026
        Total vcore-milliseconds taken by all reduce tasks=28758
        Total megabyte-milliseconds taken by all map tasks=28698624
        Total megabyte-milliseconds taken by all reduce tasks=29448192
    Map-Reduce Framework
        Map input records=1
        Map output records=11
        Map output bytes=110
        Map output materialized bytes=113
        Input split bytes=109
        Combine input records=11
        Combine output records=9
        Reduce input groups=9
        Reduce shuffle bytes=113
        Reduce input records=9
        Reduce output records=9
        Spilled Records=18
        Shuffled Maps =1
        Failed Shuffles=0
        Merged Map outputs=1
        GC time elapsed (ms)=736
        CPU time spent (ms)=8700
        Physical memory (bytes) snapshot=296263680
        Virtual memory (bytes) snapshot=4165492736
        Total committed heap usage (bytes)=140288000
    Shuffle Errors
        BAD_ID=0
        CONNECTION=0
        IO_ERROR=0
        WRONG_LENGTH=0
        WRONG_MAP=0
        WRONG_REDUCE=0
    File Input Format Counters 
        Bytes Read=67
    File Output Format Counters 
        Bytes Written=71
View Code

       1.7 執行結果

     

    完成!!

相關文章
相關標籤/搜索