0. 安装JDK

参考网上教程在OSX下安装jdk

1. 下载及安装hadoop

a) 下载地址:

http://hadoop.apache.org

b) 配置ssh环境

在terminal里面输入: ssh localhost

如果有错误提示信息,表示当前用户没有权限。这个多半是系统为安全考虑,默认设置的。

更改设置如下:进入system preference --> sharing --> 勾选remote login,并设置allow access for all users。

再次输入“ssh localhost",再输入密码并确认之后,可以看到ssh成功。

c) ssh免登陆配置

命令行输入:

ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa

ssh-keygen表示生成秘钥;-t表示秘钥类型;-P用于提供密语;-f指定生成的秘钥文件。

这个命令在”~/.ssh/“文件夹下创建两个文件id_dsa和id_dsa.pub,是ssh的一对儿私钥和公钥。

接下来,将公钥追加到授权的key中去,输入:

cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

********************************************************************************

免密码登录localhost

1. ssh-keygen -t rsa Press enter for each line 提示输入直接按回车就好

2. cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

3. chmod og-wx ~/.ssh/authorized_keys

测试 ssh localhost如果仍然提示要输入密码,那么可以vim ~/.ssh/config文件,添加以下代码。

Host localhost
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa

测试 ssh localhost,不再提示需要输入密码。

********************************************************************************

d) 设置环境变量

在实际启动Hadoop之前,有三个文件需要进行配置。

但在这之前,我们需要在我们的bash_profile中配置如下几个配置

命令行输入:

open ~/.bash_profile;

# hadoop
export HADOOP_HOME=/Users/YourUserName/Documents/Dev/hadoop-2.7.3
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin

e) 配置hadoop-env.sh

在${HADOOP_HOME}/etc/hadoop目录下,找到hadoop-env.sh,打开编辑确认如下设置是否正确:

export JAVA_HOME=${JAVA_HOME}

export HADOOP_HEAPSIZE=2000(去掉注释)

export HADOOP_OPTS="-Djava.security.krb5.realm=OX.AC.UK -Djava.security.krb5.kdc=kdc0.ox.ac.uk:kdc1.ox.ac.uk"(去掉注释)

f) 配置core-site.xml——指定了NameNode的主机名与端口

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed 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. See accompanying LICENSE file.
--> <!-- Put site-specific property overrides in this file. --> <configuration>
<property>
<name>/Users/YourUserName/Documents/Dev/hadoop-2.7.3/hadoop-${user.name}</name>
<value>hdfs://localhost:9000</value>
<description>A base for other temporary directories.</description>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:8020</value>
</property>
</configuration>

g) 配置hdfs-site.xml——指定了HDFS的默认参数副本数,因为仅运行在一个节点上,所以这里的副本数为1

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed 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. See accompanying LICENSE file.
--> <!-- Put site-specific property overrides in this file. --> <configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>

h) 配置mapred-site.xml——指定了JobTracker的主机名与端口

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed 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. See accompanying LICENSE file.
--> <!-- Put site-specific property overrides in this file. --> <configuration>
<property>
<name>mapred.job.tracker</name>
<value>hdfs://localhost:9001</value>
</property>
<property>
<name>mapred.tasktracker.map.tasks.maximum</name>
<value>2</value>
</property>
<property>
<name>mapred.tasktracker.reduce.tasks.maximum</name>
<value>2</value>
</property>
</configuration>

i) 安装HDFS

经过以上的配置,就可以进行HDFS的安装了

命令行输入:

cd $HADOOP_HOME/bin

hadoop namenode -format

如果出现下图, 说明你的HDFS已经安装成功了

j) 启动Hadoop

cd ${HADOOP_HOME}/sbin

start-dfs.sh
start-yarn.sh

k) 验证hadoop

如果在启动过程中没有发生任何错误

启动完成之后,在命令行输入: jps

如果结果如下:

3761 DataNode
4100 Jps
3878 SecondaryNameNode
3673 NameNode
4074 NodeManager
3323 ResourceManager

以上几个节点都打印出来,那么恭喜你,你已经成功安装和启动hadoop了!

最后,我们可以在浏览器通过http的方式进行验证

浏览器输入:

http://localhost:8088/

结果如下:

浏览器输入:

http://localhost:50070/

结果如下:

2. 常见错误解决

hadoop namenode不能启动

org.apache.hadoop.hdfs.server.common.InconsistentFSStateException: Directory /tmp/hadoop-javoft/dfs/name is in an inconsistent state: storage di rectory does not exist or is not accessible.

原因在于core-site.xml
你必须覆盖hadoop.tmp.dir为你自己的hadoop目录
...
hadoop.tmp.dir
/home/javoft/Documents/hadoop/hadoop-${user.name}

