Hadoop deployment small script to share

Source: Internet
Author: User
Keywords ssh feet name script and then
Tags .mall aliyun authentication cluster deployment distributed echo etc hadoop

Recently abandoned non-ssh connection http://www.aliyun.com/zixun/aggregation/14119.html"> Hadoop cluster deployment, or returned to the ssh key authentication on the way. There is some trouble inside, each Taiwan machine must upload the public key.I just again I am a lazy person, so write a few small script to complete, as long as the public key can be distributed in a machine above.

The first is to generate the ssh key script

#! / bin / sh

ssh-keygen -t rsa -P '' -f ~ / .ssh / id_rsa

cp ~ / .ssh / id_rsa.pub ~ / .ssh / authorized_keys

ssh-keygen Generally need to enter the passphrase, but usually three Enter passed, I lazy input, plus-P '' on it.

Then add the public key to the slave's script

#! / bin / sh

read-p "Enter the remote server IP:" ip

ssh-copy-id -o StrictHostKeyChecking = no -i ~ / .ssh / id_rsa.pub root @ $ ip

ssh root @ $ ip 'sed -i "s / ^ # RSAAuthentication \ yes / RSAAuthentication \ yes / g" / etc / ssh / sshd_config'

ssh root @ $ ip 'sed -i "s / ^ # PubkeyAuthentication \ yes / PubkeyAuthentication yes / g" / etc / ssh / sshd_config'

ssh root @ $ ip 'sed -i "s / ^ # PermitRootLogin \ yes / PermitRootLogin \ yes / g" / etc / ssh / sshd_config'

ssh root @ $ ip 'service sshd restart'

hostname = `ssh root @ $ {ip} 'hostname'`

echo "Add the host name and IP to the local / etc / hosts file"

echo "$ ip $ hostname" >> / etc / hosts

echo "The remote host host name is $ hostname, check / etc / hosts to ensure that the host name and IP are added to the host list file"

echo "host public key copy completed"

Then the third script reads the host list and copies / etc / hosts to all the hosts

#! / bin / sh

cat / etc / hosts | while read LINE

do

ip = `echo $ LINE | awk '{print $ 1}' | grep -v" :: "| grep -v" 127.0.0.1 "`

echo "Copying / etc / hosts to $ {ip}"

scp -o StrictHostKeyChecking = no / etc / hosts root @ $ {ip}: / etc /

done

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.