分享

windows和cygwin下hadoop安装配置及问题解决

在Windows下利用cygwin仿unix环境安装配置Hadoop。

子猴也是刚接触到hadoop,对其的配置第一次按照网上的一些说明配置成功了,但有些东西感到不是很清晰,所以又重新把整个过程跑了一遍并记录下来,也是想对整个过程有个清晰的脉络,不正确之处请指教。

1、  所需软件

1.1、Cygwin(截至到目前最新版本是2.685)

下载地址:http://www.cygwin.com/setup.exe

1.2、JDK 1.6.x

1.3、hadoop-0.20.1

下载地址:http://apache.freelamp.com/hadoop/core/hadoop-0.20.1/hadoop-0.20.1.tar.gz

2、  安装

2.1、Cygwin安装说明见文章:http://www.zihou.me/2010/02/19/1506/

补充:cygwin的bash是无法复制粘贴的,很不方便,所以可采用putty,下载地址是:

http://www.linuxboy.net/linux/rc/puttycyg.zip ,将puttycyg.zip解压后的三个exe文件放到Cygwin安装目录HOME_PATH下bin目录下,然后修改HOME_PATH下的Cygwin.bat文件,建议用记事本打开,然后将bash –login –i注释掉,在前面加rem,也就是rem bash –login –i,或者:: bash –login –i,加入 start putty -cygterm – 即可。

这样一来就可以复制粘贴了,但注意的是默认的根目录是Cygwin的HOME_PATH,如果要切换到其他主目录,但如果你想要进入到其他根目录,但如果你想要进入到其他根目录,需要通过系统根目录,子猴这里的是/cygdrive,比如要进入到e盘,则为/cygdrive/e。

2.2、JDK的安装省略了

2.3、hadoop-0.20.1安装

将hadoop-0.20.1.tar.gz解压,解压后的目录如hadoop-0.20.1,假设是放在E盘:

E:\hadoop-0.20.1,修改conf/hadoop-env.sh文件,将export JAVA_HOME的值修改为你机上的jdk安装目录,比如/cygdrive/d/tools/jdk1.6.0_03,/cygdrive是Cygwin安装成功后系统的根目录

3、  安装和配置ssh

3.1、安装

在Cygwin的根目录下分别运行:

  1. $ chmod +r /etc/group
  2. $ chmod +r /etc/passwd
  3. $ chmod +rwx /var
  4. $ ssh-host-config
  5. *** Info: Generating /etc/ssh_host_key
  6. *** Info: Generating /etc/ssh_host_rsa_key
  7. *** Info: Generating /etc/ssh_host_dsa_key
  8. *** Info: Creating default /etc/ssh_config file
  9. *** Info: Creating default /etc/sshd_config file
  10. *** Info: Privilege separation is set to yes by default since OpenSSH 3.3.
  11. *** Info: However, this requires a non-privileged account called 'sshd'.
  12. *** Info: For more info on privilege separation read /usr/share/doc/openssh/README.privsep.
  13. *** Query: Should privilege separation be used? (yes/no) yes
  14. *** Info: Note that creating a new user requires that the current account have
  15. *** Info: Administrator privileges.  Should this script attempt to create a
  16. *** Query: new local account 'sshd'? (yes/no) yes
  17. *** Info: Updating /etc/sshd_config file
  18. *** Info: Added ssh to C:\WINDOWS\system32\driversc\services
  19. *** Info: Creating default /etc/inetd.d/sshd-inetd file
  20. *** Info: Updated /etc/inetd.d/sshd-inetd
  21. *** Warning: The following functions require administrator privileges!
  22. *** Query: Do you want to install sshd as a service?
  23. *** Query: (Say "no" if it is already installed as a service) (yes/no) yes
  24. *** Query: Enter the value of CYGWIN for the daemon: [] cygwin
  25. (注:此处输入的cygwin可以是任意的)
  26. *** Info: The sshd service has been installed under the LocalSystem
  27. *** Info: account (also known as SYSTEM). To start the service now, call
  28. *** Info: `net start sshd' or `cygrunsrv -S sshd'.  Otherwise, it
  29. *** Info: will start automatically after the next reboot.
  30. *** Info: Host configuration finished. Have fun!
