三台虚拟机,centos6.5
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.59.130 m1
192.168.59.131 s1
192.168.59.132 s2
修改主机名
[root@m1 hadoop]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=m1
修改主机映射
[root@m1 hadoop]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.59.130 m1
192.168.59.131 s1
192.168.59.132 s2
ssh免密码登陆(注意! 要求每台机子互相都能ssh包括本机)
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub m2
安装jdk
http://www.cnblogs.com/xiaojf/p/6568426.html
安装hadoop2.7.3
解压,重命名
[root@m1 soft]# ll
total
drwxr-xr-x. root root Aug hadoop
drwxr-xr-x. root root Mar : jar
drwxr-xr-x. uucp Dec : jdk
drwxr-xr-x. root root Mar : kafka
drwxrwxr-x. Mar scala-2.11.
drwxr-xr-x. root root Mar : tmp
drwxr-xr-x. Aug zookeeper-3.4.
创建目录存放日志文件还要有数据文件
mkdir -p /usr/local/soft/tmp/hadoop/tmp
mkdir -p /usr/local/soft/tmp/hadoop/dfs/name
mkdir -p /usr/local/soft/tmp/hadoop/dfs/data
修改配置文件
[root@m1 soft]# cd /usr/local/soft/hadoop/etc/hadoop/
[root@m1 hadoop]# ll
total
-rw-r--r--. root root Aug capacity-scheduler.xml
-rw-r--r--. root root Aug configuration.xsl
-rw-r--r--. root root Aug container-executor.cfg
-rw-r--r--. root root Aug core-site.xml
-rw-r--r--. root root Aug hadoop-env.cmd
-rw-r--r--. root root Aug hadoop-env.sh
-rw-r--r--. root root Aug hadoop-metrics2.properties
-rw-r--r--. root root Aug hadoop-metrics.properties
-rw-r--r--. root root Aug hadoop-policy.xml
-rw-r--r--. root root Aug hdfs-site.xml
-rw-r--r--. root root Aug httpfs-env.sh
-rw-r--r--. root root Aug httpfs-log4j.properties
-rw-r--r--. root root Aug httpfs-signature.secret
-rw-r--r--. root root Aug httpfs-site.xml
-rw-r--r--. root root Aug kms-acls.xml
-rw-r--r--. root root Aug kms-env.sh
-rw-r--r--. root root Aug kms-log4j.properties
-rw-r--r--. root root Aug kms-site.xml
-rw-r--r--. root root Aug log4j.properties
-rw-r--r--. root root Aug mapred-env.cmd
-rw-r--r--. root root Aug mapred-env.sh
-rw-r--r--. root root Aug mapred-queues.xml.template
-rw-r--r--. root root Aug mapred-site.xml.template
-rw-r--r--. root root Aug slaves
-rw-r--r--. root root Aug ssl-client.xml.example
-rw-r--r--. root root Aug ssl-server.xml.example
-rw-r--r--. root root Aug yarn-env.cmd
-rw-r--r--. root root Aug yarn-env.sh
-rw-r--r--. root root Aug yarn-site.xml
yarn-env.sh
[root@m1 hadoop]# vi yarn-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. # The only required environment variable is JAVA_HOME. All others are # optional. When running a distributed configuration it is best to # set JAVA_HOME in this file, so that it is correctly defined on # remote nodes. # The java implementation to use. export JAVA_HOME=/usr/local/soft/jdk
slaves
[root@m1 hadoop]# vi slaves
s1
s2
core-site.xml
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://m1:9000</value> </property> <property> <name>io.file.buffer.size</name> <value></value> </property> <property> <name>hadoop.tmp.dir</name> <value>file:/usr/local/soft/tmp/hadoop/tmp</value> <description>Abase for other temporary directories.</description> </property> </configuration>
hdfs-site.xml
<configuration>
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>m1:9001</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/usr/hadoop/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/usr/hadoop/dfs/data</value>
</property>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
</configuration>
mapred-site.xml
<configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> <property> <name>mapreduce.jobhistory.address</name> <value>m1:</value> </property> <property> <name>mapreduce.jobhistory.webapp.address</name> <value>m1:</value> </property> </configuration>
yarn-site.xml
<configuration> <!-- Site specific YARN configuration properties --> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> <property> <name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name> <value>org.apache.hadoop.mapred.ShuffleHandler</value> </property> <property> <name>yarn.resourcemanager.address</name> <value>m1:</value> </property> <property> <name>yarn.resourcemanager.scheduler.address</name> <value>m1:</value> </property> <property> <name>yarn.resourcemanager.resource-tracker.address</name> <value>m1:</value> </property> <property> <name>yarn.resourcemanager.admin.address</name> <value>m1:</value> </property> <property> <name>yarn.resourcemanager.webapp.address</name> <value>m1:</value> </property> </configuration>
设置Hadoop环境变量
export HADOOP_HOME=/usr/local/soft/hadoop
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin
分发代码
[root@m1 soft]# scp -r hadoop root@s2:/usr/local/soft/
namenode format
[root@m1 soft]# hdfs namenode -format
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it. // :: INFO namenode.NameNode: STARTUP_MSG:
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG: host = m1/192.168.59.130
STARTUP_MSG: args = [-format]
STARTUP_MSG: version = 2.7.3
启动
[root@m1 soft]# start-all.sh
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
Starting namenodes on [m1]
m1: starting namenode, logging to /usr/local/soft/hadoop/logs/hadoop-root-namenode-m1.out
s1: starting datanode, logging to /usr/local/soft/hadoop/logs/hadoop-root-datanode-s1.out
s2: starting datanode, logging to /usr/local/soft/hadoop/logs/hadoop-root-datanode-s2.out
Starting secondary namenodes [master]
master: ssh: Could not resolve hostname master: Name or service not known
starting yarn daemons
starting resourcemanager, logging to /usr/local/soft/hadoop/logs/yarn-root-resourcemanager-m1.out
s1: starting nodemanager, logging to /usr/local/soft/hadoop/logs/yarn-root-nodemanager-s1.out
s2: starting nodemanager, logging to /usr/local/soft/hadoop/logs/yarn-root-nodemanager-s2.out
验证
[root@m1 soft]# hadoop dfs -ls /
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it. [root@m1 soft]# hadoop dfs -mkdir /xiaojf
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it. [root@m1 soft]# hadoop dfs -ls /
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it. Found items
drwxr-xr-x - root supergroup -- : /xiaojf
完成