Building a Hadoop cluster - SSH configuration

Hadoop control scripts (not daemons) rely on SSH to perform cluster-wide operations. For example, a script can kill and restart all daemons in the cluster. It's worth noting that control scripts are not the only way, there are other ways that users can perform cluster-wide operations (such as a distributed shell).
To support seamless work, SSH needs to allow Hadoop users to log in to machines in the cluster without having to type a password when SSH is installed. The easiest way is to create a public/private key pair, store it in NFS, and let the entire cluster share the key pair.
First, after logging in as a hadoop user account, type the following command to generate an RSA key pair.
    % ssh-keygen -t rsa -f ~/.ssh/id_rsa
passwordless keys are not a good choice although passwordless logins are expected (when running on a local pseudo-distributed cluster, you might as well use an empty password ). Therefore, when prompted for a password, it is best for the user to specify a password. You can use ssh-agent to avoid entering keys one by one for each connection.
The private key is placed in the file specified by the -f option, eg ~/.ssh/id_rsa. The file name for storing the public key is similar to the private key type, but with ".pub" as the suffix, for example ~/.ssh/id_rsa.pub.
Next, make sure the public key is stored in the ~.ssh/authorized_keys file on all machines the user intends to connect to. If the hadoop user's home directory is on an NFS filesystem (as described above), you can share the key across the cluster by typing:
       % cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
If the home directory is not shared via NFS, you need to use other methods to share the public key (eg: ssh-copy-id).
Test if you can ssh from the host machine to the worker machine. If so, ssh-agent is running. Run ssh-add again to store the password. This way, the user can ssh to a working machine without having to enter a password.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326788344&siteId=291194637