复制代码
在询问yes/no的地方,统一输入yes,sshd就安装好了。3.2配置3.2.1、启动sshd服务net start sshdCYGWIN sshd 服务正在启动CYGWIN sshd 服务已经启动成功3.2.2、$ ssh localhost试着连接本机看看,注意,如果在没有启动sshd服务,这个连接肯定是失败的!如果没问题,会出现下面一些内容:
  1. The authenticity of host 'localhost (127.0.0.1)' can't be established.
  2. RSA key fingerprint is 08:03:20:43:48:39:29:66:6e:c5:61:ba:77:b2:2f:55.
  3. Are you sure you want to continue connecting (yes/no)? yes
  4. Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
  5. zihou@localhost's password:
复制代码
会提示输入你机子的登录密码,输入无误后,会出现文本图形,类似于欢迎的提示:The Hippo says: Welcome to3.2.3、建立ssh的通道
  1. $ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
  2. Generating public/private dsa key pair.
  3. Your identification has been saved in /home/zihou/.ssh/id_dsa.
  4. Your public key has been saved in /home/zihou/.ssh/id_dsa.pub.
  5. The key fingerprint is:
  6. 6d:64:8e:a6:38:73:ab:c5:ce:71:cd:df:a1:ca:63:54 zihou@PC-04101515
  7. The key's randomart image is:
  8. +--[ DSA 1024]----+
  9. |                 |
  10. |                 |
  11. |          o      |
  12. |         *  E    |
  13. |        S +.     |
  14. |     o o +.      |
  15. |    + * ..o   .  |
  16. |     B + .o. o . |
  17. |    ..+  .ooo .  |
  18. +-----------------+
复制代码
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys再执行遍$ ssh localhost看看,如果没有问题,就说明sshd已经配置好了。4、  配置hadoop编辑conf/hadoop-site.xml加入以下内容:
  1. <configuration>
  2. <property>
  3. <name>fs.default.name</name>
  4. <value>localhost:9000</value>
  5. </property>
  6. <property>
  7. <name>mapred.job.tracker</name>
  8. <value>localhost:9001</value>
  9. </property>
  10. <property>
  11. <name>dfs.replication</name>
  12. <value>1</value>
  13. </property>
  14. </configuration>
复制代码
5、  运行hadoop进入到E:\hadoop-0.20.1,在cygwin下的操作如:/cygdrive/e/ hadoop-0.20.1,执行:bin/hadoop namenode –format格式化一个新的分布式文件系统,提示信息如下:
10/02/19 17:32:26 WARN conf.Configuration: DEPRECATED: hadoop-site.xml found in the classpath.
Usage of hadoop-site.xml is deprecated. Instead use core-site.xml, mapred-site.xml and hdfs-site.xml
to override properties of core-default.xml, mapred-default.xml and hdfs-default.xml respectively
(这段我还不是很清楚,我用的最新版本)10/02/19 17:32:26 INFO namenode.NameNode: STARTUP_MSG:/************************************************************STARTUP_MSG: Starting NameNodeSTARTUP_MSG:   host = PC-04101515/192.168.0.14STARTUP_MSG:   args = [-format]STARTUP_MSG:   version = 0.20.1STARTUP_MSG:   build =http://svn.apache.org/repos/asf/hadoop/common/tags/release-0.20.1-rc1 -r 810220; compiled by ‘oom’ on Tue Sep  1 20:55:56 UTC 2009************************************************************/10/02/19 17:32:27 INFO namenode.FSNamesystem:fsOwner=zihou,None,root,Administrators,Users10/02/19 17:32:27 INFO namenode.FSNamesystem: supergroup=supergroup10/02/19 17:32:27 INFO namenode.FSNamesystem: isPermissionEnabled=true10/02/19 17:32:28 INFO common.Storage: Image file of size 102 saved in 0 seconds.10/02/19 17:32:28 INFO common.Storage: Storage directory \tmp\hadoop-SYSTEM\dfs\name has been successfully formatted.10/02/19 17:32:28 INFO namenode.NameNode: SHUTDOWN_MSG:/************************************************************SHUTDOWN_MSG: Shutting down NameNode at PC-04101515/192.168.0.14************************************************************/
6、  启动hadoop守护进程
  1. $ bin/start-all.sh
  2. starting namenode, logging to
  3. /cygdrive/e/hadoop-0.20.1/bin/../logs/hadoop-zihou-namenode-PC-04101515.out
  4. localhost: datanode running as process 5200. Stop it first.
  5. localhost: secondarynamenode running as process 1664. Stop it first.
  6. starting jobtracker, logging to
  7. /cygdrive/e/hadoop-0.20.1/bin/../logs/hadoop-zihou-jobtracker-PC-04101515.out
  8. localhost: starting tasktracker, logging to
  9. /cygdrive/e/hadoop-0.20.1/bin/../logs/hadoop-zihou-tasktracker-PC-04101515.out
