Java安装的是/usr/lib/jvm/jdk1.7.0_72
1.下载,
2.使用sudo创建jvm文件夹,并且cp
3.解压tar–zxvf
4.sudochown -R castle:castle hadoop-2.6.0修改权限
5.配置环境变量
~/.profile中也可以在~/.bashrc中添加
#setjava env
exportJAVA_HOME=/usr/lib/jvm/jdk1.7.0_72
exportJRE_HOME=${JAVA_HOME}/jre
exportCLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
exportPATH=${JAVA_HOME}/bin:$PATH
#sethadoop env
exportHADOOP_HOME=/usr/local/hadoop/hadoop-2.6.0
exportPATH=$PATH:$HADOOP_HOME/bin
source .profile 不需要注销登陆时文件生效
hadoop/usr/local/hadoop/hadoop-2.6.0
前面的步骤与上面的很相似的
1.配置etc/hadoop/hadoop-env.sh
#set to the root of your Java installation
exportJAVA_HOME=/usr/lib/jvm/jdk1.7.0_72
#hadoop
exportHADOOP_PREFIX=/usr/local/hadoop/hadoop-2.6.0
2.伪分布配置
etc/hadoop/core-site.xml:
<property>
<name>hadoop.tmp.dir</name>
<value>/usr/local/hadoop/hadoop-2.6.0/tmp</value>
<description>Abase for other
temporary directories.
</description>
</property>
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property></configuration>etc/hadoop/hdfs-site.xml:
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/usr/local/hadoop/hadoop-2.6.0/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/usr/local/hadoop/hadoop-2.6.0/dfs/data</value>
</property>
<property>
<name>dfs.permissions</name>
<value>false</value>
////这个属性节点是为了防止后面eclopse存在拒绝读写设置的
</property>
</configuration>
mapred-site.xml
<!--mapreduce parameter -->
<!--新框架支持第三方MapReduce开发框架以支持如SmartTalk/DGSG等非Yarn架构,注意通常情况下这个配置的值都设置为Yarn,
如果没有配置这项,那么提交的Yarn job只会运行在locale模式,而不是分布式模式。-->
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
注意:旧版的mapreduce在这里面是要配置以下内容的:
<property>
<name>mapred.job.tracker</name>
<value>:9001</value>
</property>
新框架中已改为Yarn-site.xml中的resouceManager及nodeManager具体配置项,新框架中历史job的查询已从Jobtracker剥离,归入单独的mapreduce.jobtracker.jobhistory相关配置,
所以这里不需要配置这个选项。在yarn-site.xml配置相关属性即可。
yarn-site.xml
<configuration> <property>
<name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property></configuration>
其他的修改文章
3.配置SSH无密码登陆
如果ubuntu没有安装ssh相关的软件
$
sudo apt-get install ssh$
sudo apt-get install rsyncSetuppassphraseless ssh
Nowcheck that you can ssh to the localhost without a passphrase:
$
ssh localhostIfyou cannot ssh to localhost without a passphrase, execute thefollowing commands:
$
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
$
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keysssh-keygen
代表产生密钥ssh
localhost还是出现问题
无法连接ssh:
connect to host localhost port 22: Connection refused从网上得知解决办法1.首先查看是否有sshd进程
ps
-e | grep ssh2.没有的话启动
/etc/init.d/ssh
-start 如果启动不了的话,需要安装3.安装
sudo
apt-get install openssh-server4.重新启动5.查看可以了1695
? 00:00:00 ssh-agent12407
? 00:00:00 sshdcastle@castle-X550VC:~$
ssh localhost
The
authenticity of host 'localhost (127.0.0.1)' can't be established.ECDSA
key fingerprint is ae:23:4a:95:bc:37:dd:1a:5b:48:4f:66:e2:87:12:1c.Are
you sure you want to continue connecting (yes/no)? yPlease
type 'yes' or 'no': yesWarning:
Permanently added 'localhost' (ECDSA) to the list of known hosts.Welcome
to Ubuntu 14.04 LTS (GNU/Linux 3.13.0-43-generic x86_64)
*
Documentation: https://help.ubuntu.com/The
programs included with the Ubuntu system are free software;the
exact distribution terms for each program are described in theindividual
files in /usr/share/doc/*/copyright.Ubuntu
comes with ABSOLUTELY NO WARRANTY, to the extent permitted byapplicable
law. $
bin/hdfs namenode -formatbin/hdfs namenode -format 只需要执行一次即可。如果执行两次的话,
每次namenode
format会重新创建一个namenodeId
/usr/local/hadoop/hadoop2.6.0/tmp/dfs/name
会被清空;而datanode不清空。
会出现:datanode的clusterID
和
namenode的clusterID
不匹配
出现这种问题的解决办法是:修改.../tmp/dfs/name下的namenodeId.
为什么我在hadoop0.20.2中每一次都执行了format?我想是因为我每一次format都不成功的原因吧。hdfs dfs -mkdir /user 在hdfs中创建文件夹。$
sbin/start-dfs.sh使用jps命令查看2855
org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
11127 DataNode
10975 NameNode
11432 Jps
11284 SecondaryNameNode
表示成功了。
$
sbin/start-yarn.sh$
sbin/stop-dfs.sh
$
sbin/stop-yarn.sh如果在eclipse运行helloword的时候,控制台没有打印出运行的过程。那么就将hadoop安装文件夹中的etc/hadoop/log4j.properties复制到eclipse项目中的src文件夹中即可。15/01/2410:30:12 WARN util.NativeCodeLoader: Unable to load native-hadooplibrary for your platform... using builtin-java classes whereapplicable
15/01/2410:30:13 INFO Configuration.deprecation: session.id is deprecated.Instead, use dfs.metrics.session-id
15/01/2410:30:13 INFO jvm.JvmMetrics: Initializing JVM Metrics withprocessName=JobTracker, sessionId=
15/01/2410:30:13 WARN mapreduce.JobSubmitter: No job jar file set. Userclasses may not be found. See Job or Job#setJar(String).
15/01/2410:30:13 INFO input.FileInputFormat: Total input paths to process : 2
15/01/2410:30:14 INFO mapreduce.JobSubmitter: number of splits:2
15/01/2410:30:14 INFO mapreduce.JobSubmitter: Submitting tokens for job:job_local632218717_0001
15/01/2410:30:14 INFO mapreduce.Job: The url to track the job::8080/
15/01/2410:30:14 INFO mapreduce.Job: Running job: job_local632218717_0001
15/01/2410:30:14 INFO mapred.LocalJobRunner: OutputCommitter set in confignull
15/01/2410:30:14 INFO mapred.LocalJobRunner: OutputCommitter isorg.apache.hadoop.mapreduce.lib.output.FileOutputCommitter
15/01/2410:30:15 INFO mapred.LocalJobRunner: Waiting for map tasks
15/01/2410:30:15 INFO mapred.LocalJobRunner: Starting task:attempt_local632218717_0001_m_000000_0
15/01/2410:30:15 INFO mapred.Task: Using ResourceCalculatorProcessTree : [ ]
15/01/2410:30:15 INFO mapred.MapTask: Processing split:hdfs://localhost:9000/user/castle/wordcount_input/input1:0+32
15/01/2410:30:15 INFO mapred.MapTask: (EQUATOR) 0 kvi 26214396(104857584)
15/01/2410:30:15 INFO mapred.MapTask: mapreduce.task.io.sort.mb: 100
15/01/2410:30:15 INFO mapred.MapTask: soft limit at 83886080
15/01/2410:30:15 INFO mapred.MapTask: bufstart = 0; bufvoid = 104857600
15/01/2410:30:15 INFO mapred.MapTask: kvstart = 26214396; length = 6553600
15/01/2410:30:15 INFO mapred.MapTask: Map output collector class =org.apache.hadoop.mapred.MapTask$MapOutputBuffer
15/01/2410:30:15 INFO mapred.LocalJobRunner:
15/01/2410:30:15 INFO mapred.MapTask: Starting flush of map output
15/01/2410:30:15 INFO mapred.MapTask: Spilling map output
15/01/2410:30:15 INFO mapred.MapTask: bufstart = 0; bufend = 52; bufvoid =104857600
15/01/2410:30:15 INFO mapred.MapTask: kvstart = 26214396(104857584); kvend =26214380(104857520); length = 17/6553600
15/01/2410:30:15 INFO mapred.MapTask: Finished spill 0
15/01/2410:30:15 INFO mapred.Task:Task:attempt_local632218717_0001_m_000000_0 is done. And is in theprocess of committing
15/01/2410:30:15 INFO mapred.LocalJobRunner: map
15/01/2410:30:15 INFO mapred.Task: Task'attempt_local632218717_0001_m_000000_0' done.
15/01/2410:30:15 INFO mapred.LocalJobRunner: Finishing task:attempt_local632218717_0001_m_000000_0
15/01/2410:30:15 INFO mapred.LocalJobRunner: Starting task:attempt_local632218717_0001_m_000001_0
15/01/2410:30:15 INFO mapred.Task: Using ResourceCalculatorProcessTree : [ ]
15/01/2410:30:15 INFO mapred.MapTask: Processing split:hdfs://localhost:9000/user/castle/wordcount_input/input2:0+29
15/01/2410:30:15 INFO mapred.MapTask: (EQUATOR) 0 kvi 26214396(104857584)
15/01/2410:30:15 INFO mapred.MapTask: mapreduce.task.io.sort.mb: 100
15/01/2410:30:15 INFO mapred.MapTask: soft limit at 83886080
15/01/2410:30:15 INFO mapred.MapTask: bufstart = 0; bufvoid = 104857600
15/01/2410:30:15 INFO mapred.MapTask: kvstart = 26214396; length = 6553600
15/01/2410:30:15 INFO mapred.MapTask: Map output collector class =org.apache.hadoop.mapred.MapTask$MapOutputBuffer
15/01/2410:30:15 INFO mapred.LocalJobRunner:
15/01/2410:30:15 INFO mapred.MapTask: Starting flush of map output
15/01/2410:30:15 INFO mapred.MapTask: Spilling map output
15/01/2410:30:15 INFO mapred.MapTask: bufstart = 0; bufend = 49; bufvoid =104857600
15/01/2410:30:15 INFO mapred.MapTask: kvstart = 26214396(104857584); kvend =26214380(104857520); length = 17/6553600
15/01/2410:30:15 INFO mapred.MapTask: Finished spill 0
15/01/2410:30:15 INFO mapred.Task:Task:attempt_local632218717_0001_m_000001_0 is done. And is in theprocess of committing
15/01/2410:30:15 INFO mapred.LocalJobRunner: map
15/01/2410:30:15 INFO mapred.Task: Task'attempt_local632218717_0001_m_000001_0' done.
15/01/2410:30:15 INFO mapred.LocalJobRunner: Finishing task:attempt_local632218717_0001_m_000001_0
15/01/2410:30:15 INFO mapred.LocalJobRunner: map task executor complete.
15/01/2410:30:15 INFO mapred.LocalJobRunner: Waiting for reduce tasks
15/01/2410:30:15 INFO mapred.LocalJobRunner: Starting task:attempt_local632218717_0001_r_000000_0
15/01/2410:30:15 INFO mapred.Task: Using ResourceCalculatorProcessTree : [ ]
15/01/2410:30:15 INFO mapred.ReduceTask: Using ShuffleConsumerPlugin:org.apache.hadoop.mapreduce.task.reduce.Shuffle@158e338a
15/01/2410:30:15 INFO reduce.MergeManagerImpl: MergerManager:memoryLimit=626471744, maxSingleShuffleLimit=156617936,mergeThreshold=413471360, ioSortFactor=10,memToMemMergeOutputsThreshold=10
15/01/2410:30:15 INFO reduce.EventFetcher:attempt_local632218717_0001_r_000000_0 Thread started: EventFetcherfor fetching Map Completion Events
15/01/2410:30:15 INFO mapreduce.Job: Job job_local632218717_0001 running inuber mode : false
15/01/2410:30:15 INFO mapreduce.Job: map 100% reduce 0%
15/01/2410:30:16 INFO reduce.LocalFetcher: localfetcher#1 about to shuffleoutput of map attempt_local632218717_0001_m_000000_0 decomp: 40 len:44 to MEMORY
15/01/2410:30:16 INFO reduce.InMemoryMapOutput: Read 40 bytes from map-outputfor attempt_local632218717_0001_m_000000_0
15/01/2410:30:16 INFO reduce.MergeManagerImpl: closeInMemoryFile ->map-output of size: 40, inMemoryMapOutputs.size() -> 1,commitMemory -> 0, usedMemory ->40
15/01/2410:30:16 INFO reduce.LocalFetcher: localfetcher#1 about to shuffleoutput of map attempt_local632218717_0001_m_000001_0 decomp: 51 len:55 to MEMORY
15/01/2410:30:16 INFO reduce.InMemoryMapOutput: Read 51 bytes from map-outputfor attempt_local632218717_0001_m_000001_0
15/01/2410:30:16 INFO reduce.MergeManagerImpl: closeInMemoryFile ->map-output of size: 51, inMemoryMapOutputs.size() -> 2,commitMemory -> 40, usedMemory ->91
15/01/2410:30:16 INFO reduce.EventFetcher: EventFetcher is interrupted..Returning
15/01/2410:30:16 INFO mapred.LocalJobRunner: 2 / 2 copied.
15/01/2410:30:16 INFO reduce.MergeManagerImpl: finalMerge called with 2in-memory map-outputs and 0 on-disk map-outputs
15/01/2410:30:16 INFO mapred.Merger: Merging 2 sorted segments
15/01/2410:30:16 INFO mapred.Merger: Down to the last merge-pass, with 2segments left of total size: 71 bytes
15/01/2410:30:16 INFO reduce.MergeManagerImpl: Merged 2 segments, 91 bytes todisk to satisfy reduce memory limit
15/01/2410:30:16 INFO reduce.MergeManagerImpl: Merging 1 files, 93 bytes fromdisk
15/01/2410:30:16 INFO reduce.MergeManagerImpl: Merging 0 segments, 0 bytesfrom memory into reduce
15/01/2410:30:16 INFO mapred.Merger: Merging 1 sorted segments
15/01/2410:30:16 INFO mapred.Merger: Down to the last merge-pass, with 1segments left of total size: 79 bytes
15/01/2410:30:16 INFO mapred.LocalJobRunner: 2 / 2 copied.
15/01/2410:30:16 INFO Configuration.deprecation: mapred.skip.on isdeprecated. Instead, use mapreduce.job.skiprecords
15/01/2410:30:16 INFO mapred.Task:Task:attempt_local632218717_0001_r_000000_0 is done. And is in theprocess of committing
15/01/2410:30:16 INFO mapred.LocalJobRunner: 2 / 2 copied.
15/01/2410:30:16 INFO mapred.Task: Taskattempt_local632218717_0001_r_000000_0 is allowed to commit now