• 大数据开发-Hadoop伪集群搭建


    大数据开发-Hadoop伪集群搭建

    环境下载地址

    Hadoop下载地址:https://archive.apache.org/dist/hadoop/common/hadoop-3.2.0/

    Jdk下载地址:https://repo.huaweicloud.com/java/jdk/8u202-b08/

    虚拟机环境修改(CentOs7)

    1. 虚拟机静态IP设置
    [root@hadoop01 hadoop]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
    TYPE="Ethernet"
    PROXY_METHOD="none"
    BROWSER_ONLY="no"
    BOOTPROTO="static"		#修改为static
    DEFROUTE="yes"
    IPV4_FAILURE_FATAL="no"
    IPV6INIT="yes"
    IPV6_AUTOCONF="yes"
    IPV6_DEFROUTE="yes"
    IPV6_FAILURE_FATAL="no"
    IPV6_ADDR_GEN_MODE="stable-privacy"
    NAME="ens33"
    UUID="f784733d-1beb-4a60-bee1-a132fa810a0e"
    DEVICE="ens33"
    ONBOOT="yes"
    # 下面三项需要自己添加,(192.168.52)这个在VM中,点击编辑->虚拟网络编辑器->NAT设置中可以查看
    IPADDR=192.168.52.100
    GATEWAY=192.168.52.2
    DNS1=192.168.52.2
    
    
    # 修改完之后重启网卡
    [root@hadoop01 hadoop]# service network restart
    
    # 查看ip地址
    [root@hadoop01 hadoop]# ip addr
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host 
           valid_lft forever preferred_lft forever
    2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
        link/ether 00:0c:29:54:0d:dd brd ff:ff:ff:ff:ff:ff
        inet 192.168.52.100/24 brd 192.168.52.255 scope global noprefixroute ens33
           valid_lft forever preferred_lft forever
        inet6 fe80::965d:76b:dac9:4202/64 scope link noprefixroute 
           valid_lft forever preferred_lft forever
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40

    ​ 2. 修改hostname

    # localhost删掉,修改为自己想要的名字,比如我这里是hadoop01
    [root@hadoop01 hadoop]# vim /etc/hostname
    # 修改完成之后重启虚拟机
    [root@hadoop01 hadoop]# reboot -h now
    
    
    • 1
    • 2
    • 3
    • 4
    • 5

    Java以及Hadoop安装

    Java环境安装

    • 将下载好的文件上传到服务器指定位置

    image-20240304153008412

    • 解压
    [root@hadoop01 soft]# tar -zxvf jdk-8u202-linux-x64.tar.gz
    
    
    • 1
    • 2
    • 配置环境变量
    [root@hadoop01 soft]# vim /etc/profile
    # 文件末端添加
    export JAVA_HOME=/home/soft/jdk-8u202
    export PATH=$JAVA_HOME/bin:$PATH
    
    # 安装完成
    [root@hadoop01 soft]# java -version
    java version "1.8.0_202"
    Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
    Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    Hadoop环境安装

    • 解压
    [root@hadoop01 soft]# tar -zxvf jdk-8u202-linux-x64.tar.gz
    
    • 1
    • 配置环境变量
    [root@hadoop01 soft]# vim /etc/profile
    export HADOOP_HOME=/home/soft/hadoop-3.2.0
    export PATH=$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH
    
    
    • 1
    • 2
    • 3
    • 4

    Hadoop配置文件修改(/home/soft/hadoop-3.2.0/etc/hadoop)

    • core-site.xml
    
    
    
    
    
    
    <configuration>
    
    	<property>
    
    		<name>fs.defaultFSname>
    		<value>hdfs://hadoop01:9000value>
    	property>
    
    	<property>
        	<name>hadoop.tmp.dirname>
        	<value>/home/hadoop_repo/datavalue>
      	property>
    configuration>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • hadoop-env.sh
    #
    # Licensed to the Apache Software Foundation (ASF) under one
    # or more contributor license agreements.  See the NOTICE file
    # distributed with this work for additional information
    # regarding copyright ownership.  The ASF licenses this file
    # to you 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.
    
    # Set Hadoop-specific environment variables here.
    
    ##
    ## THIS FILE ACTS AS THE MASTER FILE FOR ALL HADOOP PROJECTS.
    ## SETTINGS HERE WILL BE READ BY ALL HADOOP COMMANDS.  THEREFORE,
    ## ONE CAN USE THIS FILE TO SET YARN, HDFS, AND MAPREDUCE
    ## CONFIGURATION OPTIONS INSTEAD OF xxx-env.sh.
    ##
    ## Precedence rules:
    ##
    ## {yarn-env.sh|hdfs-env.sh} > hadoop-env.sh > hard-coded defaults
    ##
    ## {YARN_xyz|HDFS_xyz} > HADOOP_xyz > hard-coded defaults
    ##
    
    # Many of the options here are built from the perspective that users
    # may want to provide OVERWRITING values on the command line.
    # For example:
    #
    # JAVA_HOME=/usr/java/testing hdfs dfs -ls
    #
    # Therefore, the vast majority (BUT NOT ALL!) of these defaults
    # are configured for substitution and not append.  If append
    # is preferable, modify this file accordingly.
    
    ###
    # Generic settings for HADOOP
    ###
    
    # Technically, the only required environment variable is JAVA_HOME.
    # All others are optional.  However, the defaults are probably not
    # preferred.  Many sites configure these options outside of Hadoop,
    # such as in /etc/profile.d
    
    # The java implementation to use. By default, this environment
    # variable is REQUIRED on ALL platforms except OS X!
    export JAVA_HOME=/home/soft/jdk1.8
    
    # Location of Hadoop.  By default, Hadoop will attempt to determine
    # this location based upon its execution path.
    # export HADOOP_HOME=
    
    # Location of Hadoop's configuration information.  i.e., where this
    # file is living. If this is not defined, Hadoop will attempt to
    # locate it based upon its execution path.
    #
    # NOTE: It is recommend that this variable not be set here but in
    # /etc/profile.d or equivalent.  Some options (such as
    # --config) may react strangely otherwise.
    #
    # export HADOOP_CONF_DIR=${HADOOP_HOME}/etc/hadoop
    
    # The maximum amount of heap to use (Java -Xmx).  If no unit
    # is provided, it will be converted to MB.  Daemons will
    # prefer any Xmx setting in their respective _OPT variable.
    # There is no default; the JVM will autoscale based upon machine
    # memory size.
    # export HADOOP_HEAPSIZE_MAX=
    
    # The minimum amount of heap to use (Java -Xms).  If no unit
    # is provided, it will be converted to MB.  Daemons will
    # prefer any Xms setting in their respective _OPT variable.
    # There is no default; the JVM will autoscale based upon machine
    # memory size.
    # export HADOOP_HEAPSIZE_MIN=
    
    # Enable extra debugging of Hadoop's JAAS binding, used to set up
    # Kerberos security.
    # export HADOOP_JAAS_DEBUG=true
    
    # Extra Java runtime options for all Hadoop commands. We don't support
    # IPv6 yet/still, so by default the preference is set to IPv4.
    # export HADOOP_OPTS="-Djava.net.preferIPv4Stack=true"
    # For Kerberos debugging, an extended option set logs more information
    # export HADOOP_OPTS="-Djava.net.preferIPv4Stack=true -Dsun.security.krb5.debug=true -Dsun.security.spnego.debug"
    
    # Some parts of the shell code may do special things dependent upon
    # the operating system.  We have to set this here. See the next
    # section as to why....
    export HADOOP_OS_TYPE=${HADOOP_OS_TYPE:-$(uname -s)}
    
    
    # Under certain conditions, Java on OS X will throw SCDynamicStore errors
    # in the system logs.
    # See HADOOP-8719 for more information.  If one needs Kerberos
    # support on OS X, one will want to change/remove this extra bit.
    case ${HADOOP_OS_TYPE} in
      Darwin*)
        export HADOOP_OPTS="${HADOOP_OPTS} -Djava.security.krb5.realm= "
        export HADOOP_OPTS="${HADOOP_OPTS} -Djava.security.krb5.kdc= "
        export HADOOP_OPTS="${HADOOP_OPTS} -Djava.security.krb5.conf= "
      ;;
    esac
    
    # Extra Java runtime options for some Hadoop commands
    # and clients (i.e., hdfs dfs -blah).  These get appended to HADOOP_OPTS for
    # such commands.  In most cases, # this should be left empty and
    # let users supply it on the command line.
    # export HADOOP_CLIENT_OPTS=""
    
    #
    # A note about classpaths.
    #
    # By default, Apache Hadoop overrides Java's CLASSPATH
    # environment variable.  It is configured such
    # that it starts out blank with new entries added after passing
    # a series of checks (file/dir exists, not already listed aka
    # de-deduplication).  During de-deduplication, wildcards and/or
    # directories are *NOT* expanded to keep it simple. Therefore,
    # if the computed classpath has two specific mentions of
    # awesome-methods-1.0.jar, only the first one added will be seen.
    # If two directories are in the classpath that both contain
    # awesome-methods-1.0.jar, then Java will pick up both versions.
    
    # An additional, custom CLASSPATH. Site-wide configs should be
    # handled via the shellprofile functionality, utilizing the
    # hadoop_add_classpath function for greater control and much
    # harder for apps/end-users to accidentally override.
    # Similarly, end users should utilize ${HOME}/.hadooprc .
    # This variable should ideally only be used as a short-cut,
    # interactive way for temporary additions on the command line.
    # export HADOOP_CLASSPATH="/some/cool/path/on/your/machine"
    
    # Should HADOOP_CLASSPATH be first in the official CLASSPATH?
    # export HADOOP_USER_CLASSPATH_FIRST="yes"
    
    # If HADOOP_USE_CLIENT_CLASSLOADER is set, the classpath along
    # with the main jar are handled by a separate isolated
    # client classloader when 'hadoop jar', 'yarn jar', or 'mapred job'
    # is utilized. If it is set, HADOOP_CLASSPATH and
    # HADOOP_USER_CLASSPATH_FIRST are ignored.
    # export HADOOP_USE_CLIENT_CLASSLOADER=true
    
    # HADOOP_CLIENT_CLASSLOADER_SYSTEM_CLASSES overrides the default definition of
    # system classes for the client classloader when HADOOP_USE_CLIENT_CLASSLOADER
    # is enabled. Names ending in '.' (period) are treated as package names, and
    # names starting with a '-' are treated as negative matches. For example,
    # export HADOOP_CLIENT_CLASSLOADER_SYSTEM_CLASSES="-org.apache.hadoop.UserClass,java.,javax.,org.apache.hadoop."
    
    # Enable optional, bundled Hadoop features
    # This is a comma delimited list.  It may NOT be overridden via .hadooprc
    # Entries may be added/removed as needed.
    # export HADOOP_OPTIONAL_TOOLS="hadoop-aliyun,hadoop-aws,hadoop-azure-datalake,hadoop-azure,hadoop-kafka,hadoop-openstack"
    
    ###
    # Options for remote shell connectivity
    ###
    
    # There are some optional components of hadoop that allow for
    # command and control of remote hosts.  For example,
    # start-dfs.sh will attempt to bring up all NNs, DNS, etc.
    
    # Options to pass to SSH when one of the "log into a host and
    # start/stop daemons" scripts is executed
    # export HADOOP_SSH_OPTS="-o BatchMode=yes -o StrictHostKeyChecking=no -o ConnectTimeout=10s"
    
    # The built-in ssh handler will limit itself to 10 simultaneous connections.
    # For pdsh users, this sets the fanout size ( -f )
    # Change this to increase/decrease as necessary.
    # export HADOOP_SSH_PARALLEL=10
    
    # Filename which contains all of the hosts for any remote execution
    # helper scripts # such as workers.sh, start-dfs.sh, etc.
    # export HADOOP_WORKERS="${HADOOP_CONF_DIR}/workers"
    
    ###
    # Options for all daemons
    ###
    #
    
    #
    # Many options may also be specified as Java properties.  It is
    # very common, and in many cases, desirable, to hard-set these
    # in daemon _OPTS variables.  Where applicable, the appropriate
    # Java property is also identified.  Note that many are re-used
    # or set differently in certain contexts (e.g., secure vs
    # non-secure)
    #
    
    # Where (primarily) daemon log files are stored.
    # ${HADOOP_HOME}/logs by default.
    # Java property: hadoop.log.dir
    # export HADOOP_LOG_DIR=${HADOOP_HOME}/logs
    
    # A string representing this instance of hadoop. $USER by default.
    # This is used in writing log and pid files, so keep that in mind!
    # Java property: hadoop.id.str
    # export HADOOP_IDENT_STRING=$USER
    
    # How many seconds to pause after stopping a daemon
    # export HADOOP_STOP_TIMEOUT=5
    
    # Where pid files are stored.  /tmp by default.
    # export HADOOP_PID_DIR=/tmp
    
    # Default log4j setting for interactive commands
    # Java property: hadoop.root.logger
    # export HADOOP_ROOT_LOGGER=INFO,console
    
    # Default log4j setting for daemons spawned explicitly by
    # --daemon option of hadoop, hdfs, mapred and yarn command.
    # Java property: hadoop.root.logger
    # export HADOOP_DAEMON_ROOT_LOGGER=INFO,RFA
    
    # Default log level and output location for security-related messages.
    # You will almost certainly want to change this on a per-daemon basis via
    # the Java property (i.e., -Dhadoop.security.logger=foo). (Note that the
    # defaults for the NN and 2NN override this by default.)
    # Java property: hadoop.security.logger
    # export HADOOP_SECURITY_LOGGER=INFO,NullAppender
    
    # Default process priority level
    # Note that sub-processes will also run at this level!
    # export HADOOP_NICENESS=0
    
    # Default name for the service level authorization file
    # Java property: hadoop.policy.file
    # export HADOOP_POLICYFILE="hadoop-policy.xml"
    
    #
    # NOTE: this is not used by default!  <-----
    # You can define variables right here and then re-use them later on.
    # For example, it is common to use the same garbage collection settings
    # for all the daemons.  So one could define:
    #
    # export HADOOP_GC_SETTINGS="-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps"
    #
    # .. and then use it as per the b option under the namenode.
    
    ###
    # Secure/privileged execution
    ###
    
    #
    # Out of the box, Hadoop uses jsvc from Apache Commons to launch daemons
    # on privileged ports.  This functionality can be replaced by providing
    # custom functions.  See hadoop-functions.sh for more information.
    #
    
    # The jsvc implementation to use. Jsvc is required to run secure datanodes
    # that bind to privileged ports to provide authentication of data transfer
    # protocol.  Jsvc is not required if SASL is configured for authentication of
    # data transfer protocol using non-privileged ports.
    # export JSVC_HOME=/usr/bin
    
    #
    # This directory contains pids for secure and privileged processes.
    #export HADOOP_SECURE_PID_DIR=${HADOOP_PID_DIR}
    
    #
    # This directory contains the logs for secure and privileged processes.
    # Java property: hadoop.log.dir
    # export HADOOP_SECURE_LOG=${HADOOP_LOG_DIR}
    
    #
    # When running a secure daemon, the default value of HADOOP_IDENT_STRING
    # ends up being a bit bogus.  Therefore, by default, the code will
    # replace HADOOP_IDENT_STRING with HADOOP_xx_SECURE_USER.  If one wants
    # to keep HADOOP_IDENT_STRING untouched, then uncomment this line.
    # export HADOOP_SECURE_IDENT_PRESERVE="true"
    
    ###
    # NameNode specific parameters
    ###
    
    # Default log level and output location for file system related change
    # messages. For non-namenode daemons, the Java property must be set in
    # the appropriate _OPTS if one wants something other than INFO,NullAppender
    # Java property: hdfs.audit.logger
    # export HDFS_AUDIT_LOGGER=INFO,NullAppender
    
    # Specify the JVM options to be used when starting the NameNode.
    # These options will be appended to the options specified as HADOOP_OPTS
    # and therefore may override any similar flags set in HADOOP_OPTS
    #
    # a) Set JMX options
    # export HDFS_NAMENODE_OPTS="-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=1026"
    #
    # b) Set garbage collection logs
    # export HDFS_NAMENODE_OPTS="${HADOOP_GC_SETTINGS} -Xloggc:${HADOOP_LOG_DIR}/gc-rm.log-$(date +'%Y%m%d%H%M')"
    #
    # c) ... or set them directly
    # export HDFS_NAMENODE_OPTS="-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -Xloggc:${HADOOP_LOG_DIR}/gc-rm.log-$(date +'%Y%m%d%H%M')"
    
    # this is the default:
    # export HDFS_NAMENODE_OPTS="-Dhadoop.security.logger=INFO,RFAS"
    
    ###
    # SecondaryNameNode specific parameters
    ###
    # Specify the JVM options to be used when starting the SecondaryNameNode.
    # These options will be appended to the options specified as HADOOP_OPTS
    # and therefore may override any similar flags set in HADOOP_OPTS
    #
    # This is the default:
    # export HDFS_SECONDARYNAMENODE_OPTS="-Dhadoop.security.logger=INFO,RFAS"
    
    ###
    # DataNode specific parameters
    ###
    # Specify the JVM options to be used when starting the DataNode.
    # These options will be appended to the options specified as HADOOP_OPTS
    # and therefore may override any similar flags set in HADOOP_OPTS
    #
    # This is the default:
    # export HDFS_DATANODE_OPTS="-Dhadoop.security.logger=ERROR,RFAS"
    
    # On secure datanodes, user to run the datanode as after dropping privileges.
    # This **MUST** be uncommented to enable secure HDFS if using privileged ports
    # to provide authentication of data transfer protocol.  This **MUST NOT** be
    # defined if SASL is configured for authentication of data transfer protocol
    # using non-privileged ports.
    # This will replace the hadoop.id.str Java property in secure mode.
    # export HDFS_DATANODE_SECURE_USER=hdfs
    
    # Supplemental options for secure datanodes
    # By default, Hadoop uses jsvc which needs to know to launch a
    # server jvm.
    # export HDFS_DATANODE_SECURE_EXTRA_OPTS="-jvm server"
    
    ###
    # NFS3 Gateway specific parameters
    ###
    # Specify the JVM options to be used when starting the NFS3 Gateway.
    # These options will be appended to the options specified as HADOOP_OPTS
    # and therefore may override any similar flags set in HADOOP_OPTS
    #
    # export HDFS_NFS3_OPTS=""
    
    # Specify the JVM options to be used when starting the Hadoop portmapper.
    # These options will be appended to the options specified as HADOOP_OPTS
    # and therefore may override any similar flags set in HADOOP_OPTS
    
    #
    # export HDFS_PORTMAP_OPTS="-Xmx512m"
    
    # Supplemental options for priviliged gateways
    # By default, Hadoop uses jsvc which needs to know to launch a
    # server jvm.
    # export HDFS_NFS3_SECURE_EXTRA_OPTS="-jvm server"
    
    # On privileged gateways, user to run the gateway as after dropping privileges
    # This will replace the hadoop.id.str Java property in secure mode.
    # export HDFS_NFS3_SECURE_USER=nfsserver
    
    ###
    # ZKFailoverController specific parameters
    ###
    # Specify the JVM options to be used when starting the ZKFailoverController.
    # These options will be appended to the options specified as HADOOP_OPTS
    # and therefore may override any similar flags set in HADOOP_OPTS
    #
    # export HDFS_ZKFC_OPTS=""
    
    ###
    # QuorumJournalNode specific parameters
    ###
    # Specify the JVM options to be used when starting the QuorumJournalNode.
    # These options will be appended to the options specified as HADOOP_OPTS
    # and therefore may override any similar flags set in HADOOP_OPTS
    #
    # export HDFS_JOURNALNODE_OPTS=""
    
    ###
    # HDFS Balancer specific parameters
    ###
    # Specify the JVM options to be used when starting the HDFS Balancer.
    # These options will be appended to the options specified as HADOOP_OPTS
    # and therefore may override any similar flags set in HADOOP_OPTS
    #
    # export HDFS_BALANCER_OPTS=""
    
    ###
    # HDFS Mover specific parameters
    ###
    # Specify the JVM options to be used when starting the HDFS Mover.
    # These options will be appended to the options specified as HADOOP_OPTS
    # and therefore may override any similar flags set in HADOOP_OPTS
    #
    # export HDFS_MOVER_OPTS=""
    
    ###
    # Router-based HDFS Federation specific parameters
    # Specify the JVM options to be used when starting the RBF Routers.
    # These options will be appended to the options specified as HADOOP_OPTS
    # and therefore may override any similar flags set in HADOOP_OPTS
    #
    # export HDFS_DFSROUTER_OPTS=""
    
    ###
    # HDFS StorageContainerManager specific parameters
    ###
    # Specify the JVM options to be used when starting the HDFS Storage Container Manager.
    # These options will be appended to the options specified as HADOOP_OPTS
    # and therefore may override any similar flags set in HADOOP_OPTS
    #
    # export HDFS_STORAGECONTAINERMANAGER_OPTS=""
    
    ###
    # Advanced Users Only!
    ###
    
    #
    # When building Hadoop, one can add the class paths to the commands
    # via this special env var:
    # export HADOOP_ENABLE_BUILD_PATHS="true"
    
    #
    # To prevent accidents, shell commands be (superficially) locked
    # to only allow certain users to execute certain subcommands.
    # It uses the format of (command)_(subcommand)_USER.
    #
    # For example, to limit who can execute the namenode command,
    # export HDFS_NAMENODE_USER=hdfs
    
    
    
    export HADOOP_LOG_DIR=/home/hadoop_repo/logs/hadoop
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
    • 273
    • 274
    • 275
    • 276
    • 277
    • 278
    • 279
    • 280
    • 281
    • 282
    • 283
    • 284
    • 285
    • 286
    • 287
    • 288
    • 289
    • 290
    • 291
    • 292
    • 293
    • 294
    • 295
    • 296
    • 297
    • 298
    • 299
    • 300
    • 301
    • 302
    • 303
    • 304
    • 305
    • 306
    • 307
    • 308
    • 309
    • 310
    • 311
    • 312
    • 313
    • 314
    • 315
    • 316
    • 317
    • 318
    • 319
    • 320
    • 321
    • 322
    • 323
    • 324
    • 325
    • 326
    • 327
    • 328
    • 329
    • 330
    • 331
    • 332
    • 333
    • 334
    • 335
    • 336
    • 337
    • 338
    • 339
    • 340
    • 341
    • 342
    • 343
    • 344
    • 345
    • 346
    • 347
    • 348
    • 349
    • 350
    • 351
    • 352
    • 353
    • 354
    • 355
    • 356
    • 357
    • 358
    • 359
    • 360
    • 361
    • 362
    • 363
    • 364
    • 365
    • 366
    • 367
    • 368
    • 369
    • 370
    • 371
    • 372
    • 373
    • 374
    • 375
    • 376
    • 377
    • 378
    • 379
    • 380
    • 381
    • 382
    • 383
    • 384
    • 385
    • 386
    • 387
    • 388
    • 389
    • 390
    • 391
    • 392
    • 393
    • 394
    • 395
    • 396
    • 397
    • 398
    • 399
    • 400
    • 401
    • 402
    • 403
    • 404
    • 405
    • 406
    • 407
    • 408
    • 409
    • 410
    • 411
    • 412
    • 413
    • 414
    • 415
    • 416
    • 417
    • 418
    • 419
    • 420
    • 421
    • 422
    • 423
    • 424
    • 425
    • 426
    • 427
    • 428
    • 429
    • 430
    • 431
    • 432
    • 433
    • 434
    • 435
    • 436
    • hdfs-site.xml
    
    
    
    
    
    
    <configuration>
    
    <property>
    	<name>dfs.replicationname>
    	<value>1value>
    property>
    
    
    configuration>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • mapred-site.xml
    
    
    
    
    
    
    <configuration>
    
    	<property>
    		<name>mapreduce.framework.namename>
    		<value>yarnvalue>
    	property>
    
    
    configuration>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • yarn-site.xml
    
    
    <configuration>
    
        <property>
            <name>yarn.nodemanager.aux-servicesname>
            <value>mapreduce_shufflevalue>
        property>
    
    
    
    
    
        <property>
            <name>yarn.nodemanager.env-whitelistname>
            <value>JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_MAPRED_HOMEvalue>
        property>
    configuration>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • workers
    # 可改可不改
    hadoop01
    
    
    • 1
    • 2
    • 3
    • 修改start-dfs.sh
    # 文件起始位置添加:
    HDFS_DATANODE_USER=root
    HDFS_DATANODE_SECURE_USER=hdfs
    HDFS_NAMENODE_USER=root
    HDFS_SECONDARYNAMENODE_USER=root
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 修改start-yarn.sh
    # 文起始位置添加:
    YARN_RESOURCEMANAGER_USER=root
    HADOOP_SECURE_DN_USER=yarn
    YARN_NODEMANAGER_USER=root
    
    • 1
    • 2
    • 3
    • 4
    • 修改stop-dfs.sh
    # 文起始位置添加:
    HDFS_DATA_NODE_USER=root
    HDFS_DATANODE_SECURE_USER=hdfs
    HDFS_NAMENODE_USER=root
    HDFS_SECONDARYNAMENODE_USER=root
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 修改stop-yarn.sh
    # 文起始位置添加:
    YARN_RESOURCEMANAGER_USER=root
    HADOOP_SECURE_DN_USER=yarn
    YARN_NODEMANAGER_USER=root
    
    • 1
    • 2
    • 3
    • 4

    启动Hadoop集群

    # 启动
    [root@hadoop01 hadoop-3.2.0]# sbin/start-all.sh
    # 查看 ,如下即为启动成功
    [root@hadoop01 hadoop]# jps
    1573 DataNode
    2053 ResourceManager
    1800 SecondaryNameNode
    2185 NodeManager
    2765 Jps
    1438 NameNode
    
    # 若有某个进程启动失败可以在hadoop-env.sh中配置的log文件地址进行查看
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    通过页面访问查看服务启动情况

    • dfs服务访问->http://192.168.52.100:9870/
    • yarn服务访问->http://192.168.52.100:8088/

    image-20240304155509071

    root

    
    - 修改stop-dfs.sh
    
    ```sh
    # 文起始位置添加:
    HDFS_DATA_NODE_USER=root
    HDFS_DATANODE_SECURE_USER=hdfs
    HDFS_NAMENODE_USER=root
    HDFS_SECONDARYNAMENODE_USER=root
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 修改stop-yarn.sh
    # 文起始位置添加:
    YARN_RESOURCEMANAGER_USER=root
    HADOOP_SECURE_DN_USER=yarn
    YARN_NODEMANAGER_USER=root
    
    • 1
    • 2
    • 3
    • 4

    启动Hadoop集群

    # 启动
    [root@hadoop01 hadoop-3.2.0]# sbin/start-all.sh
    # 查看 ,如下即为启动成功
    [root@hadoop01 hadoop]# jps
    1573 DataNode
    2053 ResourceManager
    1800 SecondaryNameNode
    2185 NodeManager
    2765 Jps
    1438 NameNode
    
    # 若有某个进程启动失败可以在hadoop-env.sh中配置的log文件地址进行查看
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    通过页面访问查看服务启动情况

    • dfs服务访问->http://192.168.52.100:9870/
    • yarn服务访问->http://192.168.52.100:8088/

    [外链图片转存中…(img-x4JTpD49-1709539380291)]

    image-20240304155528211

  • 相关阅读:
    java毕业设计饮品公司管理Mybatis+系统+数据库+调试部署
    Linux命令详解(12)-crontab命令
    Windows下安装Miniconda及配置和简单使用
    STM32H743的FDCAN使用方法(2):STM32CubeMX初始化代码修改
    一款纯前端类似excel的在线表格
    Ubuntu&win11双系统
    深入了解 JavaScript 内存泄漏
    Pycharm打开时一直加载中?解决办法来了~
    [Linux] DHCP网络
    xgboost early_stop_rounds是如何生效的?
  • 原文地址:https://blog.csdn.net/Grady00/article/details/136454911