复制代码
(注:如果你第一次启动,提示信息或许会与上面有所不同,我为了写这篇文章,重新执行了一遍)7、  测试单机模式的操作方法下面的实例将已解压的 conf 目录拷贝作为输入,查找并显示匹配给定正则表达式的条目。输出写入到指定的output目录。(注:根目录是hadoop的目录)$ mkdir input$ cp conf/*.xml input$ bin/hadoop jar hadoop-*-examples.jar grep input output ‘dfs[a-z.]+’$ cat output/*通过执行$ bin/hadoop dfs –ls来看是否将*.xml文件拷贝到input中了,执行后结果如下:Found 1 itemsdrwxr-xr-x   – zihou supergroup          0 2010-02-19 17:44 /user/zihou/input表示已经拷贝过去了。在伪分布式模式上运行bin/hadoop jar hadoop-*-examples.jar grep input output ‘dfs[a-z.]+’如果没有错误的话,会给出一堆信息,如:
10/02/19 14:56:07 WARN conf.Configuration: DEPRECATED: hadoop-site.xml found in the classpath. Usage of hadoop-site.xml is deprecated. Instead use core-site.xml, mapred-site.xml and hdfs-site.xml to override properties of core-default.xml, mapred-default.xml and hdfs-default.xml respectively10/02/19 14:56:08 INFO jvm.JvmMetrics: Initializing JVM Metrics with processName=JobTracker, sessionId=10/02/19 14:56:09 INFO mapred.FileInputFormat: Total input paths to process : 510/02/19 14:56:10 INFO mapred.JobClient: Running job: job_local_000110/02/19 14:56:10 INFO mapred.FileInputFormat: Total input paths to process : 510/02/19 14:56:10 INFO mapred.MapTask: numReduceTasks: 110/02/19 14:56:10 INFO mapred.MapTask: io.sort.mb = 10010/02/19 14:56:10 INFO mapred.MapTask: data buffer = 79691776/9961472010/02/19 14:56:10 INFO mapred.MapTask: record buffer = 262144/327680。。。。。。。。。。。。。。。
这样,hadoop就成功配置了!说明:Hadoop中文文档地址:http://hadoop.apache.org/common/docs/r0.18.2/cn/快速安装说明手册:http://hadoop.apache.org/common/docs/r0.18.2/cn/quickstart.htmlHadoop简介:Hadoop是一个开放源代码的分布式文件系统,属于Apache中的一个项目,所谓分布式文件系统(Distributed File System),指的是具有执行远程文件存取的能力,并以透明方式对分布在网络上的文件进行管理和存取,客户端访问的时候不需要知道文件真正存放在哪里。 Hadoop最初是包含在Nutch中的,后来,Nutch中实现的NDFS和MapReduce代码剥离出来成立了一个新的开源项目,这就是 Hadoop。问题:安装了cygwin,但没有cygdrive这个文件夹?、解答:查看硬盘是看不到这个文件夹的,但如果你通过DOS界面操作的话就有这个文件夹,这个文件夹相当于是Linux系统下的文件夹,在Windows环境下是看不到的。但在Dos界面中,如果你安装好了cygwin的话,就相当于Linux环境,所以是可以看到这个文件夹的。


本帖被以下淘专辑推荐:

已有(2)人评论

跳转到指定楼层
小熊007 发表于 2014-7-15 16:47:24
回复

使用道具 举报

stark_summer 发表于 2015-2-12 15:51:44
对于那些不想再linux系统捣鼓的人 可以使用下,但有的时候会有各种问题的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条