阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Ubuntu12.04 Hadoop单机搭建

401次阅读
没有评论

共计 11028 个字符,预计需要花费 28 分钟才能阅读完成。

一直都听别人说 Hadoop, 还是蛮神秘的,不过看介绍才知道这个是整分布式的。现在分布式,大数据都是挺火的,不得不让人去凑个热闹呀。

先说下我的环境:

www.linuxidc.com@linuxidc-virtual:~/Downloads$ uname -a
Linux linuxidc-virtual 3.11.0-17-generic #31~precise1-Ubuntu SMP Tue Feb 4 21:29:23 UTC 2014 i686 i686 i386 GNU/Linux

准备工作,Hadoop 是 Apache 的产品, 你懂的, 这个当然和 Java 相关了, 所以你得有一个 Java 编译器才行, 不管你是 OpenJDK, 还是 OraceJDK, 你都要整一个不是.

参考:http://www.linuxidc.com/Linux/2014-03/97462.htm

好了,进入正题。

1, 我们得去 Hadoop 官网去下载, 我这里选择最新的 hadoop-2.3.0 版本, 其他版本记得甄别一下, 毕竟测试环境, 当然用最新的好了.

解压压缩包, 复制到制定的位置.

www.linuxidc.com@linuxidc-virtual:~/Downloads$ tar -xvf hadoop-2.3.0.tar.gz

www.linuxidc.com@linuxidc-virtual:~/Downloads$ sudo cp -r hadoop-2.3.0 /usr/local/hadoop/

2, 为啥, 我要说版本问题呢, 因为, 这个配置文件的位置, 之前的版本和现在版本有很大差异的.

当然版本配置文件地址在

www.linuxidc.com@linuxidc-virtual:/usr/local/hadoop/etc/hadoop$ ls -al
total 128
drwxr-xr-x 2 linuxidc linuxidc  4096 Feb 27 15:09 .
drwxr-xr-x 3 linuxidc linuxidc  4096 Feb 27 15:09 ..
-rw-r–r– 1 linuxidc linuxidc  3589 Feb 27 15:09 capacity-scheduler.xml
-rw-r–r– 1 linuxidc linuxidc  1335 Feb 27 15:09 configuration.xsl
-rw-r–r– 1 linuxidc linuxidc  318 Feb 27 15:09 container-executor.cfg
-rw-r–r– 1 linuxidc linuxidc  860 Feb 27 15:23 core-site.xml
-rw-r–r– 1 linuxidc linuxidc  3589 Feb 27 15:09 hadoop-env.cmd
-rw-r–r– 1 linuxidc linuxidc  3402 Feb 27 15:42 hadoop-env.sh
-rw-r–r– 1 linuxidc linuxidc  1774 Feb 27 15:09 hadoop-metrics2.properties
-rw-r–r– 1 linuxidc linuxidc  2490 Feb 27 15:09 hadoop-metrics.properties
-rw-r–r– 1 linuxidc linuxidc  9257 Feb 27 15:09 hadoop-policy.xml
-rw-r–r– 1 linuxidc linuxidc  984 Feb 27 15:27 hdfs-site.xml
-rw-r–r– 1 linuxidc linuxidc  1449 Feb 27 15:09 httpfs-env.sh
-rw-r–r– 1 linuxidc linuxidc  1657 Feb 27 15:09 httpfs-log4j.properties
-rw-r–r– 1 linuxidc linuxidc    21 Feb 27 15:09 httpfs-signature.secret
-rw-r–r– 1 linuxidc linuxidc  620 Feb 27 15:09 httpfs-site.xml
-rw-r–r– 1 linuxidc linuxidc 11169 Feb 27 15:09 log4j.properties
-rw-r–r– 1 linuxidc linuxidc  918 Feb 27 15:09 mapred-env.cmd
-rw-r–r– 1 linuxidc linuxidc  1383 Feb 27 15:09 mapred-env.sh
-rw-r–r– 1 linuxidc linuxidc  4113 Feb 27 15:09 mapred-queues.xml.template
-rw-r–r– 1 linuxidc linuxidc  758 Feb 27 15:09 mapred-site.xml.template
-rw-r–r– 1 linuxidc linuxidc    10 Feb 27 15:09 slaves
-rw-r–r– 1 linuxidc linuxidc  2316 Feb 27 15:09 ssl-client.xml.example
-rw-r–r– 1 linuxidc linuxidc  2268 Feb 27 15:09 ssl-server.xml.example
-rw-r–r– 1 linuxidc linuxidc  2178 Feb 27 15:09 yarn-env.cmd
-rw-r–r– 1 linuxidc linuxidc  4084 Feb 27 15:09 yarn-env.sh
-rw-r–r– 1 linuxidc linuxidc  772 Feb 27 15:30 yarn-site.xml

