手机版
你好,游客 登录 注册
背景:
阅读新闻

Hadoop配置自动化之一ssh自动化

[日期:2013-09-23] 来源:Linux社区  作者:fansy1990 [字体:大 中 小]

测试信息:

Hadoop1@Ubuntu:~$ ./generate_ssh_v1 hadoop1 1234

####################################################
 generate the rsa public key on ubuntu ...
####################################################
spawn ssh hadoop1@ubuntu
The authenticity of host 'ubuntu (192.168.128.130)' can't be established.
ECDSA key fingerprint is 53:c7:7a:dc:3b:bc:34:00:4a:6d:18:1c:5e:87:e7:e8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ubuntu,192.168.128.130' (ECDSA) to the list of known hosts.
hadoop1@ubuntu's password:
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.5.0-23-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

Last login: Mon Sep 23 15:22:03 2013 from ubuntu
ssh-keygen -t rsa -P '' -f /home/hadoop1/.ssh/id_rsa
hadoop1@ubuntu:~$ ssh-keygen -t rsa -P '' -f /home/hadoop1/.ssh/id_rsa
Generating public/private rsa key pair.
Your identification has been saved in /home/hadoop1/.ssh/id_rsa.
Your public key has been saved in /home/hadoop1/.ssh/id_rsa.pub.
The key fingerprint is:
e1:5e:20:9d:4e:11:f8:dc:05:35:08:83:5d:ce:99:ed hadoop1@ubuntu
The key's randomart image is:
+--[ RSA 2048]----+
|      +=+o+o    |
|      o..*.+..  |
|      .o*.=..    |
|      =oo..    |
|        S . E    |
|      . .      |
|        .        |
|                |
|                |
+-----------------+
hadoop1@ubuntu:~$ ssh-copy-id -i /home/hadoop1/.ssh/id_rsa.pub ubuntu
hadoop1@ubuntu's password:
Now try logging into the machine, with "ssh 'ubuntu'", and check in:

  ~/.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

hadoop1@ubuntu:~$
####################################################
 copy the namenode's authorized_keys to slaves ...
####################################################
spawn ssh hadoop1@hadoop
The authenticity of host 'hadoop (192.168.128.138)' can't be established.
ECDSA key fingerprint is 10:8f:d1:8e:63:0a:af:1e:fb:d9:a8:bb:9a:39:ab:46.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'hadoop,192.168.128.138' (ECDSA) to the list of known hosts.
hadoop1@hadoop's password:
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.5.0-23-generic i686)

 * Documentation:  https://help.ubuntu.com/

  System information as of Tue Aug  6 20:11:49 CST 2013

  System load:  0.1              Processes:          76
  Usage of /:  24.8% of 7.12GB  Users logged in:    2
  Memory usage: 34%              IP address for eth0: 192.168.128.138
  Swap usage:  0%

  Graph this data and manage this system at https://landscape.canonical.com/

85 packages can be updated.
45 updates are security updates.

Last login: Tue Aug  6 20:11:16 2013 from 192.168.128.130
hadoop1@hadoop:~$ rm -rf /home/hadoop1/.ssh
hadoop1@hadoop:~$ mkdir /home/hadoop1/.ssh
hadoop1@hadoop:~$ spawn scp /home/hadoop1/.ssh/authorized_keys hadoop1@hadoop:/home/hadoop1/.ssh/
hadoop1@hadoop's password:
authorized_keys                                          100%  396    0.4KB/s  00:00   
hadoop1@ubuntu:~$ ssh ubuntu
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.5.0-23-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

Last login: Mon Sep 23 16:13:39 2013 from ubuntu
hadoop1@ubuntu:~$ exit
logout
Connection to ubuntu closed.
hadoop1@ubuntu:~$ ssh hadoop
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.5.0-23-generic i686)

 * Documentation:  https://help.ubuntu.com/

  System information as of Tue Aug  6 20:12:17 CST 2013

  System load:  0.12              Processes:          76
  Usage of /:  24.8% of 7.12GB  Users logged in:    2
  Memory usage: 34%              IP address for eth0: 192.168.128.138
  Swap usage:  0%

  Graph this data and manage this system at https://landscape.canonical.com/

85 packages can be updated.
45 updates are security updates.

Last login: Tue Aug  6 20:11:50 2013 from 192.168.128.130
hadoop1@hadoop:~$ exit
logout
Connection to hadoop closed.

总结:刚开始编写shell的时候连着写 spawn 然后直接敲shell的命令,结果老是expect后面的读不到。。。

更多Ubuntu相关信息见Ubuntu 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=2

 

更多Hadoop相关信息见Hadoop 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=13

 

linux
相关资讯       Hadoop配置  Hadoop ssh 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直���或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款