[walter@node2:.ssh]ls -la
drwx------ 2 walter walter .
drwx------ 3 walter walter ..
-rw-r--r-- 1 walter walter authorized_keys
注意每个机器上的.ssh目录的ls -la都应该和上面是一样的
接着,在三台机器上都需要对sshd服务进行配置(其实是可以不用配置的,完成了上面的那些操作了以后SSH就已经可以工作了),在三台机器上修改文件/etc/ssh/sshd_config
#去除密码认证
PasswordAuthentication no
AuthorizedKeyFile .ssh/authorized_keys
至此各个机器上的SSH配置已经完成,可以测试一下了,比如node1向node2发起ssh连接
[walter@node1:~]$ssh node2
如果ssh配置好了,就会出现以下提示信息
The authenticity of host [node2] can't be established.
Key fingerprint is 1024 5f:a0:0b:65:d3:82:df:ab:44:62:6d:98:9c:fe:e9:52.
Are you sure you want to continue connecting (yes/no)?
OpenSSH告诉你它不知道这台主机,但是你不用担心这个问题,因为你是第一次登录这台主机。键入“yes”。这将把这台主机的“识别标记”加到“~/.ssh/know_hosts”文件中。第二次访问这台主机的时候就不会再显示这条提示信息了。
然后你会发现不需要输入密码就可以建立ssh连接了,恭喜你,配置成功了
不过,别忘了测试本机ssh node1
Hadoop配置文件
在hadoop-conf/目录下,打开slaves文件,该文件用来指定所有的从节点,一行指定一个主机名。即本文中的node12,node3,因此slaves文件看起来应该是这样的
node1
node2
在conf/目录中的hadoop-default.xml中包含了Hadoop的所有配置项,但是不允许直接修改!可以在hadoop-conf/目录下的core-site.xml里面定义我们需要的项,其值会覆盖hadoop-default.xml中的默认值。可以根据自己的实际需要来进行定制。以下是我的配置档:
hadoop-conf/core-site.xml
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://node1:9000</value>
<description>The name of the default file system. </description>
</property>
</configuration>
hadoop-conf/hdfs-site.xml:
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
<description>Default block replication. The actual number of replications can be specified when the file is created. The default is used if replication is not specified in create time.</description>
</property>
<property>
<name>mapred.local.dir</name>
<value>/home/walter/software/hadoop/tmp</value>
<description>A base for other temporary directories.</description>
</property>
<property>
<name>dfs.name.dir</name>
<value>/home/walter/software/hadoop/filesystem/name</value>
<description>Determines where on the local filesystem the DFS name node should store the name table. If this is a comma-delimited list of directories then the name table is replicated in all of the directories, for redundancy. </description>
</property>
<property>
<name>dfs.data.dir</name>
<value>/home/walter/software/hadoop/filesystem/data</value>
<description>Determines where on the local filesystem an DFS data node should store its blocks. If this is a comma-delimited list of directories, then data will be stored in all named directories, typically on different devices. Directories that do not exist are ignored.</description>
</property>
</configuration>
hadoop-conf/mapred-site.xml:
<property>
<name>mapred.job.tracker</name>
<value>node1:9001</value>
<description>The host and port that the MapReduce job tracker runs at. If "local", then jobs are run in-process as a single map and reduce task.</description>
</property>