而我们要修改的配置文件有

hadoop-env.sh 找到 JAVA_HOME, 把它修改成这样.

# The java implementation to use.

2 export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_45

core-site.xml

www.linuxidc.com@linuxidc-virtual:/usr/local/hadoop/etc/hadoop$ cat core-site.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<?xml-stylesheet type=”text/xsl” href=”https://www.linuxidc.com/Linux/2014-03/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>fs.defaultFS</name>
<value>hdfs://127.0.0.1:9000</value>
</property>
</configuration>

hdfs-site.xml

www.linuxidc.com@linuxidc-virtual:/usr/local/hadoop/etc/hadoop$ cat hdfs-site.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<?xml-stylesheet type=”text/xsl” href=”https://www.linuxidc.com/Linux/2014-03/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.namenode.name.dir</name>
<value>file:/usr/local/hadoop/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/usr/local/hadoop/dfs/data</value>
</property>
</configuration>

相关阅读

Ubuntu 13.04 上搭建 Hadoop 环境 http://www.linuxidc.com/Linux/2013-06/86106.htm

Ubuntu 12.10 +Hadoop 1.2.1 版本集群配置 http://www.linuxidc.com/Linux/2013-09/90600.htm

Ubuntu 上搭建 Hadoop 环境(单机模式 + 伪分布模式)http://www.linuxidc.com/Linux/2013-01/77681.htm

Ubuntu 下 Hadoop 环境的配置 http://www.linuxidc.com/Linux/2012-11/74539.htm

单机版搭建 Hadoop 环境图文教程详解 http://www.linuxidc.com/Linux/2012-02/53927.htm

搭建 Hadoop 环境(在 Winodws 环境下用虚拟机虚拟两个 Ubuntu 系统进行搭建)http://www.linuxidc.com/Linux/2011-12/48894.htm

yarn-site.xml(这个就是新增加的,代替以前 mapred-site.xml)

www.linuxidc.com@linuxidc-virtual:/usr/local/Hadoop/etc/hadoop$ cat yarn-site.xml
<?xml version=”1.0″?>
<!–
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.
–>
<configuration>

<!– Site specific YARN configuration properties –>

<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>

</configuration>

3, 更改 Hadoop 的权限, 这个是必须的, 因为启动的时候, 系统会叫你输入当前启动用户密码,我们现在都是在 root 用户上操作,这个可不成。

view sourceprint?1 www.linuxidc.com@linuxidc-virtual:/usr/local/hadoop/etc/hadoop$ sudo chown -R linuxidc:linuxidc /usr/local/hadoop/

4, 现在基本配置就完成了, 现在就可以启动一下看看模样了.

进入 Hadoop 主目录 bin 下, 初始化 namenode.

1 www.linuxidc.com@linuxidc-virtual:/usr/local/hadoop/bin$ ./hadoop namenode -format

在 sbin 下启动 namenode 和 datanone.

www.linuxidc.com@linuxidc-virtual:/usr/local/hadoop/sbin$ ./hadoop-daemon.sh start namenode