Hadoop - Mac OSX下配置和启动hadoop以及常见错误解决的更多相关文章

  1. Mac OSX 下配置 LNMP开发环境

    不久前负责了一个项目需要配置PHP7的开发环境,因为之前所有的项目用的是PHP5的,所以研究了这些东西,但是很遗憾,电脑出了问题,不得已重装了系统,然后你懂得...什么都没有了,要重新来过.. 虽然本 ...

  2. Linux环境下配置及启动Hadoop(伪集群)

    1.下载tag软件包后,我习惯放到software文件夹下,并建立app文件夹2.通过tar -zxvf hadoop-2.6.0-cdh5.7.0.tar.gz -C ~/app/ 命令解压到app ...

  3. 日常工作问题解决:配置NTP服务器以及一些常见错误解决

    1.配置NTP服务端 环境:redhat 6.5 服务器主机名 ip地址 说明 server 192.168.57.20 NTP服务端 client 192.168.57.21 NTP客户端 搭建说明 ...

  4. Mac osx 下配置ANT

    一般安装过程如下: 1:sudo sh (会提示你输入当前用户的密码) 2:cp apache-ant.1.8.2-bin.zip /usr/local 3:cd /usr/local 4:unzip ...

  5. Mac OSX 下用 Homebrew 安装 MongoDB 并配置到 WebStorm 中

    1. 安装 Ruby OSX 操作系统内置 Ruby,但如果没有 Ruby,则需先输入以下命令安装能够进行多版本ruby环境安装.管理和切换的命令行工具 RVM. 1.1 安装 RVM 打开终端输入以 ...

  6. Mac OSX下Sublime Text配置使用Ctags实现代码跳转

    1. 先用brew工具安装ctags,安装路径在/user/local/bin The default ctags executable in OSX does not support recursi ...

  7. 在Mac OSX下使用ssh建立隧道(在Windows下建立隧道可以使用putty,其间会用到ppk文件)

    在Windows下建立隧道可以使用putty,其间会用到ppk文件.在Mac OSX下,同样的功能可以用ssh命令实现.具体是: ssh -D 8088 -Nf user@ip -i myppk.ss ...

  8. MAC OSX 下安装 CTAGS

    由于本子跟风换了骚货MBP,因而开发要迁移到MAC OSX下,mac os 下的ctags不一样,所以需要自己编译一个   Lion内置了ctags,但是不我所需要,因此得在网上去弄,最新的版本是 5 ...

  9. 在Mac OSX下安装Microsoft Calibri字体

    参考: Where can I find default Microsoft fonts Calibri, Cambria? 在Mac OSX下安装Microsoft Calibri字体 1.下载: ...

随机推荐

  1. 面向对象、类与对象、成员与局部变量、封装、private、构造函数、this、static、extends、super、final、abstract、interface、多态、内部类、异常【5】

    若有不正之处,请多多谅解并欢迎批评指正,不甚感激. 请尊重作者劳动成果: 本文原创作者:pipi-changing本文原创出处:http://www.cnblogs.com/pipi-changing ...

  2. 斯坦福第三课:线性代数回顾(Linear Algebra Review)

    3.1  矩阵和向量 3.2  加法和标量乘法 3.3  矩阵向量乘法 3.4  矩阵乘法 3.5  矩阵乘法的性质 3.6  逆.转置 3.1  矩阵和向量 如图:这个是 4×2 矩阵,即 4 行  ...

  3. 文件和目录:access函数

    access函数是按照实际用户ID和实际组ID进行访问权限测试的: #include <unistd.h> int access( const char *pathname, int mo ...

  4. 套题 bestcoder 84

    A题:Aaronson 静下心来观察就会发现1.如果m大于等于n的位数,那么n直接写成二进制形式就是最优解形式2.如果m小于n的位数,那么贪心地使得高位尽可能地多消掉n的值,因为高位少写一个数就意味着 ...

  5. JAVA的初始化顺序(续)

    JAVA在创建对象之前,是先加载类,然后再创建对象. 加载类时,会加载静态的成员变量,包括父类的静态成员变量[先加载父类,再加载子类]. 一.  静态成员变量的初始化 package com.cnbl ...

  6. Microsoft.Extensions.Options支持什么样的配置类?

    在.Net core中,微软放弃了笨重基于XML的.Config配置文件(好吧,像我这种咸鱼早都忘了如何自己写一个Section了). 现在主推新的高度可扩展的配置文件(参见此处) 对于新的配置系统, ...

  7. 《JavaScript语言精粹》之函数化

    写在前面 看到好多书评和读书笔记都说<JavaScript语言精粹>字字珠玑,名不虚传..当然,要看得懂才行 其实个人认为函数化部分不是很好,举的例子不是十分恰当,之前看不懂是因为被成功误 ...

  8. MongoDB 基础命令使用学习记录

    1. 启动 mongod 几个常用命令说明:--dbpath : 指定数据库相关文件的存储目录 --logpath: 指定日志文件的存储目录 --port: 指定数据库的端口,默认是 27017 -- ...

  9. 深入理解java虚拟机【Java Class类文件结构】

    Java语言从诞生之时就宣称一次编写,到处运行的跨平台特性,其实现原理是源码文件并没有直接编译成机器指令,而是编译成Java虚拟机可以识别和运行的字节码文件(Class类文件,*.class),字节码 ...

  10. 秀才提笔忘了字:javascript使用requestAnimationFrame实现动画

    requestAnimationFrame优于setTimeout/setInterval的地方在于它是由浏览器专门为动画提供的API,在运行时浏览器会自动优化方法的调用,并且如果页面不是激活状态下的 ...