在3个系统centos6.5的linux虚拟机搭建一个分布式hadoop环境,hadoop版本为2.6,节点ip分别为
192.168.17.133
192.168.17.134
192.168.17.135
分别在3个节点上配置/etc/hosts文件,内容如下:
192.168.17.133 master
192.168.17.134 slave1
192.168.17.135 slave2
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
这里选择安装jdk1.7版本,安装成功后配置一下环境变量:
export JAVA_HOME=/usr/java/jdk1.7.0_67-cloudera
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
临时关闭防火墙:
service iptables stop
永久关闭防火墙重启生效:
chkconfig iptables off
临时关闭Selinux:
setenforce 0
永久关闭Selinux:
编辑/etc/selinux/config,设置SELINUX=disabled
配置完成后重启各节点使配置生效
ssh-keygen -t rsa -P ""
(使用rsa加密方式生成密钥)回车后,会提示三次输入信息,我们直接回车即可。cat id_rsa.pub >> authorized_keys
这里以master为ntp服务器,slave1,slave2作为客户端
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
#restrict default kod nomodify notrap nopeer noquery
#restrict -6 default kod nomodify notrap nopeer noquery
restrict default nomodify
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 127.127.1.0 #local clock
fudge 127.127.1.0 stratum 8
service ntpd start
,设置开机启动:chkconfig ntpd on
在客户端slave1,slave2停止ntpd服务:service ntpd stop
,并手动测试能否同步master:ntpdate master
,成功的话如下图:
在slave1,slave2添加定时同步任务,执行crontab -e
添加以下内容:
*/1 * * * * /usr/sbin/ntpdate master;hwclock –w
以上的步骤都是基础环境配置,现在正式进入hadoop环境的配置
到官网下载安装包后解压到/usr/hadoop-2.6.0,然后配置一下环境变量,内容如下:
export HADOOP_HOME=/usr/hadoop-2.6.0
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
到$HADOOP_HOME/etc/hadoop目录下修改这三个文件,添加JAVA_HOME配置:
export JAVA_HOME=/usr/java/jdk1.7.0_67-cloudera
根据实际的部署修改slaves文件,这里以slave1,slave2两台机子作为集群的slave,则内容为:
slave1
slave2
<property>
<name>hadoop.tmp.dirname>
<value>/hadoop/tmpvalue>
property>
<property>
<name>fs.defaultFSname>
<value>hdfs://master:9000value>
property>
<property>
<name>dfs.replicationname>
<value>3value>
property>
<property>
<name>dfs.namenode.name.dirname>
<value>/hadoop/dfs/namevalue>
property>
<property>
<name>dfs.datannode.data.dirname>
<value>/hadoop/dfs/datavalue>
property>
<property>
<name>dfs.permissionsname>
<value>falsevalue>
property>
<property>
<name>mapreduce.framework.namename>
<value>yarnvalue>
property>
<property>
<name>mapreduce.jobhistory.addressname>
<value>master:10020value>
property>
<property>
<name>mapreduce.jobhistory.webapp.addressname>
<value>master:19888value>
property>
<property>
<name>yarn.nodemanager.aux-servicesname>
<value>mapreduce_shufflevalue>
property>
<property>
<name>yarn.nodemanager.aux-services.mapreduce.shuffle.classname>
<value>org.apache.hadoop.mapred.ShuffleHandlervalue>
property>
<property>
<name>yarn.resourcemanager.addressname>
<value>master:8032value>
property>
<property>
<name>yarn.resourcemanager.scheduler.addressname>
<value>master:8030value>
property>
<property>
<name>yarn.resourcemanager.resource-tracker.addressname>
<value>master:8031value>
property>
<property>
<name>yarn.resourcemanager.admin.addressname>
<value>master:8033value>
property>
<property>
<name>yarn.resourcemanager.webapp.addressname>
<value>master:8088value>
property>
执行命令hadoop namenode -format
,看到以下信息表示成功:
$HADOOP_HOME/sbin/start-dfs.sh
$HADOOP_HOME/sbin/start-yarn.sh
$HADOOP_HOME/sbin/mr-jobhistory-daemon.sh stap historyserver
完成后可以通过jps查看一下各节点的进程是否正常启动,或者通过访问一下web界面:
http://master:50070
http://master:8088/
hadoop2.2已经被遗弃的属性名称:https://www.iteblog.com/archives/923.html