本文介绍: 选择完整克隆,得到基于hadoop122的两台虚拟机hadoop123和hadoop124。hadoop124和hadoop122也按照同样模式修改主机名。修改hadoop22 ip:192.168.80.122。在里面追加自己主机名和ip的关系,三个虚拟机依次来一遍。通过主机登录,需要修改配置文件。点击生成mac地址,多点两下。hadoop 124操作如上。这个安全子模块会影响ssh。ssh基于密码实现远程登录。分别关掉selinux。使用ssh完成免密登录。三台机器分别关防火墙。ssh ip地址。
一 在vm中选择克隆选项
选择完整克隆,得到基于hadoop122的两台虚拟机hadoop123和hadoop124
首先配置hadoop123的mac地址
网络适配器,高级
点击生成mac地址,多点两下
hadoop 124操作如上
二 配置IP地址
修改hadoop22 ip:192.168.80.122
为 : 192.168.80.123
UUID随便修改一位
# 重启网卡
systemctl restart network
# 检查网络是否变更
ip addr
# 修改主机名为hadoop123,如下图所示
hadoop124和hadoop122也按照同样模式修改主机名
三台机器分别关防火墙
# 查看防火墙状态
[root@hadoop122 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@hadoop122 ~]# systemctl disabled firewalld
Unknown operation 'disabled'.
# 设置防火墙功能失效,开机自动关闭
[root@hadoop122 ~]# systemctl disable firewalld
# 关闭防火墙
[root@hadoop122 ~]# systemctl stop firewalld
[root@hadoop122 ~]#
[root@hadoop122 ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@hadoop123 ~]# ssh 192.168.80.122
The authenticity of host '192.168.80.122 (192.168.80.122)' can't be established.
ECDSA key fingerprint is SHA256:AAiu5mU3Ibf//CJbobg3+munBUo6nOvgV/VecInV9c8.
ECDSA key fingerprint is MD5:a7:eb:75:65:e6:09:16:88:2b:fd:fa:bf:23:fb:ba:12.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added '192.168.80.122' (ECDSA) to the list of known hosts.
root@192.168.80.122's password:
Last login: Fri Apr 21 22:02:38 2023 from 192.168.80.1
declare -x HISTCONTROL="ignoredups"
declare -x HISTSIZE="1000"
declare -x HOME="/root"
declare -x HOSTNAME="hadoop122"
declare -x JAVA_HOME="/usr/java/jdk1.8.0_261/"
declare -x LANG="zh_CN.UTF-8"
declare -x LESSOPEN="||/usr/bin/lesspipe.sh %s"
declare -x LOGNAME="root"
declare -x LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:"
declare -x MAIL="/var/spool/mail/root"
declare -x OLDPWD
declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
declare -x PWD="/root"
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x SSH_CLIENT="192.168.80.123 43738 22"
declare -x SSH_CONNECTION="192.168.80.123 43738 192.168.80.122 22"
declare -x SSH_TTY="/dev/pts/0"
declare -x TERM="xterm"
declare -x USER="root"
declare -x XDG_RUNTIME_DIR="/run/user/0"
declare -x XDG_SESSION_ID="3"
root@hadoop122 ~]# ssh 192.168.80.124
The authenticity of host '192.168.80.124 (192.168.80.124)' can't be established.
ECDSA key fingerprint is SHA256:AAiu5mU3Ibf//CJbobg3+munBUo6nOvgV/VecInV9c8.
ECDSA key fingerprint is MD5:a7:eb:75:65:e6:09:16:88:2b:fd:fa:bf:23:fb:ba:12.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.80.124' (ECDSA) to the list of known hosts.
root@192.168.80.124's password:
Last login: Fri Apr 21 22:02:33 2023 from 192.168.80.1
declare -x HISTCONTROL="ignoredups"
declare -x HISTSIZE="1000"
declare -x HOME="/root"
declare -x HOSTNAME="hadoop124"
declare -x JAVA_HOME="/usr/java/jdk1.8.0_261/"
declare -x LANG="zh_CN.UTF-8"
declare -x LESSOPEN="||/usr/bin/lesspipe.sh %s"
declare -x LOGNAME="root"
declare -x LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:"
declare -x MAIL="/var/spool/mail/root"
declare -x OLDPWD
declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
declare -x PWD="/root"
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x SSH_CLIENT="192.168.80.122 42110 22"
declare -x SSH_CONNECTION="192.168.80.122 42110 192.168.80.124 22"
declare -x SSH_TTY="/dev/pts/1"
declare -x TERM="xterm"
declare -x USER="root"
declare -x XDG_RUNTIME_DIR="/run/user/0"
declare -x XDG_SESSION_ID="2"
[root@hadoop124 ~]# exit
登出
Connection to 192.168.80.124 closed.
[root@hadoop122 ~]#
vi /etc/hosts
192.168.80.122 hadoop122
192.168.80.123 hadoop123
192.168.80.124 hadoop124
[root@hadoop124 ~]# ssh hadoop123
The authenticity of host 'hadoop123 (192.168.80.123)' can't be established.
ECDSA key fingerprint is SHA256:AAiu5mU3Ibf//CJbobg3+munBUo6nOvgV/VecInV9c8.
ECDSA key fingerprint is MD5:a7:eb:75:65:e6:09:16:88:2b:fd:fa:bf:23:fb:ba:12.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'hadoop123,192.168.80.123' (ECDSA) to the list of known hosts.
root@hadoop123's password:
Last login: Fri Apr 21 22:02:29 2023 from 192.168.80.1
declare -x HISTCONTROL="ignoredups"
declare -x HISTSIZE="1000"
declare -x HOME="/root"
declare -x HOSTNAME="hadoop123"
declare -x JAVA_HOME="/usr/java/jdk1.8.0_261/"
declare -x LANG="zh_CN.UTF-8"
declare -x LESSOPEN="||/usr/bin/lesspipe.sh %s"
declare -x LOGNAME="root"
declare -x LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:"
declare -x MAIL="/var/spool/mail/root"
declare -x OLDPWD
declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
declare -x PWD="/root"
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x SSH_CLIENT="192.168.80.124 44462 22"
declare -x SSH_CONNECTION="192.168.80.124 44462 192.168.80.123 22"
declare -x SSH_TTY="/dev/pts/1"
declare -x TERM="xterm"
declare -x USER="root"
declare -x XDG_RUNTIME_DIR="/run/user/0"
declare -x XDG_SESSION_ID="2"
[root@hadoop123 ~]#
三 三台设备基于秘钥实现免密登录
1 三台设备分别执行下面的指令,产生公钥和私钥
[root@hadoop122 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
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.
The key fingerprint is:
SHA256:2Vq/ZXyDyYoYrgc+dSy+60AHoagQEOEdPz5jnNYnn/c root@hadoop122
The key's randomart image is:
+---[RSA 2048]----+
|*o . . |
|..o + . |
|.o o + |
|o o = o |
|. X +S.o |
| +.+o+=....o |
| ..+.+o ..++..|
| oooo o o+ ..|
| .=*o. ..E |
+----[SHA256]-----+
[root@hadoop122 ~]# ll -a
总用量 36
dr-xr-x---. 4 root root 196 4月 21 22:16 .
dr-xr-xr-x. 17 root root 244 4月 21 22:01 ..
-rw-------. 1 root root 1234 4月 15 20:38 anaconda-ks.cfg
-rw-------. 1 root root 3423 4月 21 22:24 .bash_history
-rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout
-rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 12月 29 2013 .bashrc
-rw-r--r--. 1 root root 100 12月 29 2013 .cshrc
drwxrwxrwx. 2 root root 20 4月 18 17:45 for
-rw-------. 1 root root 919 4月 21 02:25 .mysql_history
drwx------ 2 root root 57 4月 21 22:35 .ssh
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
-rw-------. 1 root root 3644 4月 21 02:30 .viminfo
[root@hadoop122 ~]# cd .ssh/
[root@hadoop122 .ssh]# ll
总用量 12
-rw------- 1 root root 1675 4月 21 22:35 id_rsa
-rw-r--r-- 1 root root 396 4月 21 22:35 id_rsa.pub
-rw-r--r-- 1 root root 176 4月 21 22:16 known_hosts
[root@hadoop122 .ssh]#
2 给hadoop124和hadoop123 和hadoop122执行下列指令,将123和124的公钥拷贝给122
执行
[root@hadoop123 ~]# ssh-copy-id hadoop122
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'hadoop122 (192.168.80.122)' can't be established.
ECDSA key fingerprint is SHA256:AAiu5mU3Ibf//CJbobg3+munBUo6nOvgV/VecInV9c8.
ECDSA key fingerprint is MD5:a7:eb:75:65:e6:09:16:88:2b:fd:fa:bf:23:fb:ba:12.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@hadoop122's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'hadoop122'"
and check to make sure that only the key(s) you wanted were added.
[root@hadoop123 ~]#
[root@hadoop122 .ssh]# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDALfG02gQRsrN85OzNg5rDNbs5BFCUWWmgwBYJBgOFA9Y+5vs/ZN67RBYpbYo1z2mdN+M47ZjolyTN1w80o2+N+t2uCwAdxY+AB6a+rrThGxkA1RVTJfCZuPbQpsQa1czCUjxrb+Q24P7QtP0Hl++ncMYbkFvEmLFdWMXNK9zjJkNPAZmGGlJ22ujQeiOfZkgx34FpDWAtZ9H/iQnPEr7szJW8EGipox5AvrvZWwc//dt2WJiHjPcjF1+mZ4CQrZoY0hUeJt4+aZgSKBPngjk1coST9LecSkDfVdGMdCqhP7mkhRy1dFmzeEsmV1El0oVgm7Ovn82KFEUDn6mwnrYv root@hadoop123
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDILOlaUsyYp2sL9Rd5T6DcvR+N3xjRge5wCyHv+HE+OIMdPGOGSUmgtOkrIaj+KCIRLkkmD4EX+ihePNDwu1KwIryf54nCecsNC4cCttxz1ZpojznmxvlfRsyRlahD4+3zGvvMXO6e6SEqJKadm6NmXWDKVHDG7n+0FI4lcsigpdshYKdiLYKqDxuerGN/Ra23YNVthNzNzjbJb6wcxiSbcHaURDMZgk10BMUrxhZTlXjKseEgMEfJmXNHPz0nHJrGsRrAtgei2V8AM1TzwZVT+DZkaew0WnZpSH0Y76NVg5gYhzJm/hNATzmrgktcHJAJlF9vxNOdFSgd1lG8TnDF root@hadoop124
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK0XicamcOBMiWotiuPoK2UK/DcHbcleD0XKqEFl8elQS3Xl1vSQIq5wResjnURPC2qDJ7Xl/+bsOdMYywNTBrCtPPa5zBQq4VQBzrzswVI+pu01iRgMJ6CP6lvwxyA/iI/kI4qnTz5paJprh+c5jqHEoarQ+tSF0QSS/pEBzcfhq7MpmhCy8p/DGcFLu8Q7TdnzNFHJQigVMVyA6GXezdzci5pg2r8y0lWw4Dxu+8pITeONLcTH1OVspGT2WbArMTvXekSy8dZ+T612UWuV2BcfhZRV7188VNzqCuwaOLuAVQJVH9bxkLtE14/zg0VmhDueU0FYxzRJT5WnXKg1Rr root@hadoop122
[root@hadoop122 .ssh]#
3. 将122的公钥分别分发给123和124
[root@hadoop122 .ssh]# scp authorized_keys hadoop123:$PWD
The authenticity of host 'hadoop123 (192.168.80.123)' can't be established.
ECDSA key fingerprint is SHA256:AAiu5mU3Ibf//CJbobg3+munBUo6nOvgV/VecInV9c8.
ECDSA key fingerprint is MD5:a7:eb:75:65:e6:09:16:88:2b:fd:fa:bf:23:fb:ba:12.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'hadoop123,192.168.80.123' (ECDSA) to the list of known hosts.
root@hadoop123's password:
authorized_keys 100% 1188 2.4MB/s 00:00
[root@hadoop122 .ssh]#
[root@hadoop122 .ssh]# scp authorized_keys hadoop124:$PWD
The authenticity of host 'hadoop124 (192.168.80.124)' can't be established.
ECDSA key fingerprint is SHA256:AAiu5mU3Ibf//CJbobg3+munBUo6nOvgV/VecInV9c8.
ECDSA key fingerprint is MD5:a7:eb:75:65:e6:09:16:88:2b:fd:fa:bf:23:fb:ba:12.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'hadoop124' (ECDSA) to the list of known hosts.
root@hadoop124's password:
authorized_keys 100% 1188 2.6MB/s 00:00
[root@hadoop122 .ssh]#
原文地址:https://blog.csdn.net/CNMBZY/article/details/130283449
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_47512.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。