2

3 www.linuxidc.com@linuxidc-virtual:/usr/local/hadoop/sbin$ ./hadoop-daemon.sh start datanode

启动 Hadoop.

www.linuxidc.com@linuxidc-virtual:/usr/local/hadoop/sbin$ ./start-all.sh

上图:

访问 http://172.16.80.228:50070/.

有开就关闭嘛.

www.linuxidc.com@linuxidc-virtual:/usr/local/hadoop/sbin$ ./stop-all.sh

Ubuntu12.04 Hadoop 单机搭建

更多 Hadoop 相关信息见 Hadoop 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=13

一直都听别人说 Hadoop, 还是蛮神秘的,不过看介绍才知道这个是整分布式的。现在分布式,大数据都是挺火的,不得不让人去凑个热闹呀。

先说下我的环境:

www.linuxidc.com@linuxidc-virtual:~/Downloads$ uname -a
Linux linuxidc-virtual 3.11.0-17-generic #31~precise1-Ubuntu SMP Tue Feb 4 21:29:23 UTC 2014 i686 i686 i386 GNU/Linux

准备工作,Hadoop 是 Apache 的产品, 你懂的, 这个当然和 Java 相关了, 所以你得有一个 Java 编译器才行, 不管你是 OpenJDK, 还是 OraceJDK, 你都要整一个不是.

参考:http://www.linuxidc.com/Linux/2014-03/97462.htm

好了,进入正题。

1, 我们得去 Hadoop 官网去下载, 我这里选择最新的 hadoop-2.3.0 版本, 其他版本记得甄别一下, 毕竟测试环境, 当然用最新的好了.

解压压缩包, 复制到制定的位置.

www.linuxidc.com@linuxidc-virtual:~/Downloads$ tar -xvf hadoop-2.3.0.tar.gz

www.linuxidc.com@linuxidc-virtual:~/Downloads$ sudo cp -r hadoop-2.3.0 /usr/local/hadoop/

2, 为啥, 我要说版本问题呢, 因为, 这个配置文件的位置, 之前的版本和现在版本有很大差异的.

当然版本配置文件地址在

www.linuxidc.com@linuxidc-virtual:/usr/local/hadoop/etc/hadoop$ ls -al
total 128
drwxr-xr-x 2 linuxidc linuxidc  4096 Feb 27 15:09 .
drwxr-xr-x 3 linuxidc linuxidc  4096 Feb 27 15:09 ..
-rw-r–r– 1 linuxidc linuxidc  3589 Feb 27 15:09 capacity-scheduler.xml
-rw-r–r– 1 linuxidc linuxidc  1335 Feb 27 15:09 configuration.xsl
-rw-r–r– 1 linuxidc linuxidc  318 Feb 27 15:09 container-executor.cfg
-rw-r–r– 1 linuxidc linuxidc  860 Feb 27 15:23 core-site.xml
-rw-r–r– 1 linuxidc linuxidc  3589 Feb 27 15:09 hadoop-env.cmd
-rw-r–r– 1 linuxidc linuxidc  3402 Feb 27 15:42 hadoop-env.sh
-rw-r–r– 1 linuxidc linuxidc  1774 Feb 27 15:09 hadoop-metrics2.properties
-rw-r–r– 1 linuxidc linuxidc  2490 Feb 27 15:09 hadoop-metrics.properties
-rw-r–r– 1 linuxidc linuxidc  9257 Feb 27 15:09 hadoop-policy.xml
-rw-r–r– 1 linuxidc linuxidc  984 Feb 27 15:27 hdfs-site.xml
-rw-r–r– 1 linuxidc linuxidc  1449 Feb 27 15:09 httpfs-env.sh
-rw-r–r– 1 linuxidc linuxidc  1657 Feb 27 15:09 httpfs-log4j.properties
-rw-r–r– 1 linuxidc linuxidc    21 Feb 27 15:09 httpfs-signature.secret
-rw-r–r– 1 linuxidc linuxidc  620 Feb 27 15:09 httpfs-site.xml
-rw-r–r– 1 linuxidc linuxidc 11169 Feb 27 15:09 log4j.properties
-rw-r–r– 1 linuxidc linuxidc  918 Feb 27 15:09 mapred-env.cmd
-rw-r–r– 1 linuxidc linuxidc  1383 Feb 27 15:09 mapred-env.sh
-rw-r–r– 1 linuxidc linuxidc  4113 Feb 27 15:09 mapred-queues.xml.template
-rw-r–r– 1 linuxidc linuxidc  758 Feb 27 15:09 mapred-site.xml.template
-rw-r–r– 1 linuxidc linuxidc    10 Feb 27 15:09 slaves
-rw-r–r– 1 linuxidc linuxidc  2316 Feb 27 15:09 ssl-client.xml.example
-rw-r–r– 1 linuxidc linuxidc  2268 Feb 27 15:09 ssl-server.xml.example
-rw-r–r– 1 linuxidc linuxidc  2178 Feb 27 15:09 yarn-env.cmd
-rw-r–r– 1 linuxidc linuxidc  4084 Feb 27 15:09 yarn-env.sh
-rw-r–r– 1 linuxidc linuxidc  772 Feb 27 15:30 yarn-site.xml

