首页 > 代码库 > Hadoop.2.x_无秘钥设置
Hadoop.2.x_无秘钥设置
1、在实际生产环境中为Hadoop配置无秘钥登录非常有必要
# 在没有配置时:
[liuwl@linux-66-64 hadoop-2.5.0]$ jps 26163 Jps [liuwl@linux-66-64 hadoop-2.5.0]$ sbin/start-yarn.sh starting yarn daemons starting resourcemanager, logging to /home/liuwl/opt/modules/hadoop-2.5.0/logs/yarn-liuwl-resourcemanager-linux-66-64.liuwl.com.out liuwl@linux-66-64.liuwl.com‘s password: # 启动 nodemanager 需要密码 linux-66-64.liuwl.com: starting nodemanager, logging to /home/liuwl/opt/modules/hadoop-2.5.0/logs/yarn-liuwl-nodemanager-linux-66-64.liuwl.com.out [liuwl@linux-66-64 hadoop-2.5.0]$ jps 27134 ResourceManager 27475 Jps 27417 NodeManager [liuwl@linux-66-64 hadoop-2.5.0]$ sbin/stop-yarn.sh stopping yarn daemons stopping resourcemanager liuwl@linux-66-64.liuwl.com‘s password: # 关闭 nodemanager 需要密码 linux-66-64.liuwl.com: stopping nodemanager no proxyserver to stop
# 可想,实际生产中无秘钥登录的重要性
2、生成公钥与私钥
做好无秘钥登录用户选择(在每个用户下都会有个二.ssh文件夹,默认为空)
[liuwl@linux-66-64 .ssh]$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/liuwl/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/liuwl/.ssh/id_rsa. Your public key has been saved in /home/liuwl/.ssh/id_rsa.pub. The key fingerprint is: 12:26:91:a1:da:29:91:a7:ec:3e:1a:f6:92:f5:7d:cc liuwl@linux-66-64.liuwl.com The key‘s randomart image is: +--[ RSA 2048]----+ | oo | | . ... | |o o . o | |.* . o . | |+.o . S | |.. . . | |.oo . . o | |o=. . . E | |o.o. . | +-----------------+ [liuwl@linux-66-64 .ssh]$ ls id_rsa id_rsa.pub # 私钥与公钥
3、发送到节点(机器)上
[liuwl@linux-66-64 .ssh]$ hostname linux-66-64.liuwl.com [liuwl@linux-66-64 .ssh]$ ssh-copy-id linux-66-64.liuwl.com The authenticity of host ‘linux-66-64.liuwl.com (192.168.0.111)‘ can‘t be established. # 第一次设置需要提示是否确定 RSA key fingerprint is 93:26:f9:f8:57:d1:0d:cb:5f:69:87:26:f6:77:f8:e0. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added ‘linux-66-64.liuwl.com,192.168.0.111‘ (RSA) to the list of known hosts. liuwl@linux-66-64.liuwl.com‘s password: # 输入密码 Now try logging into the machine, with "ssh ‘linux-66-64.liuwl.com‘", and check in: .ssh/authorized_keys to make sure we haven‘t added extra keys that you weren‘t expecting. [liuwl@linux-66-64 .ssh]$ ls authorized_keys id_rsa id_rsa.pub known_hosts # authorized_keys 也是公钥,注意秘钥权限不能随便乱改
[liuwl@linux-66-64 .ssh]$ ll total 16 -rw------- 1 liuwl liuwl 409 Oct 14 00:43 authorized_keys -rw------- 1 liuwl liuwl 1675 Oct 14 00:40 id_rsa -rw-r--r-- 1 liuwl liuwl 409 Oct 14 00:40 id_rsa.pub -rw-r--r-- 1 liuwl liuwl 417 Oct 14 00:43 known_hosts [liuwl@linux-66-64 .ssh]$ cat authorized_keys ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5d/DiNJ8BRdsoTlfZqMMY+RUWeUel9oOfSGg/EdVifgryHHpUGc/PziuDZAZb0R/zV9HebYgIZ8YDsJvUOZleUP6n2p+8kRqJGsKCru2lM8lVPtkICZq+KUHHzMvavgwa2K6r9kITc1LMr8plBzdfPkN4uygYK6otLdlAn9qAGAv47FTGcbMJuUhB4e3MKqVg5z5ZFI3FRE3MmLoazVLQ3kCOHlSzUdmJ9ZyAQRdSP9OTSbtL81KSxFIJbvgZ2qoTDL26mjg4rTntvwyXoxPWQ/9twWbJ9Sov1k1SZVHfZ8XnHFsCTF0YzFrxD/UZQUpWnR5/T+/cR2mtU/n08+rtQ== liuwl@linux-66-64.liuwl.com [liuwl@linux-66-64 .ssh]$ cat known_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soTlfZqMMY+RUWeUel9oOfSGg/EdVifgryHHpUGc/PziuDZAZb0R/zV9HebYgIZ8YDsJvUOZleUP6n2p+8kRqJGsKCru2lM8lVPtkICZq+KUHHzMvavgwa2K6r9kITc1LMr8plBzdfPkN4uygYK6otLdlAn9qAGAv47FTGcbMJuUhB4e3MKqVg5z5ZFI3FRE3MmLoazVLQ3kCOHlSzUdmJ9ZyAQRdSP9OTSbtL81KSxFIJbvgZ2qoTDL26mjg4rTntvwyXoxPWQ/9twWbJ9Sov1k1SZVHfZ8XnHFsCTF0YzFrxD/UZQUpWnR5/T+/cR2mtU/n08+rtQ== liuwl@linux-66-64.liuwl.com
4、测试一下
[liuwl@linux-66-64 hadoop-2.5.0]$ sbin/start-yarn.sh starting yarn daemons starting resourcemanager, logging to /home/liuwl/opt/modules/hadoop-2.5.0/logs/yarn-liuwl-resourcemanager-linux-66-64.liuwl.com.out linux-66-64.liuwl.com: starting nodemanager, logging to /home/liuwl/opt/modules/hadoop-2.5.0/logs/yarn-liuwl-nodemanager-linux-66-64.liuwl.com.out [liuwl@linux-66-64 hadoop-2.5.0]$ jps 25171 NodeManager 25072 ResourceManager 25331 Jps
OK!
Hadoop.2.x_无秘钥设置
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。