centos 7 hadoop的安装和使用
准备工作
- 安装jdk
- 用户免密登录
安装参考文章:
http://blog.csdn.net/circyo/article/details/46724335
http://www.linuxidc.com/Linux/2015-11/124800.htm
常用命令:
1、找到hadoop 安装目录,启动命令“sbin/start-all.sh"
2、hdfs文件系统”bin/hadoop fs"
3、“bin/hadoop fs -help"查看hdfs文件系统常用命令
4、配置文件在hadoop 安装目录“etc"下
5、bin/hdfs fsck / 运行DFS文件检测排错
6、bin/hdfs namenode -format 格式化namenode
7、bin/hdfs dfsadmin -safemode enter/leave/get/wait (安全模式:进入开启/强制关闭/获得/等待)
注意:
1、hadoop JAVA_HOME 需要配置
2、重启机器后namenode 启动不了,可通过格式化hdfs 解决
3、datanode启动不了,可通过删除dfs目录解决(可能原因是集群信息不正确,可能跟格式化namenode相关,操作步骤停止hadoop,删除dfs目录,格式化hdfs,启动hadoop)
eclipse hadoop2.7.3 安装
参考文章:http://www.cnblogs.com/duking1991/p/6056923.html
注意:
1、解压后hadoop路径地址需要无空格或特殊字符,否则eclipse加载不了hadoop包文件
2、在项目中添加log4j配置,可在eclipse中输出日志信息
3、无法操作hadoop文件,用户禁止访问(Permission denied),解决一种办法,改变目录权限,"bin/hadoop fs -chmod 777 /user/***"
4、在main中配置hadoop 目录 ,System.setProperty("hadoop.home.dir","d:\\hadoop-2.7.3");
我的hadoop配置:
core-site.xml
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://master:9000</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/home/hadoop/tmp</value> </property> <property> <name>io.file.buffer.size</name> <value>131702</value> </property> </configuration>
hdfs-site.xml
<configuration> <property> <name>dfs.namenode.name.dir</name> <value>file:/home/hadoop/dfs/name</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:/home/hadoop/dfs/data</value> </property> <property> <name>dfs.replication</name> <value>2</value> </property> <property> <name>dfs.namenode.secondary.http-address</name> <value>master:9001</value> </property> <property> <name>dfs.webhdfs.enabled</name> <value>true</value> </property> </configuration>
mapred-site.xml
<configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> <final>true</final> </property> <property> <name>mapreduce.jobtracker.http.address</name> <value>master:50030</value> </property> <property> <name>mapreduce.jobhistory.address</name> <value>master:10020</value> </property> <property> <name>mapreduce.jobhistory.webapp.address</name> <value>master:19888</value> </property> <property> <name>mapred.job.tracker</name> <value>http://master:9001</value> </property> </configuration>
yarn-site.xml
<configuration> <!-- Site specific YARN configuration properties --> <property> <name>yarn.resourcemanager.hostname</name> <value>master</value> </property> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> <property> <name>yarn.resourcemanager.address</name> <value>master:8032</value> </property> <property> <name>yarn.resourcemanager.scheduler.address</name> <value>master:8030</value> </property> <property> <name>yarn.resourcemanager.resource-tracker.address</name> <value>master:8031</value> </property> <property> <name>yarn.resourcemanager.admin.address</name> <value>master:8033</value> </property> <property> <name>yarn.resourcemanager.webapp.address</name> <value>master:8088</value> </property> </configuration>
免密登录设置:centos 7 免密登录