導(dǎo)讀:集群搭建比較常用的功能,主要作用就是安裝好一個(gè)節(jié)點(diǎn)將配置好的軟件信息scp到其它節(jié)點(diǎn)上,然后修改下相關(guān)的主機(jī)名即可。
1、服務(wù)器列表
IP |
主機(jī)名 |
用戶名 |
備注 |
xxx.xxx.xxx.128 |
test001 |
test |
免密訪問服務(wù)器 |
xxx.xxx.xxx.129 |
test002 |
test |
免密訪問服務(wù)器 |
xxx.xxx.xxx.130 |
test003 |
test |
免密訪問服務(wù)器 |
2、添加Hosts文件
#三臺(tái)服務(wù)器執(zhí)行相同操作
vim /etc/hosts
xxx.xxx.xxx.128 test001
xxx.xxx.xxx.129 test002
xxx.xxx.xxx.130 test003
3、關(guān)閉防火墻
#三臺(tái)服務(wù)器執(zhí)行相同操作
# 臨時(shí)關(guān)閉
開啟:systemctl start firewalld
關(guān)閉:systemctl stop firewalld# 永久關(guān)閉
關(guān)閉:systemctl disable firewalld
開啟:systemctl enable firewalld
4、主機(jī)名修改
#三臺(tái)服務(wù)器執(zhí)行相同操作
1、 hostnamectl set-hostname test001
2、"hostname=test001" >> /etc/sysconfig/network #如果有則修改
5、創(chuàng)建用戶
#三臺(tái)服務(wù)器執(zhí)行相同操作
useradd -m test
6、靜態(tài)IP配置
#由于使用的是虛擬機(jī),所以需要設(shè)置靜態(tài)IP,三臺(tái)服務(wù)器都需要設(shè)置
1、vim
/etc/sysconfig/network-scripts/ifcfg-ens33TYPE=Ethernet
NAME=ens33 #此處根據(jù)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、密鑰生成
#三臺(tái)服務(wù)器執(zhí)行相同操作
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/.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、authorized_keys、known_hosts文件復(fù)制
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、免密測(cè)試
[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.
總結(jié):整體安裝過程雖然比較繁瑣,但是所涉及到的基礎(chǔ)知識(shí)點(diǎn)有很多。
另外大家如果想要學(xué)習(xí)大數(shù)據(jù)哪方面的東西可以給我留言。