1. YUM 更新

2. 主机名称修改

(1)查看当前主机名

  1. $ hostnamectl status
  2. Static hostname: daygeek-Y700
  3. Icon name: computer-laptop
  4. Chassis: laptop
  5. Machine ID: 31bdeb7b83230a2025d43547368d75bc
  6. Boot ID: 267f264c448f000ea5aed47263c6de7f
  7. Operating System: Manjaro Linux
  8. Kernel: Linux 4.19.20-1-MANJARO
  9. Architecture: x86-64

(2)修改主机名

  1. hostnamectl set-hostname [YOUR NEW HOSTNAME]

参考文章: Linux 中改变主机名的 4 种方法

3. 映射主机与IP

集群内的虚拟机都需要修改

  1. [root@node-1 redis-cluster]# vim /etc/hosts
  2. 192.168.0.1 master
  3. 192.168.0.2 slave1
  4. 192.168.0.3 slave2

保存后退出即可

  1. [root@redis ~]# ping slave1
  2. PING slave1 (10.19.134.172) 56(84) bytes of data.
  3. 64 bytes from slave1 (10.19.134.172): icmp_seq=1 ttl=64 time=1.34 ms
  4. 64 bytes from slave1 (10.19.134.172): icmp_seq=2 ttl=64 time=0.752 ms
  5. 64 bytes from slave1 (10.19.134.172): icmp_seq=3 ttl=64 time=0.369 ms
  6. ^C
  7. --- slave1 ping statistics ---
  8. 3 packets transmitted, 3 received, 0% packet loss, time 2001ms
  9. rtt min/avg/max/mdev = 0.369/0.820/1.341/0.401 ms

4. 免密SSH配置

4.1 生成密钥对

分别在三台虚拟机执行密钥生成命令,一路回车

  1. [root@redis ~]# ssh-keygen -t rsa
  2. Generating public/private rsa key pair.
  3. Enter file in which to save the key (/root/.ssh/id_rsa):
  4. Created directory '/root/.ssh'.
  5. Enter passphrase (empty for no passphrase):
  6. Enter same passphrase again:
  7. Your identification has been saved in /root/.ssh/id_rsa.
  8. Your public key has been saved in /root/.ssh/id_rsa.pub.
  9. The key fingerprint is:
  10. SHA256:ArGj5KJEts60ufblXQz8H3xdsajEIhNfLOMgzgAaLQk root@status
  11. The key's randomart image is:
  12. +---[RSA 2048]----+
  13. |E+ . |
  14. |+.o o . |
  15. |.+..+. o o o . |
  16. |oo..+oo = = . o|
  17. |.+o o.=S+ o . ..|
  18. |*.o .* + . . .|
  19. |.= . + + . . |
  20. | .. o . . . o |
  21. |.... . . . |
  22. +----[SHA256]-----+

4.2 将从服务器公钥复制到主服务器上

分表在两台从服务器执行如下命令
从服务器1(slave1):

[root@redis ~]# scp .ssh/id_rsa.pub root@10.19.134.171:~/.ssh/id_rsa.pub.slave1
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.19.134.171' (ECDSA) to the list of known hosts.
root@10.19.134.171's password: 
id_rsa.pub

从服务器2(slave2):

[root@redis ~]# scp .ssh/id_rsa.pub root@10.19.134.171:~/.ssh/id_rsa.pub.slave2
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.19.134.171' (ECDSA) to the list of known hosts.
root@10.19.134.171's password: 
id_rsa.pub

切换到主服务器,查看复制结果

[root@redis .ssh]# ll
总用量 16
-rw------- 1 root root 1679 12月  2 17:06 id_rsa
-rw-r--r-- 1 root root  393 12月  2 17:06 id_rsa.pub
-rw-r--r-- 1 root root  393 12月  2 17:12 id_rsa.pub.slave1
-rw-r--r-- 1 root root  393 12月  2 17:11 id_rsa.pub.slave2

4.3 将公钥加入到被认证的公钥文件

在master主机上操作,将三台虚拟机生成的公钥文件都加入到被认证的公钥文件中

cat ~/.ssh/id_rsa.pub* >> ~/.ssh/authorized_keys

将被认证的公钥文件发送到另外两台从机器中(在master主机上操作)

[root@REDIS .ssh]# scp ~/.ssh/authorized_keys root@10.19.134.173:~/.ssh/
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.19.134.173' (ECDSA) to the list of known hosts.
root@10.19.134.173's password: 
authorized_keys

查看两台从节点虚拟机

# ls .ssh/
authorized_keys  id_rsa  id_rsa.pub  known_hosts

4.4 验证

在三台虚拟机上分别执行下面命令

ssh master
ssh slave1
ssh slave2

链接成功后,执行exit命令退出

参考文章:Centos-SSH免密码登录

5. 安装JAVA运行环境

yum install -y java-11-openjdk-devel.x86_64 java-11-openjdk.x86_64

6. 集群内文件传输脚本

#!/bin/bash
if [ $# -lt 1 ]
then
    echo Not Enough Arguement!
    exit;
fi
for host in hadoop102 hadoop103 hadoop104
do
    echo ====================    $host    ====================
    for file in $@
    do
        if [ -e $file ]
        then
            pdir=$(cd -P $(dirname $file); pwd)
            fname=$(basename $file)
            scp $pdir/$fname $USER@$host:$pdir
        else
            echo $file does not exists!
        fi
    done
done

参考文章:https://blog.csdn.net/qq_41878532/article/details/107778763

7. 单击部署

参考文章: https://www.jianshu.com/p/78f9cc79a766