节点准备
hostname | ip | 角色 |
---|---|---|
ubuntu-1804-1 | 172.21.73.53 | 从节点 |
ubuntu-1804-2 | 172.21.73.54 | 主节点 |
ubuntu-1804-3 | 172.21.73.55 | 从节点 |
关闭防火墙
sudo ufw disable
配置时钟同步NTP
所有节点安装ntp
sudo apt install ntp
以ubuntu-1804-2为server,在ubuntu-1804-2进行如下修改
修改配置文件vim /etc/ntp.conf,将下述配置注释
#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
进行如下配置,将“restrict default nomodify notrap noquery”这行修改成
restrict default nomodify notrap
restrict 172.21.73.0 mask 255.255.255.0
ubuntu-1804-1和ubuntu-1804-3同样注释下述配置,
#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
新增
server ubuntu-1804-2 prefer
启动ntp服务
systemctl enable ntp
systemctl start ntp
开启使用root登陆
使用普通用户进入root用户
sudo su
设置root密码
passwd root
修改配置
vim /etc/ssh/sshd_config
新增如下配置:
PermitRootLogin yes
重启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]-----+
在ubuntu-1804-2中进入root用户,执行如下命令,提示输入root密码,请输入root密码:
ssh-copy-id ubuntu-1804-1
ssh-copy-id ubuntu-1804-2
ssh-copy-id ubuntu-1804-3
至此,ubuntu-1804-2可以用root用户成功免密登陆ubuntu-1804-1、ubuntu-1804-2、ubuntu-1804-3
mysql安装
sudo apt install mysql-server mysql-client
sudo systemctl enable mysql
sudo systemctl start mysql
默认账号密码在文件/etc/mysql/debian.cnf 中
ubuntu@ubuntu-1804-2:/etc/apt/sources.list.d$ sudo cat /etc/mysql/debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = 0cBYq68fUGyFCpPw
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user =