Node preparation:
I built 3 nodes, and the nodes can be arbitrary. It is recommended to have at least 3
hostname ip roles
ubuntu-1804-1 172.21.73.53 slave node
ubuntu-1804-2 172.21.73.54 master node
ubuntu-1804-3 172.21.73.55 slave node
1: Turn off the firewall of all nodes
sudo ufw disable
2: Configure clock synchronization with NTP
and install ntp on all nodes
sudo apt install ntp
Use ubuntu-1804-2 as the server and make the following modifications on ubuntu-1804-2 ( execute all nodes )
Modify the configuration file vim /etc/ntp.conf and comment the following configuration:
#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst
#pool ntp.ubuntu.com
Add the following from the node:
server ubuntu-1804-2 prefer
Start ntp service
systemctl enable ntp
systemctl start ntp
Three: Configure password-free login (between root users)
1. Use an ordinary user to enter the root user
sudo su
2. Set root password
passwd root
3. Modify configuration
vim /etc/ssh/sshd_config
4. Add the following configuration:
PermitRootLogin yes
5. Restart ssh
systemctl restart sshd
ubuntu-1804-2可以免密登陆ubuntu-1804-1、ubuntu-1804-2、ubuntu-1804-3
root@ubuntu-1804-2:~# ssh-keygen
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:2MRn3ranRz0AFjMqx1t3Qk5QibTnPrw+zR9MY9ftu6s root@ubuntu-1804-3
The key’s randomart image is:
±–[RSA 2048]----+
| .*=+. |
| … .+B. |
| .o++o.= . |
| +o+o.+.o o|
| . S… o…=+|
| .o.=o+|
| .=+oo|
| ++oo| |
oEo+=|
±—[SHA256]-----+
Executing the above command will generate the public and private keys.
Enter the root user in ubuntu-1804-2. Execute the following command and you will be prompted to enter the root password. Please enter root password:
ssh-copy-id ubuntu-1804-1
ssh-copy-id ubuntu-1804-2
ssh-copy-id ubuntu-1804-3
At this point, ubuntu-1804-2 can successfully log in to ubuntu-1804-1, ubuntu-1804-2, and ubuntu-1804-3 as the root user without a password.
Note: Some ssh-copy-id will appear here and the slave node cannot be copied. :
Can be copied manually:
Copy the public key in red brackets of the main node to the green brackets file of other nodes. If there is no such file, you can touch to create a new one. </