【Hadoop】安装Hadoop集群(未配置高可用HA)
作者:互联网
Hadoop的集群安装
1.在Master中的解压Hadoop
tar -xvf hadoop-2.6.6.tar -C /home/hadoop/
2.在Hadoop解压路径下创建四个目录
3.配置 hadoop的配置文件(hadoop安装路径下的etc/hadoop)
(1)配置core-site.xml
sudo vim core-site.xml
在标签中间加入以下配置
<property>
<name>hadoop.tmp.dir</name>
<value>file:/home/hadoop/hadoop-2.6.5/hdfs/tmp</value>
<description>A base for other temporary directories.</description>
</property>
<property>
<name>io.file.buffer.size</name>
<value>131072</value>
</property>
<property>
<name>fs.defaultFS</name>
<value>hdfs://master:9000</value>
</property>
(2)配置hadoop-env.sh
sudo vim hadoop-env.sh
更改java环境变量
(3)配置yarn-env.sh
sudo vim yarn-env.sh
更改java环境变量
(4)配置hdfs-site.xml
sudo vim hdfs-site.xml
在标签中间加入以下配置
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/home/hadoop/hadoop-2.6.5/hdfs/name</value>
<final>true</final>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/home/hadoop/hadoop-2.6.5/hdfs/data</value>
<final>true</final>
</property>
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>master:9001</value>
</property>
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
<property>
<name>dfs.permissions</name>
<value>false</value>
</property>
(5)配置mapred-site.xml
① 将mapred-site.xml.template重命名为mapred-site.xml
cp mapred-site.xml.template mapred-site.xml
② 在标签中间加入以下配置
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
(6)配置yarn-site.xml
在标签中间加入以下配置
<property>
<name>yarn.resourcemanager.address</name>
<value>master:18040</value>
</property>
<property>
<name>yarn.resourcemanager.scheduler.address</name>
<value>master:18030</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address</name>
<value>master:18088</value>
</property>
<property>
<name>yarn.resourcemanager.resource-tracker.address</name>
<value>master:18025</value>
</property>
<property>
<name>yarn.resourcemanager.admin.address</name>
<value>master:18141</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.auxservices.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
(7)修改slaves(把原本的localhost删掉,改为slave1和slave2,如图所示)
添加后
4.配置Hadoop环境变量
sudo vim /etc/profile
export HADOOP_HOME=/home/hadoop/hadoop-2.6.5
export PATH="$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH"
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
5.将Master上的所有Hadoop的配置复制到slave1和slave2中
scp -r /home/hadoop/hadoop-2.6.5/ hadoop@192.168.1.5:/home/hadoop/
在slave1节点的/home/hadoop路径下就可以查询得到了
slave2同理,将IP地址更换为slave2节点的IP就可以了
scp -r /home/hadoop/hadoop-2.6.5/ hadoop@192.168.1.4:/home/hadoop/
然后在slave1、slave2上都执行第4步操作(添加环境变量)
6.在Master上格式化Hadoop
hdfs namenode -format
7.添加IP与主机名的映射(三个节点都配置)
sudo vim /etc/hosts
192.168.1.6 master
192.168.1.5 slave1
192.168.1.4 slave2
8.配置免密
(1)生成.ssh文件
ssh localhost
(2)生成密钥
ssh-keygen -t rsa
(3)生成公钥
ssh-copy-id localhost
(4)把免密配置复制到其他节点
scp -r ~/.ssh hadoop@slave1:~
scp -r ~/.ssh hadoop@slave2:~
9.启动Hadoop(如果没有配置免密,需要多次输入密码)
方法一:start-all.sh
方法二:先启动start-dfs.sh
,然后再启动start-yarn.sh
10.停止Hadoop
方法一:stop-all.sh
方法二:先启动stop-dfs.sh
,然后再启动stop-yarn.sh
标签:xml,Hadoop,yarn,hadoop,集群,site,home,HA 来源: https://blog.csdn.net/qq_37251994/article/details/123580019