而我们要修改的配置文件有

hadoop-env.sh 找到 JAVA_HOME, 把它修改成这样.

# The java implementation to use.

2 export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_45

core-site.xml

www.linuxidc.com@linuxidc-virtual:/usr/local/hadoop/etc/hadoop$ cat core-site.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<?xml-stylesheet type=”text/xsl” href=”https://www.linuxidc.com/Linux/2014-03/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>fs.defaultFS</name>
<value>hdfs://127.0.0.1:9000</value>
</property>
</configuration>

hdfs-site.xml

www.linuxidc.com@linuxidc-virtual:/usr/local/hadoop/etc/hadoop$ cat hdfs-site.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<?xml-stylesheet type=”text/xsl” href=”https://www.linuxidc.com/Linux/2014-03/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.namenode.name.dir</name>
<value>file:/usr/local/hadoop/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/usr/local/hadoop/dfs/data</value>
</property>
</configuration>

相关阅读

Ubuntu 13.04 上搭建 Hadoop 环境 http://www.linuxidc.com/Linux/2013-06/86106.htm

Ubuntu 12.10 +Hadoop 1.2.1 版本集群配置 http://www.linuxidc.com/Linux/2013-09/90600.htm

Ubuntu 上搭建 Hadoop 环境(单机模式 + 伪分布模式)http://www.linuxidc.com/Linux/2013-01/77681.htm

Ubuntu 下 Hadoop 环境的配置 http://www.linuxidc.com/Linux/2012-11/74539.htm

单机版搭建 Hadoop 环境图文教程详解 http://www.linuxidc.com/Linux/2012-02/53927.htm

搭建 Hadoop 环境(在 Winodws 环境下用虚拟机虚拟两个 Ubuntu 系统进行搭建)http://www.linuxidc.com/Linux/2011-12/48894.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计11028字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中

星哥玩云

星哥玩云
星哥玩云
分享互联网知识
用户数
4
文章数
19351
评论数
4
阅读量
7991856
文章搜索
热门文章
星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛 NAS-6:抖音视频同步工具,视频下载自动下载保存 前言 各位玩 NAS 的朋友好,我是星哥!...
星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛 NAS-3:安装飞牛 NAS 后的很有必要的操作 前言 如果你已经有了飞牛 NAS 系统,之前...
我把用了20年的360安全卫士卸载了

我把用了20年的360安全卫士卸载了

