换了macbook pro之后,要重新安装hadoop,但是mac上的jdk跟windows上的不同,导致折腾了挺久的,现在分享出来,希望对大家有用。

一:下载jdk

选择最新版本下载,地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html

安装完成之后,打开终端,输入java -version ,出现类似如下说明安装成功。

java version "1.8.0"

Java(TM) SE Runtime Environment (build 1.8.0-b132)

Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

二:配置hadoop

下载hadoop,自己可到官网下载稳定版本,不用下载最新的,因为最新的可能不稳定。

配置hadoop 里面conf文件夹四个文件(hadoop-env.sh,core-site.xml,mapred-site.xml,hdfs-site.xml)

下载完hadoop之后,把它解压到你想存放的文件夹,然后进入hadoop的conf目录

1.配置hadopp-env.sh

打开该文件之后找到

#export JAVA_HOME=
#export HADOOP_HEAPSIZE=2000
#export HADOOP_OPTS=-server

修改为:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home

export HADOOP_HEAPSIZE=2000

#export HADOOP_OPTS=-server

export HADOOP_OPTS="-Djava.security.krb5.realm=OX.AC.UK -Djava.security.krb5.kdc=kdc0.ox.ac.uk:kdc1.ox.ac.uk"

即去掉前面的解释符#

特别注意:

JAVA_HOME=的配置是类似上面的目录,百度上有些文章写到是在终端输入whereis java出现的目录,这是不对的。

因为mac的jdk安装在根目录的Library文件夹下面。

2.配置core-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/Users/username/Documents/apache/hadoop-2.6.0/hadoop_tmp</value>
<description>A base for other temporary directories.</description>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
<property>
<name>mapred.job.tracker</name>
<value>hdfs://localhost:9001</value>
</property>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>

3.配置mapred-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
</configuration>

4.配置hdfs-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>

三:配置ssh,无密码登录

1.mac 上已经ssh了,在终端输入ssh-keygen -t rsa命令,碰到需要输入密码的直接按enter健即可。出现如下成功

Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/jia/.ssh/id_rsa.
Your public key has been saved in /Users/jia/.ssh/id_rsa.pub.
The key fingerprint is:
d4:85:aa:83:ae:db:50:48:0c:5b:dd:80:bb:fa:26:a7 jia@JIAS-MacBook-Pro.local
The key's randomart image is:
+--[ RSA 2048]----+
|. .o.o .. |
| =. . . ... |
|. o. ... |
| ... .. |
| .... .S |
| ... o |
| ... . |
|o oo. |
|E*+o. |
+-----------------+

在终端输入cd .ssh 进入.ssh目录,输入命令。

cp id_rsa.pub authorized_keys

即可。

2.在mac上输入

ssh localhost

如果出现

ssh: connect to host localhost port : Connection refused

表示当前用户没有权限。这个可能是系统为安全考虑,默认设置的。

更改设置如下:进入system preference --> sharing --> 勾选remote login,并设置allow access for all users。再次输入“ssh localhost",再输入密码并确认之后,可以看到ssh成功

如果出现

No such file or directory...

1.启动sshd服务:
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist

2.查看服务的启动,筛选:
sudo launchctl list | grep ssh

四:配置环境变量

suodo vim /etc/profile

添加:

export HADOOP_HOME=/Users/username/Documents/apache/hadoop-2.6.0
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin

五:启动hadoop

1.进入hadoop文件夹,用如下命令格式化:

bin/hadoop namenode -format

出现如下,说明成功

/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG: host = JIAS-MacBook-Pro.local/192.168.1.3
STARTUP_MSG: args = [-format]
STARTUP_MSG: version = 0.20.2
STARTUP_MSG: build = https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20 -r 911707; compiled by 'chrisdo' on Fri Feb 19 08:07:34 UTC 2010
************************************************************/
Re-format filesystem in /tmp/hadoop-jia/dfs/name ? (Y or N) Y
14/07/14 13:55:17 INFO namenode.FSNamesystem: fsOwner=jia,staff,everyone,localaccounts,_appserverusr,admin,_appserveradm,_lpadmin,com.apple.sharepoint.group.1,_appstore,_lpoperator,_developer,com.apple.access_screensharing,com.apple.access_ssh
14/07/14 13:55:17 INFO namenode.FSNamesystem: supergroup=supergroup
14/07/14 13:55:17 INFO namenode.FSNamesystem: isPermissionEnabled=true
14/07/14 13:55:17 INFO common.Storage: Image file of size 93 saved in 0 seconds.
14/07/14 13:55:17 INFO common.Storage: Storage directory /tmp/hadoop-jia/dfs/name has been successfully formatted.
14/07/14 13:55:17 INFO namenode.NameNode: SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at JIAS-MacBook-Pro.local/192.168.1.3
************************************************************/

