1、先使用groupadd hadoop 建立hadoop用户组
2、新建用户,useradd -d /usr/hadoop -g hadoop -m hadoop (新建用户hadoop指定用户主目录/usr/hadoop 及所属组hadoop)
3、passwd hadoop 设置hadoop密码(这里设置密码为hadoop)
4、安装好jdk1.8版本 ,安装教材地址http://www.cnblogs.com/shihaiming/p/5809553.html(安装在/usr/local/jdk1.8目录)
5、拷贝hadoop2.7.3版本到Linux虚拟机上(放在目录/usr/hadoop/hadoop 中),到此基本环境已经完成,克隆虚拟机datanode1,datanode2,namenode,备份,总共四份虚拟机,为接下来省去安装虚拟机步骤。
6、修改主机名 vi /etc/hostname 分别改为datanode1,datanode2,namenode
7、配置hadoop 环境变量,修改hadoop用户目录下的.bash_profile文件
如图:
8、修改/etc/hosts 文件引入其他服务器主机名 (datanode1,datanode2主机也相应做此操作)
8、修改usr/hadoop/hadoop/etc/hadoop/hadoop-env.sh 文件,修改内容如下:
a. 加入一行 export HADOOP_LOG_DIR=/usr/hadoop/log/hadoop ,如果不存在该日志路径,创建。
b. 设置jdk 安装路径 export JAVA_HOME=/usr/local/jdk1.8 (把配置文件中jdk配置去掉注释,并加上路径即可)
9、配置hadoop的文件/etc/hadoop/core-site.xm
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/usr/hadoop/hadoop/tmp/</value>
<description> Abase for other temporary directories</description> </property> <property>
<name>fs.defaultFS</name>
<value>hdfs://namenode:9000</value>
</property>
<property>
<name>io.file.buffer.size</name>
<value>4096</value>
</property>
</configuration>
hdfs-site.xml
<configuration>
<property>
<name>dfs.nameservices</name>
<value>namenode</value>
</property>
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>namenode:50090</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>/usr/hadoop/hadoop/dfs/data</value>
</property>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
</configuration>
mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>mapreduce.jobtracker.http.address</name>
<value>namenode:50030</value>
</property>
<property>
<name>mapreduce.jobhistory.address</name>
<value>namenode:10020</value>
</property>
<property>
<name>mapreduce.jobhistory.webapp.address</name>
<value>namenode:19888</value>
</property>
<property>
<!--see job-->
<name>mapred.job.tracker</name>
<value>namenode:9001</value>
</property>
</configuration>
yarn-site.xml
<configuration>
<!-- Site specific YARN configuration properties -->
<property>
<name>yarn.nodemanager.aux.services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.resourcemanager.address</name>
<value>namenode:8032</value>
</property>
<property>
<name>yarn.resourcemanager.scheduler.address</name>
<value>namenode:8030</value>
</property>
<property>
<name>yarn.resourcemanager.resource-tracker.address</name>
<value>namenode:8031</value>
</property>
<property>
<name>yarn.resourcemanager.admin.address</name>
<value>namenode:8033</value>
</property>
<property>
<name>yarn.resourcemanager.web.address</name>
<value>namenode:8088</value>
</property>
</configuration>
在slaves文件中加入
datanode1
datanode2
把已经配置好的hadoop 拷贝到namenode ,datanode1,datanode2的/usr/hadoop/hadoop
10、配置hadoop集群中无密码登录
[hadoop@namenode ~]$ssh-keygen -t rsa (产生密钥和公钥,一直敲回车键,不需要输入密码,datanode1,datanoe2同样做此操作,下面命令只在namenode中进行)
[hadoop@namenode .ssh]$ cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
[hadoop@namenode .ssh]$ ssh datanode1 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[hadoop@namenode .ssh]$ ssh datanode2 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
然后把authorized_keys 分别拷贝到datanode1,datanode2 的.ssh目录下
重启sshd
systemctl restart sshd
尝试下是否实现了无密码切换服务器。
11、启动hadoop
start-dfs.sh
start-yarn.sh
这就大功告成了