我把用了 20 年的 360 安全卫士卸载了 是的,正如标题你看到的。 原因 偷摸安装自家的软件 莫名其妙安装...
再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见 zabbix!轻量级自建服务器监控神器在 Linux 的完整部署指南 在日常运维中,服务器监控是绕不开的...
飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛 NAS 中安装 Navidrome 音乐文件中文标签乱码问题解决、安装 FntermX 终端 问题背景 ...
阿里云CDN
阿里云CDN-提高用户访问的响应速度和成功率
随机文章
小白也能看懂:什么是云服务器?腾讯云 vs 阿里云对比

小白也能看懂:什么是云服务器?腾讯云 vs 阿里云对比

小白也能看懂:什么是云服务器?腾讯云 vs 阿里云对比 星哥玩云,带你从小白到上云高手。今天咱们就来聊聊——什...
颠覆 AI 开发效率!开源工具一站式管控 30+大模型ApiKey,秘钥付费+负载均衡全搞定

颠覆 AI 开发效率!开源工具一站式管控 30+大模型ApiKey,秘钥付费+负载均衡全搞定

  颠覆 AI 开发效率!开源工具一站式管控 30+ 大模型 ApiKey,秘钥付费 + 负载均衡全...
星哥带你玩飞牛NAS-2:飞牛配置RAID磁盘阵列

星哥带你玩飞牛NAS-2:飞牛配置RAID磁盘阵列

星哥带你玩飞牛 NAS-2:飞牛配置 RAID 磁盘阵列 前言 大家好,我是星哥之前星哥写了《星哥带你玩飞牛 ...
星哥带你玩飞牛NAS-8:有了NAS你可以干什么?软件汇总篇

星哥带你玩飞牛NAS-8:有了NAS你可以干什么?软件汇总篇

星哥带你玩飞牛 NAS-8:有了 NAS 你可以干什么?软件汇总篇 前言 哈喽各位玩友!我是是星哥,不少朋友私...
恶意团伙利用 PHP-FPM 未授权访问漏洞发起大规模攻击

恶意团伙利用 PHP-FPM 未授权访问漏洞发起大规模攻击

恶意团伙利用 PHP-FPM 未授权访问漏洞发起大规模攻击 PHP-FPM(FastCGl Process M...

免费图片视频管理工具让灵感库告别混乱

一言一句话
-「
手气不错
星哥带你玩飞牛 NAS-10:备份微信聊天记录、数据到你的NAS中!

星哥带你玩飞牛 NAS-10:备份微信聊天记录、数据到你的NAS中!

星哥带你玩飞牛 NAS-10:备份微信聊天记录、数据到你的 NAS 中! 大家对「数据安全感」的需求越来越高 ...
星哥带你玩飞牛NAS-16:飞牛云NAS换桌面,fndesk图标管理神器上线!

星哥带你玩飞牛NAS-16:飞牛云NAS换桌面,fndesk图标管理神器上线!

  星哥带你玩飞牛 NAS-16:飞牛云 NAS 换桌面,fndesk 图标管理神器上线! 引言 哈...
4盘位、4K输出、J3455、遥控,NAS硬件入门性价比之王

4盘位、4K输出、J3455、遥控,NAS硬件入门性价比之王

  4 盘位、4K 输出、J3455、遥控,NAS 硬件入门性价比之王 开篇 在 NAS 市场中,威...
支付宝、淘宝、闲鱼又双叕崩了,Cloudflare也瘫了连监控都挂,根因藏在哪?

支付宝、淘宝、闲鱼又双叕崩了,Cloudflare也瘫了连监控都挂,根因藏在哪?

支付宝、淘宝、闲鱼又双叕崩了,Cloudflare 也瘫了连监控都挂,根因藏在哪? 最近两天的互联网堪称“故障...
零成本上线!用 Hugging Face免费服务器+Docker 快速部署HertzBeat 监控平台

零成本上线!用 Hugging Face免费服务器+Docker 快速部署HertzBeat 监控平台

零成本上线!用 Hugging Face 免费服务器 +Docker 快速部署 HertzBeat 监控平台 ...