设为首页 收藏本站
查看: 1039|回复: 0

[经验分享] Master HaKu

[复制链接]

尚未签到

发表于 2017-12-16 20:14:21 | 显示全部楼层 |阅读模式
  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已经安装成功了
DSC0000.png

  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/
  结果如下:
DSC0001.jpg

  浏览器输入:
  http://localhost:50070/
  结果如下:
DSC0002.png

  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}

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-424818-1-1.html 上篇帖子: Kudu,支持快速分析的新型Hadoop存储系统 下篇帖子: Hadoop工作流引擎之Azkaban与Oozie对比(四)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表