192.168.230.10 192.168.230.11 192.168.230.12 192.168.230.14
NameNode
DataNode DataNode DataNode
SecondaryNameNode
在node1/192.168.230.10上进行操作:
[root@node1 ~]# vi /etc/hosts
192.168.230.10 node1
192.168.230.11 node2
192.168.230.12 node3
192.168.230.14 node5
[root@node1 ~]# scp /etc/hosts root@node2:/etc/
[root@node1 ~]# scp /etc/hosts root@node3:/etc/
[root@node1 ~]# scp /etc/hosts root@node5:/etc/
操作四台机器node1、node2、node3、node5分别生成秘钥目录
[root@node1 ~]# ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
[root@node2 ~]# ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
[root@node3 ~]# ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
[root@node5 ~]# ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
把公钥文件放入认证文件中去
[root@node1 ~]$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[root@node1 ~]$ ls -a
. .. .bash_history .bash_logout .bash_profile .bashrc .ssh
第一次登录需要密码
ssh node1
选择node1作为执行脚本的机器
将公钥认证文件放到node2中去
ssh node2
[root@node1 ~]# scp ~/.ssh/id_dsa.pub root@node2:~/opt/
root@node2's password:
id_dsa.pub 100% 600 0.6KB/s 00:00
[root@node1 ~]# scp ~/.ssh/id_dsa.pub root@node3:~/opt/
root@node3's password:
Permission denied, please try again.
root@node3's password:
id_dsa.pub 100% 600 0.6KB/s 00:00
[root@node1 ~]# scp ~/.ssh/id_dsa.pub root@node5:~/opt/
root@node5's password:
id_dsa.pub
[root@node2 ~]$ cat ~/opt/id_dsa.pub >> ~/.ssh/authorized_keys
[root@node3 ~]$ cat ~/opt/id_dsa.pub >> ~/.ssh/authorized_keys
[root@node5 ~]$ cat ~/opt/id_dsa.pub >> ~/.ssh/authorized_keys
[root@node1 ~]# ssh node2
[root@node1 ~]# ssh node3
[root@node1 ~]# ssh node5
[root@node1 ~]# yum install ntpdate
[root@node1 ~]# ntpdate -u ntp.sjtu.edu.cn
[root@node1 ~]# javac -version
javac 1.7.0_79
[root@node1 ~]# echo $JAVA_HOME
/usr/java/jdk1.7.0_79
export JAVA_HOME=/usr/java/jdk1.7.0_79
export HADOOP_PREFIX=/opt/modules/hadoop-2.5.1
fs.defaultFS
hdfs://node1:9000
hadoop.tmp.dir
/opt/modules/hadoop-2.5.1
dfs.namenode.secondary.http-address
node5:50090
dfs.namenode.secondary.https-address
node5:50091
slaves中配的是datanode的主机名
node2
node3
node5
masters中配的是secondarynamenode的主机名
node5
[root@node1 ~]# vi ~/.bash_profile
export HADOOP_HOME=/opt/modules/hadoop-2.5.1
export PATH=$PATH:$HADOOP_HOME/bin
[root@node1 ~]# scp ~/.bash_profile root@node2:~/
[root@node1 ~]# scp ~/.bash_profile root@node3:~/
[root@node1 ~]# scp ~/.bash_profile root@node5:~/
使配置文件生效
[root@node1 ~]# source ~/.bash_profile
[root@node2 ~]# source ~/.bash_profile
[root@node3 ~]# source ~/.bash_profile
[root@node5 ~]# source ~/.bash_profile
[root@node1 ~]# scp -r /opt/modules/hadoop-2.5.1 root@node2:/opt/modules/hadoop-2.5.1
[root@node1 ~]# scp -r /opt/modules/hadoop-2.5.1 root@node3:/opt/modules/hadoop-2.5.1
[root@node1 ~]# scp -r /opt/modules/hadoop-2.5.1 root@node5:/opt/modules/hadoop-2.5.1
[root@node1 hadoop-2.5.1]# ./bin/hdfs namenode -format
[root@node1 hadoop-2.5.1]# ./sbin/start-dfs.sh
node1:50070
在地址栏访问NameNode的WebUI:
http://192.168.230.10:50070/
node5:50090
在地址栏访问SecondaryNameNode的WebUI:
http://192.168.230.14:50090/