码迷,mamicode.com
首页 > 其他好文 > 详细

搭建hadoop

时间:2016-11-30 11:41:42      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:classpath   str   x86   city   失效   .com   conf   重启   char   

Linux 防火墙
1) 重启后生效
开启: chkconfig iptables on
关闭: chkconfig iptables off
2) 即时生效,重启后失效
开启: service iptables start
关闭: service iptables stop
需要说明的是对于Linux下的其它服务都可以用以上命令执行开启和关闭操作。
在开启了防火墙时,做如下设置,开启相关端口,
修改/etc/sysconfig/iptables 文件,添加以下内容:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

修改每台机器的/etc/hosts,增加
192.168.48.100 fcs

一、安装JDK
mkdir -p /usr/local/jdk1.8.0_111/
tar -zxvf jdk-8u101-linux-x64.tar.gz -C /usr/local/jdk1.8.0_111/
查看现有JDK
#rpm -qa | grep jdk
卸载:rpm -e --nodeps jdk-1.7.0
配置
#vi /etc/profile 加入:
export JAVA_HOME=/usr/local/jdk1.8.0_111
export JRE_HOME=/usr/local/jdk1.8.0_111/jre
export PATH=$PATH:/usr/local/jdk1.8.0_111/bin
export CLASSPATH=./:/usr/local/jdk1.8.0_111/lib:/usr/local/jdk1.8.0_111/jre/lib
让/etc/profile文件修改后立即生效 ,可以使用如下命令:
# . /etc/profile
重启测试
java -version

二、配置ssh免密码登录
ssh-keygen -t dsa -P ‘‘ -f ~/.ssh/id_dsa
这个命令会在.ssh文件夹下创建两个文件id_dsa及id_dsa.pub,这是一对私钥和公钥,然后把id_dsa.pub(公钥)追加到授权的key里面去,输入命令:
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
验证ssh已安装成功及无密码登陆本机,输入命令:
ssh -version
显示结果:
Bad escape character ‘rsion‘.
登陆ssh,输入命令:
ssh localhost
第一次登陆可能会询问是否继续链接,输入yes即可,以后登陆直接登进去。
显示结果:
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-32-generic x86_64)
* Documentation: https://help.ubuntu.com/
Last login: Sun Oct 12 13:27:58 2014 from localhost

可能遇到的问题
用ssh登录一个机器(换过ip地址),提示输入yes后,屏幕不断出现y,只有按ctrl + c结束
错误是:The authenticity of host 192.168.48.xxx can‘t be established.
执行ssh -o StrictHostKeyChecking=no 192.168.48.xxx 就OK

三、安装Hadoop(伪分布模式)
mkdir -p /home/bml/hadoop_tmp
cd /root/hadoop/etc/hadoop
1、修改hadoop-env.sh
将export JAVA_HOME=${JAVA_HOME}改为你自己安装的jdk路径:
export JAVA_HOME=/usr/local/jdk1.8.0_111
2、修改core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
<final>true</final>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/home/bml/hadoop_tmp</value>
</property>
</configuration>
3、修改hdfs-site.xml
<configuration>
<property>
<name>dfs.namenode.name.dir</name>
<value>/home/bml/hadoop/dfs/namenode</value>
<final>true</final>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>/home/bml/hadoop/dfs/datanode</value>
<final>true</final>
</property>
<property>
<name>dfs.http.address</name>
<value>localhost:50070</value>
<description>
The address and the base port where the dfs namenode web ui will listen on.
If the port is 0 then the server will start on a free port.
</description>
</property>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.permissions</name>
<value>false</value>
</property>
</configuration>
4、修改mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>mapred.job.tracker</name>
<value>hdfs://localhost:9001</value>
</property>
<property>
<name>mapred.system.dir</name>
<value>file:/home/bml/hadoop/mapred/system</value>
<final>true</final>
</property>
<property>
<name>mapred.local.dir</name>
<value>file:/home/bml/hadoop/mapred/local</value>
<final>true</final>
</property>
</configuration>
5、修改修改yarn-site.xml
<configuration>
<!-- Site specific YARN configuration properties -->
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
<description>shuffle service that needs to be set for Map Reduce to run</description>
</property>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>localhost</value>
<description>hostname of Resource Manager</description>
</property>
<property>
<name>yarn.nodemanager.resource.memory-mb</name>
<value>1024</value>
</property>
</configuration>
6、修改slaves文件
localhost
7、启动伪分布式模式:
cd /root/hadoop
第一次启动都要格式化下数据文件,命令:
./bin/hdfs namenode -format
启动hadoop,命令:
./sbin/start-all.sh
查看
jps
结果:
[root@fcs sbin]# jps
35010 NodeManager
36340 Jps
34345 JobHistoryServer
33035 NameNode
34892 ResourceManager
33726 SecondaryNameNode
33151 DataNode

 

搭建hadoop

标签:classpath   str   x86   city   失效   .com   conf   重启   char   

原文地址:http://www.cnblogs.com/jzbml/p/6116836.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!