这 个下令将为dbrg-1上的用户dbrg天生其密钥对,扣问其生涯路径时直接回车采用默认路径,当提醒要为天生的密钥输入passphrase的时间,直 接回车,也就是将其设定为空暗码。天生的密钥对id_rsa,id_rsa.pub,默认存储在/home/dbrg/.ssh目次下。然后将>
[dbrg@dbrg-1:.ssh]$cp> [dbrg@dbrg-2:~]$mkdir .ssh
[dbrg@dbrg-1:.ssh]$scp authorized_keys dbrg-2:/home/dbrg/.ssh/
此处的scp就是通过ssh举办长途copy,此处必要输入长途主机的暗码,即dbrg-2呆板上dbrg帐户的暗码,固然,你也可以用其他行动将authorized_keys文件拷贝到其他呆板上[dbrg@dbrg-2:.ssh]$chmod 644 authorized_keys
这一步非常关键,必需担保authorized_keys只对其全部者有读写权限,其他人不允许有写的权限,不然SSH是不会事变的。我就曾经在设置SSH的时间纳闷了好久。[dbrg@dbrg-2:.ssh]ls -la
drwx------ 2 dbrg dbrg .
drwx------ 3 dbrg dbrg ..
-rw-r--r-- 1 dbrg dbrg authorized_keys
留意每个呆板上的.ssh目次的ls -la都应当和上面是一样的
接着,在三台呆板上都必要对sshd做事举办设置(着实是可以不消设置的,完成了上面的那些操纵了以后SSH就已经可以事变了),在三台呆板上批改文件/etc/ssh/sshd_config
#去除暗码认证
PasswordAuthentication no
AuthorizedKeyFile .ssh/authorized_keys
至此各个呆板上的SSH设置已经完成,可以测试一下了,比如dbrg-1向dbrg-2提倡ssh毗连 [dbrg@dbrg-1:~]$ssh dbrg-2
假如ssh设置好了,就会出现以下提醒信息
The authenticity of host [dbrg-2] 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 dbrg-1
Hadoop环境变量
在/home/dbrg/HadoopInstall/hadoop-conf目次下的 hadoop_env.sh中设置Hadoop必要的环境变量,此中JAVA_HOME是必需设定的变量。HADOOP_HOME变量可以设定也可以不设 定,假如不设定,HADOOP_HOME默认的是bin目次的父目次,即本文中的/home/dbrg/HadoopInstall/hadoop。我的 是如许设置的
export HADOOP_HOME=/home/dbrg/HadoopInstall/hadoop
export JAVA_HOME=/usr/java/jdk1.6.0
从这个地方就可以看出前面所述的创建hadoop0.12.0的链接hadoop的利益了,当以后更新hadoop的版本的时间,就不必要在改设置文件,只必要变动链接就可以了。
Hadoop设置文件
如前所述,在hadoop-conf/目次下,打开slaves文件,该文件用来指定全部的从节点,一行指定一个主机名。即本文中的dbrg-2,dbrg-3,因此slaves文件看起来应当是如许的
dbrg-2
dbrg-3
在 conf/目次中的hadoop-default.xml中包孕了Hadoop的全部设置项,但是不允许直接批改!可以在hadoop-conf/目次下 的hadoop-site.xml内里界说我们必要的项,其值会覆盖hadoop-default.xml中的默认值。可以按照本身的实际必要来举办定 制。以下是我的设置档:
fs.default.name
dbrg-1:9000
The name of the default file system. Either the literal string "local" or a host:port for DFS.
mapred.job.tracker
dbrg-1:9001
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.
hadoop.tmp.dir
/home/dbrg/HadoopInstall/tmp
A base for other temporary directories.
dfs.name.dir
/home/dbrg/HadoopInstall/filesystem/name
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.
dfs.data.dir
/home/dbrg/HadoopInstall/filesystem/data
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.
dfs.replication
1
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.