ol7.7安装部署4节点hadoop 3.2.1分布式集群学习环境的详细教程

2020-07-10 14:01:02 来源:易采站长站 作者:于海丽

准备4台虚拟机,安装好ol7.7,分配固定ip192.168.168.11 12 13 14,其中192.168.168.11作为master,其他3个作为slave,主节点也同时作为namenode的同时也是datanode,192.168.168.14作为datanode的同时也作为secondary namenodes

首先修改/etc/hostname将主机名改为master、slave1、slave2、slave3

然后修改/etc/hosts文件添加

192.168.168.11 master
192.168.168.12 slave1
192.168.168.13 slave2
192.168.168.14 slave3

然后卸载自带openjdk改为sun jdk,参考https://www.jb51.net/article/190489.htm

配置无密码登陆本机

ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 0600 ~/.ssh/authorized_keys

配置互信

master上把公钥传输给各个slave

scp ~/.ssh/id_rsa.pub hadoop@slave1:/home/hadoop/
scp ~/.ssh/id_rsa.pub hadoop@slave2:/home/hadoop/
scp ~/.ssh/id_rsa.pub hadoop@slave3:/home/hadoop/

在slave主机上将master的公钥加入各自的节点上

cat ~/id_rsa.pub >> ~/.ssh/authorized_keys

master上安装hadoop

sudo tar -xzvf ~/hadoop-3.2.1.tar.gz -C /usr/local
sudo mv hadoop-3.2.1-src/ ./hadoop
sudo chown -R hadoop: ./hadoop

.bashrc添加并使之生效

export HADOOP_HOME=/usr/local/hadoop
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop

集群配置,/usr/local/hadoop/etc/hadoop目录中有配置文件:

修改core-site.xml

<configuration>
 <property>
 <name>hadoop.tmp.dir</name>
 <value>file:/usr/local/hadoop/tmp</value>
 <description>Abase for other temporary directories.</description>
 </property>
 <property>
 <name>fs.defaultFS</name>
 <value>hdfs://master:9000</value>
 </property>
</configuration>

修改hdfs-site.xml

<configuration>
 <property>
 <name>dfs.namenode.name.dir</name>
 <value>/home/hadoop/data/nameNode</value>
 </property>
 
 <property>
 <name>dfs.datanode.data.dir</name>
 <value>/home/hadoop/data/dataNode</value>
 </property>
 
 <property>
 <name>dfs.replication</name>
 <value>3</value>
 </property>
 <property>
 <name>dfs.secondary.http.address</name>
 <value>slave3:50090</value>
 </property>
</configuration>

修改mapred-site.xml

<configuration>
 <property>
 <name>mapreduce.framework.name</name>
 <value>yarn</value>
 </property>
 
 <property>
 <name>yarn.app.mapreduce.am.env</name>
 <value>HADOOP_MAPRED_HOME=$HADOOP_HOME</value>
 </property>
 
 <property>
 <name>mapreduce.map.env</name>
 <value>HADOOP_MAPRED_HOME=$HADOOP_HOME</value>
 </property>
 
 <property>
 <name>mapreduce.reduce.env</name>
 <value>HADOOP_MAPRED_HOME=$HADOOP_HOME</value>
 </property>
</configuration>
            




              

微信扫一扫

易采站长站微信账号