导读:集群搭建比较常用的功能,主要作用就是安装好一个节点将配置好的软件信息scp到其它节点上,然后修改下相关的主机名即可。
1、服务器列表
IP | 主机名 | 用户名 | 备注 |
xxx.xxx.xxx.128 | test001 | test | 免密访问服务器 |
xxx.xxx.xxx.129 | test002 | test | 免密访问服务器 |
xxx.xxx.xxx.130 | test003 | test | 免密访问服务器 |
2、添加Hosts文件
3、关闭防火墙
#三台服务器执行相同操作
# 临时关闭
开启:systemctl start firewalld
关闭:systemctl stop firewalld# 永久关闭
关闭:systemctl disable firewalld
开启:systemctl enable firewalld
4、主机名修改
#三台服务器执行相同操作
1、 hostnamectl set-hostname test001
2、”hostname=test001″ >> /etc/sysconfig/network #如果有则修改
5、创建用户
#三台服务器执行相同操作
useradd -m test
6、静态IP配置
#由于使用的是虚拟机,所以需要设置静态IP,三台服务器都需要设置
1、vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
NAME=ens33 #此处根据ifconfig查看
BOOTPROTO=static
IPV6INIT=no
ONBOOT=yes
IPADDR=xxx.xxx.xxx.129
NETMASK=255.255.255.0
HWADDR=
UUID=
DEVICE=ens33
DNS1=xxx.xxx.xxx.2 #route -n命令查看
2、vim /etc/sysconfig/network
NETWORKING=yes
GATEWAY=xxx.xxx.xxx.2
3、vim /etc/resolv.conf
nameserver=xxx.xxx.xxx.2
7、密钥生成
#三台服务器执行相同操作
1、切换到需要生成密钥的用户
[root@test001 app]# su – test
Last login: Mon Jun 21 14:27:12 CST 2021 on pts/0
2、密钥生成,生成过程一直回车即可,除非指定特殊情况。
[test@test001 ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/test/.ssh/id_rsa):
Created directory ‘/home/test/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/test/.ssh/id_rsa.
Your public key has been saved in /home/test/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:J9MGK9lSw9TWI6iHwuWOEL4XVY4seRCdTnz/4jNlaws test@test001
The key’s randomart image is:
+—[RSA 2048]—-+
| o+ ooo . |
| . +B=o + o |
| . oo*++*o . . |
| o +o=+.=. |
| o =+.S +. |
| . o .o =. + |
| . .E+ . |
| +.o |
| +.. |
+—-[SHA256]—–+
8、免密配置
1、authorized_keys、known_hosts 文件生成
cat ${HOME}/.ssh/id_rsa.pub >> ${HOME}/.ssh/authorized_keys
ssh test@test002 cat ${HOME}/.ssh/id_rsa.pub >> ${HOME}/.ssh/authorized_keys
ssh test@test003 cat ${HOME}/.ssh/id_rsa.pub >> ${HOME}/.ssh/authorized_keys
2、目录权限设置
chmod 700 ${HOME}/.ssh
chmod 600 ${HOME}/.ssh/authorized_keys
3、authorized_keys、known_hosts文件复制
scp ${HOME}/.ssh/authorized_keys test@test002:${HOME}/.ssh/
scp ${HOME}/.ssh/known_hosts test@test002:${HOME}/.ssh/
scp ${HOME}/.ssh/authorized_keys test@test003:${HOME}/.ssh/
scp ${HOME}/.ssh/known_hosts test@test003:${HOME}/.ssh/
9、免密测试
[test@test003 ~]$ ssh test@test001
Last login: Mon Jun 21 16:49:39 2021
[test@test001 ~]$ exit;
logout
Connection to test001 closed.
[test@test003 ~]$ ssh test@test002
Last login: Mon Jun 21 19:11:52 2021
[test@test002 ~]$ exit;
logout
Connection to test002 closed.
总结:整体安装过程虽然比较繁琐,但是所涉及到的基础知识点有很多。
另外大家如果想要学习大数据哪方面的东西可以给我留言。