亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    Hadoop集群配置免密登錄方法

    Hadoop集群包含1個主節(jié)點和3個從節(jié)點,需要實現(xiàn)各節(jié)點之間的免密碼登錄,下面介紹具體的實現(xiàn)方法。

    一、Hadoop集群環(huán)境

    Hadoop集群配置免密登錄方法

    二、免密登錄原理

    每臺主機authorized_keys文件里面包含的主機(ssh密鑰),該主機都能無密碼登錄,所以只要每臺主機的authorized_keys文件里面都放入其他主機(需要無密碼登錄的主機)的ssh密鑰就行了。

     三、實現(xiàn)方法

    1. 配置每個節(jié)點的hosts文件

    #vim /etc/hosts
    1 192.168.44.3 hadoop01
    2 192.168.44.4 hadoop02
    3 192.168.44.5 hadoop03
    4 192.168.44.6 hadoop04

    2. 每個節(jié)點生成ssh密鑰

    [root@hadoop01 ~]# ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa):
    Created directory ‘/root/.ssh’.
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /root/.ssh/id_rsa.
    Your public key has been saved in /root/.ssh/id_rsa.pub.
    …………………

    [root@hadoop01 .ssh]# ls
    id_rsa  id_rsa.pub

    執(zhí)行命令后會在~目錄下生成.ssh文件夾,里面包含id_rsa和id_rsa.pub兩個文件。

    注:使用ssh-keygen -t rsa -P ” -f ~/.ssh/id_rsa命令可避免上述交互式操作。

    3. 在主節(jié)點上將公鑰拷到一個特定文件authorized_keys中。

    [root@hadoop01 ~]# cd .ssh
    [root@hadoop01 .ssh]# ls
    id_rsa  id_rsa.pub
    [root@hadoop01 .ssh]# cp id_rsa.pub authorized_keys
    [root@hadoop01 .ssh]# ls
    authorized_keys  id_rsa  id_rsa.pub

    4. 將authorized_keys文件拷到下一個節(jié)點,并將該節(jié)點的ssh密鑰id_rsa.pub加入該文件中。

    #在hadoop01上使用scp命令實現(xiàn)遠程文件拷貝
    [root@hadoop01 .ssh]# scp authorized_keys  root@hadoop02:/root/.ssh/
    The authenticity of host ‘hadoop02 (192.168.44.11)’ can’t be established.
    ECDSA key fingerprint is SHA256:MyB1zs0E3J/fm8pC0AN8ycsgEIBNHtUqd9xS0WAyv3s.
    ECDSA key fingerprint is MD5:88:48:3a:ba:3e:14:a7:d7:86:f6:51:74:00:10:f9:00.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added ‘hadoop02,192.168.44.11’ (ECDSA) to the list of known hosts.
    root@hadoop02’s password:
    authorized_keys                                                                100%  395  306.2KB/s  00:00   

    #登錄hadoop02主機

    [root@hadoop02 ~]# cd .ssh/
    [root@hadoop02 .ssh]# ls
    authorized_keys id_rsa id_rsa.pub
    [root@hadoop02 .ssh]# cat id_rsa.pub >> authorized_keys #使用cat追加方式

    5. 重復(fù)第4步的操作,依次將hadoop03、hadoop04節(jié)點的ssh密鑰加入到authorized_keys文件中,并將hadoop04節(jié)點生成的authorized_keys文件拷貝到其他三個節(jié)點(hadoop01、hadoop02、hadoop03)即可。

    #登錄hadoop03主機,將ssh密鑰加入authorized_keys文件中
    [root@hadoop03 .ssh]# cat id_rsa.pub >> authorized_keys
    [root@hadoop03 .ssh]# scp authorized_keys root@hadoop04:/root/.ssh/

    #登錄hadoop04主機,將ssh密鑰加入authorized_keys文件中
    [root@hadoop04 .ssh]# cat id_rsa.pub >> authorized_keys

    #將最后生成的authorized_keys文件分別拷貝到hadoop01、hadoop02和hadoop03
    [root@hadoop04 .ssh]# scp authorized_keys root@hadoop01:/root/.ssh/
    [root@hadoop04 .ssh]# scp authorized_keys root@hadoop02:/root/.ssh/
    [root@hadoop04 .ssh]# scp authorized_keys root@hadoop03:/root/.ssh/

    6. 驗證免密登錄

    使用ssh 用戶名@節(jié)點名或ssh ip地址命令驗證免密碼登錄。

    [root@hadoop01 .ssh]# ssh root@hadoop02
    Last login: Tue Feb 12 03:59:46 2019 from 192.168.44.1

    [root@hadoop02 .ssh]# ssh root@hadoop01
    Last login: Tue Feb 12 21:27:24 2019 from hadoop04

    [root@hadoop03 .ssh]# ssh root@hadoop04
    Last login: Tue Feb 12 04:00:47 2019 from 192.168.44.1

    [root@hadoop04 .ssh]# ssh root@hadoop01
    Last login: Tue Feb 12 21:26:44 2019 from hadoop02

    在 Linux Ubuntu 18.04/18.10上安裝Hadoop圖文詳解  http://fxwbio.com/Linux/2018-11/155282.htm

    CentOS 7 下搭建Hadoop 2.9 分布式集群  http://fxwbio.com/Linux/2018-11/155328.htm

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號