二、搭建3节点的集群
1 准备3个虚拟机
-
克隆2个虚拟机
- 先关闭虚拟机node1
-
配置虚拟机
-
修改ip地址
-
vim /etc/sysconfig/network-scripts/ifcfg-ens33
-
-
-
修改主机名称
-
vi /etc/hostname
-
-
禁用防火墙
-
systemctl status firewalld #查看防火墙状态 systemctl stop firewalld #关闭防火墙 systemctl disable firewalld #禁用防火墙
-
-
禁用selinux
-
vim /etc/selinux/config
-
-
关闭node2 和node3,才能让之前的配置生效
-
发送hosts文件到其他节点
scp config root@node2:/etc/selinux/config scp config root@node3:/etc/selinux/config
- 先在node1的hosts文件添加3行
vim /etc/hosts
-
192.168.88.100 node1 192.168.88.101 node2 192.168.88.102 node3
-
将这个文件发送到其他节点,2个节点都要
-
scp /etc/hosts root@node3:/etc/ scp /etc/hosts root@node2:/etc/
-
2 免密登录
集群免密登录
1、在ssh服务里面关闭严格模式
2、重启ssh服务
3、生成公钥和私钥
4、3个节点都将公钥发送给node1
5、node1将authorized_keys发送给node2和node3
-
将三个节点的id_rsa.pub生成出来之后使用命令发送给node1
ssh-copy-id node1
-
之后在node1上会生成一个authorized_keys文件这个文件就是所有节点的公钥
-
将这个文件使用scp发送给其他节点
-
scp authorized_keys root@node2:/root/.ssh/
至此完成所有节点的免密登录
-
注意
- 第一次的时候需要输入yes