hadoop2.7.3安装
Hadoop 2.7.3安装
实验环境:RHEL7,JDK1.8
主机之间的部署:
主机名称 |
IP |
Master |
192.168.146.100 |
Slave1 |
192.168.146.101 |
Slave2 |
192.168.146.102 |
设置主机名:
[root@localhost Desktop]# hostnamectl set-hostname Slave2
[root@slave1 Desktop]# hostnamectl set-hostname Slave1
设置hosts表:
[root@liu Desktop]# vim /etc/hosts
192.168.146.100 master
192.168.146.101 Slave1
192.168.146.102 Slave2
配置SSH免密码登录
在master上:
[hadoop@liu hadoop]$ ssh-keygen -t rsa(按四次回车)
[hadoop@master hadoop]$ ssh-copy-id hadoop@Slave1
在Slave2上:
[hadoop@slave2 ~]$ ssh-copy-id hadoop@Slave1
在Slave1上:
[hadoop@slave1 .ssh]$ ssh-copy-id localhost
[hadoop@slave1 .ssh]$ scp authorized_keys hadoop@Slave2:/home/hadoop/.ssh/
[hadoop@slave1 .ssh]$ scp authorized_keys hadoop@master:/home/hadoop/.ssh/
验证SSH:
相互ssh
在主节点上安装hadoop2.7.3
将文件导入/workspace目录下
设置/workspace的权限:[root@liu workspace]# chmod 1777 /workspace/
切换用户:[root@liu local]# su hadoop
解压hadoop的安装包:
[hadoop@liu local]$ tar -zxvf /workspace/hadoop-2.7.3.tar.gz -C ./
修改配置文件:
[hadoop@liu hadoop]$ vim hadoop-env.sh
export JAVA_HOME=/usr/lib/java/jdk1.8.0_121
[hadoop@liu hadoop]$ vim core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://master:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>usr/local/hadoop/tmp</value>
</property>
</configuration>
[hadoop@liu hadoop]$ vim hdfs-site.xml
<configuration>
<property>
<name>dfs.namenode.name.dir</name>
<value>/usr/local/hadoop/tmp/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>/usr/local/hadoop/tmp/dfs/data</value>
</property>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
[hadoop@master hadoop]$ vim yarn-site.xml
<property>
<name>yarn.resourcemanager.hostname</name>
<value>master</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
[hadoop@master hadoop]$ cp mapred-site.xml.template mapred-site.xml
[hadoop@master hadoop]$ vim mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
[hadoop@master local]$ vim hadoop-2.7.3/etc/hadoop/slaves
Slave1
Slave1
将hadoop文件导入salve节点:
[hadoop@master local]$ scp -r hadoop-2.7.3 hadoop@Slave1:/usr/local/
[hadoop@master local]$ scp -r hadoop-2.7.3 hadoop@Slave2:/usr/local/
导入环境变量:
[hadoop@master local]$ scp ~/.bashrc hadoop@Slave1:/home/hadoop/
[hadoop@master local]$ scp ~/.bashrc hadoop@Slave2:/home/hadoop/
格式化各节点的namenode
[hadoop@master local]$ hdfs namenode -format
启动:
sbin/start-dfs.sh
sbin/start-yarn.sh