This commit is contained in:
2021-11-14 15:52:46 +08:00
parent 915c231124
commit 1e344dc204
112 changed files with 1039 additions and 1039 deletions

View File

@@ -7,14 +7,14 @@ tags: ["mysql", "galera"]
categories: ["database"]
---
# 环境
## 环境
cpu | mem | hostname | public ip | cluster ip | CentOS | MySQL
---- | ---- | ---- | ---- | ---- | ---- | ----
双核 | 2GB | mysql_1 | 10.0.0.231 | 10.10.10.1 | 7.5 | 5.7
双核 | 2GB | mysql_2 | 10.0.0.232 | 10.10.10.2 | 7.5 | 5.7
双核 | 2GB | mysql_3 | 10.0.0.233 | 10.10.10.3 | 7.5 | 5.7
# 创建 galera yum 源文件
## 创建 galera yum 源文件
```bash
cat > /etc/yum.repos.d/galera.repo <<-END
[galera]
@@ -31,12 +31,12 @@ cpu | mem | hostname | public ip | cluster ip | CentOS | MySQL
END
```
# 安装
## 安装
```bash
yum install galera-3 mysql-wsrep-5.7 rsync
```
# 修改 /etc/my.cnf
## 修改 /etc/my.cnf
```
[mysqld]
datadir=/var/lib/mysql
@@ -64,14 +64,14 @@ cpu | mem | hostname | public ip | cluster ip | CentOS | MySQL
!includedir /etc/my.cnf.d/
```
# 随机选择一个节点,使用专用脚本 mysqld_bootstrap 初始化集群
## 随机选择一个节点,使用专用脚本 mysqld_bootstrap 初始化集群
```bash
/usr/bin/mysqld_bootstrap
# 该命令会启动本机的 mysqld 服务
systemctl status mysqld
```
# 查找密码,修改初始密码
## 查找密码,修改初始密码
```bash
grep -i password /var/log/messages
# 记录输出的密码
@@ -79,17 +79,17 @@ cpu | mem | hostname | public ip | cluster ip | CentOS | MySQL
# 根据提示输入上一步输出的密码
```
# 在其他节点上启动 mysqld 服务
## 在其他节点上启动 mysqld 服务
```bash
systemctl start mysqld
```
# 查看集群节点数量
## 查看集群节点数量
```sql
show status like 'wsrep_cluster_size';
```
# ssl 加密同步数据(不推荐,存在性能损失)
## ssl 加密同步数据(不推荐,存在性能损失)
- 生成证书
```bash
mkdir /etc/my.cnf.d/ssl && cd /etc/my.cnf.d/ssl
@@ -112,6 +112,6 @@ cpu | mem | hostname | public ip | cluster ip | CentOS | MySQL
- 重新启动集群
# ssl 加密客户端(不推荐,存在性能损失)
## ssl 加密客户端(不推荐,存在性能损失)
- MySQL 5.7 server 自带 ssl 加密,客户端连接时,指定参数 --ssl-mode=required 即可