hadoop_完全分布式配置
注:此文章所写内容完全在虚拟机配置,系统:centos,jdk和hadoop已经安装完成所配集群包括hadoop01,hadoop02,hadoop03,hadoop04四台,ip分别为:192.168.80.101,192.168.80.102,192.168.80.103,192.168.80.104。
1、现在有一台虚拟机,主机名:hadoop01,修改主机hosts
1、更改 /etc/hosts // 添加IP和主机名的映射
127.0.0.1 localhost
192.168.80.101 hadoop01
192.168.80.102 hadoop02
192.168.80.103 hadoop03
192.168.80.104 hadoop04
2、更改主机名:/etc/hostname /etc/sysconfig/network
2、配置完全分布式(${HADOOP_HOME}/etc/hadoop)
[core-site.xml] // 在<value>中写 namenode 主机名 映射ip <configuration> <property> <name>fs.defaultFS</name> <value>hdfs://hadoop01/</value> </property> </configuration> [hdfs-site.xml] //在<value>中为datenode主机数量 <configuration> <property> <name>dfs.replication</name> <value>3</value> </property> </configuration> [mapred-site.xml] 注意:cp mapred-site.xml.template mapred-site.xml <configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration> [yarn-site.xml] // 在第一个<value>内填写namenode主机名 映射ip <configuration> <property> <name>yarn.resourcemanager.hostname</name> <value>hadoop01</value> </property> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> </configuration>
// 配置 slaves 文件 datenode节点
hadoop02
hadoop03
hadoop04
3、配置完全分布式
1、克隆三台
2、克隆过后修改hostname和ip地址文件
[/etc/hostname] [/etc/sysconfig/network]
hadoop02
修改ip
[/etc/sysconfig/network-scripts/ifcfg-ethxxx]
IPADDR = 192.168.80.102
因为是克隆的所以删除UUID和MAC地址
然后 rm -f /etc/udev/rules.d/70-persistent-net.rules 文件
3、重启网络
sudo service network restart
4、修改/etc/resolv.conf文件
nameserver 192.169.80.2
5、重复以上过程2~4
4、准备完全分布式主机的ssh
1、删除主机上的/home/hadoop/.ssh/*
2、在hadoop01主机上生成密匙对
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
3、将hadoop01的公钥文件id_rsa.pub远程复制到hadoop01~hadoop04主机上
并放置到/etc/hadoop/.ssh/authorized_keys
$>scp id_rsa.pub hadoop@hadoop01:/home/centos/.ssh/authorized_keys
$>scp id_rsa.pub hadoop@hadoop02/home/centos/.ssh/authorized_keys
$>scp id_rsa.pub hadoop@hadoop03:/home/centos/.ssh/authorized_keys
$>scp id_rsa.pub hadoop@hadoop04:/home/centos/.ssh/authorized_keys若系统没有scp命令:安装scp
yum -y install openssh-clients
另外:记住更改 .ssh文件夹为 hadoop:hadoop用户4、ssh hadoop01
ssh hadoop02
ssh hadoop03
ssh hadoop04
测试登陆
5、格式化文件系统
1、格式化文件系统之前先删除临时文件目录文件
cd /tmp
rm -rf hadoop-hadoop
ssh hadoop02 rm -rf /tmp/hadoop-hadoop
....
2、删除hadoop日志文件
cd /soft/hadoop/logs
rm -rf *
ssh hadoop02 rm -rf /soft/hadoop/logs/*
....
3、格式化文件系统
hadoop namenode -format
4、启动hadoop进程
start-all.sh
6、jps查看进程
登陆192.168.80.101:50070查看节点信息