2.启动hadoop守护进程

bin/start-all.sh

3.停止hadoop守护进程

bin/stop-all.sh

六:错误分析

1.之前运行时总出现如下错误

cat: Documents/hadoop-0.20./conf/slaves: No such file or directory
cat: Documents/hadoop-0.20./conf/masters: No such file or directory

其实这是在配置mahout的环境时加上了下面这句环境变量导致的错误

export HADOOP_CONF_DIR=Documents/hadoop-0.20./conf

之前我电脑的环境变量为(在终端输入命令:open /etc/  , 找的profile文件,打开,配置好环境变量在覆盖之前的)

export HADOOP_HOME=Documents/hadoop-0.20.
export MAHOUT_HOME=Documents/hadoop-0.20./mahout-distribution-0.9
export MAVEN_HOME=Documents/apache-maven-3.2. export PATH=$PATH:$HADOOP_HOME/bin:$MAHOUT_HOME/bin:$MAVEN_HOME/bin export HADOOP_CONF_DIR=Documents/hadoop-0.20./conf
export MAHOUT_CONF_DIR=Documents/hadoop-0.20./mahout-distribution-0.9/conf export classpath=$classpath:$MAHOUT_HOME/lib:$HADOOP_CONF_DIR:$MAHOUT_CONF_DIR

把环境配置改为如下就可以正常运行了

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home
export HADOOP_HOME=Documents/hadoop-0.20.0
export MAHOUT_HOME=Documents/hadoop-0.20.2/mahout-distribution-0.9
export MAVEN_HOME=Documents/apache-maven-3.2.2

export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$MAVEN_HOME/bin:$MAHOUT_HOME/bin

export MAHOUT_CONF_DIR=Documents/hadoop-0.20.2/mahout-distribution-0.9/conf

export classpath=$classpath:$JAVA_HOME/lib:$MAHOUT_HOME/lib:$MAHOUT_CONF_DIR

红色部分做好加进去

既去掉

export HADOOP_CONF_DIR=Documents/hadoop-0.20./conf

注意:

修改/etc/profile上的环境配置文件之后,用如下命令使其生效

source /etc/profile

2.如果需要自己编译hadoop源码的话,编译过程可能会出现org.apache.maven.plugin.MojoExecutionException的错误

 Failed to execute goal org.apache.hadoop:hadoop-maven-plugins:2.6.2:protoc (compile-protoc) on project hadoop-common: org.apache.maven.plugin.MojoExecutionException: 'protoc --version' did not return a version -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.hadoop:hadoop-maven-plugins:2.6.2:protoc (compile-protoc) on project hadoop-common: org.apache.maven.plugin.MojoExecutionException: 'protoc --version' did not return a version
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: org.apache.maven.plugin.MojoExecutionException: 'protoc --version' did not return a version
at org.apache.hadoop.maven.plugin.protoc.ProtocMojo.execute(ProtocMojo.java:105)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: org.apache.maven.plugin.MojoExecutionException: 'protoc --version' did not return a version
at org.apache.hadoop.maven.plugin.protoc.ProtocMojo.execute(ProtocMojo.java:68)
... 22 more

下载protobuf-2.4.1.jar

http://vdisk.weibo.com/s/tYlk6JrNUYTY

安装protobuf

tar xzf protobuf-2.4.1.tar.gz
cd protobuf-2.4.1
./configure
make
sudo make install
sudo ldconfig

在重新编译

 3.namenode没启动

解决方法:先可视化之后再启动

bin/hadoop namenode -format

在mac上安装hadoop伪分布式的更多相关文章

  1. Ubuntu 安装hadoop 伪分布式

    一.安装JDK  : http://www.cnblogs.com/E-star/p/4437788.html 二.配置SSH免密码登录1.安装所需软件        sudo apt-get ins ...

  2. centos安装hadoop(伪分布式)

    在本机上装的CentOS 5.5 虚拟机, 软件准备:jdk 1.6 U26 hadoop:hadoop-0.20.203.tar.gz ssh检查配置 [root@localhost ~]# ssh ...

  3. 安装hadoop伪分布式

    修改hosts cat /etc/hosts 127.0.0.1 mo.don.com 创建用户 useradd hadoop passwd hadoop sudo授权 visudo hadoop A ...

  4. hadoop伪分布式安装之Linux环境准备

    Hadoop伪分布式安装之Linux环境准备 一.软件版本 VMare Workstation Pro 14 CentOS 7 32/64位 二.实现Linux服务器联网功能 网络适配器双击选择VMn ...

  5. ubantu18.04下Hadoop安装与伪分布式配置

    1  下载 下载地址:http://mirror.bit.edu.cn/apache/hadoop/common/stable2/ 2 解压 将文件解压到 /usr/local/hadoop cd ~ ...

  6. java大数据最全课程学习笔记(1)--Hadoop简介和安装及伪分布式

    Hadoop简介和安装及伪分布式 大数据概念 大数据概论 大数据(Big Data): 指无法在一定时间范围内用常规软件工具进行捕捉,管理和处理的数据集合,是需要新处理模式才能具有更强的决策力,洞察发 ...

  7. 初学者值得拥有【Hadoop伪分布式模式安装部署】

    目录 1.了解单机模式与伪分布模式有何区别 2.安装好单机模式的Hadoop 3.修改Hadoop配置文件---五个核心配置文件 (1)hadoop-env.sh 1.到hadoop目录中 ​ 2.修 ...

  8. 在Linux(Centos7)系统上对进行Hadoop分布式配置以及运行Hadoop伪分布式实例

    在Linux(Centos7)系统上对进行Hadoop分布式配置以及运行Hadoop伪分布式实例                                                     ...

  9. Hadoop学习---CentOS中hadoop伪分布式集群安装

    注意:此次搭建是在ssh无密码配置.jdk环境已经配置好的情况下进行的 可以参考: Hadoop完全分布式安装教程 CentOS环境下搭建hadoop伪分布式集群 1.更改主机名 执行命令:vi  / ...

随机推荐

  1. 素数个数统计——Eratosthenes筛法 [LeetCode 204]

    1- 问题描述 Count the number of prime numbers less than a non-negative number, n 2- 算法思想 给出要筛数值的范围 $n$,找 ...

  2. Basic Vlan Concepts

    1.  Vlan Benefit ·To reduce CPU overhead on each device by reducing the number of devices that recei ...

  3. UserLogin

    DAL: IUserDAL namespace Dal { /// <summary> /// This interface is defined for user functions. ...

  4. Configuring My Site in SharePoint 2010

    Configuring the User Profile Service in SharePoint 2010 http://sharepointgeorge.com/2010/configuring ...

  5. crawler spec

    使用说明 0.写在前面 1.本程序完成的抓取网页并保存其文件的工作. 2.目前的版本还需将工程文件导入eclipse中运行. 3.加载主类MyCrawler生成可执行文件. 4.程序主界面: 1 准备 ...

  6. Week1 Team Homework #2 Introduction of team member with photos

    小组成员介绍 组长:黄剑锟       11061164 组员:顾泽鹏        11061160 组员:周辰光         11061154 组员:龚少波        11061167 组 ...

  7. Careercup - Facebook面试题 - 5671785349513216

    2014-05-02 01:05 题目链接 原题: bool anaStrStr (string needle, string haystack) { } Write a function that ...

  8. 关于json的知识整理

    一.什么是json JSON:JavaScript 对象表示法(JavaScript Object Notation). JSON 是存储和交换文本信息的语法.类似 XML,但JSON 比 XML 更 ...

  9. Vbox下linux虚拟机根分区扩容

    前言 使用一段时间VBox中的linux后可能会显示根分区空间不足的情况,需要扩容. 通过查阅相关资料,VBox中linux扩容主要有两种办法:通过lvm扩容和通过gparted扩容 LVM条件:VB ...

  10. 学习Linux第一天

    1.简介: 记住这个名字:Linus Torvals 系统组成:Linux内核,Shell, 文件系统,实时程序 Tips:在系统启动过程中,使用Alt+F2组合键,可以查看Ubuntu启动的详细过程 ...