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

@@ -6,7 +6,7 @@ tags: ["mariadb", "galera"]
categories: ["database"]
---
# 环境
## 环境
cpu | mem | hostname | public ip | cluster ip | CentOS | MariaDB
---- | ---- | ---- | ---- | ---- | ---- | ----
双核 | 2GB | mariadb_1 | 10.0.0.231 | 10.10.10.1 | 7.5 | 10.1.33
@@ -14,8 +14,8 @@ cpu | mem | hostname | public ip | cluster ip | CentOS | MariaDB
双核 | 2GB | mariadb_3 | 10.0.0.233 | 10.10.10.3 | 7.5 | 10.1.33
# 安装数据库
## 离线安装
## 安装数据库
### 离线安装
- [下载 rpm](http://yum.mariadb.org/10.1/centos7-amd64/rpms/)
- MariaDB-10.1.33-centos7-x86_64-client.rpm
- MariaDB-10.1.33-centos7-x86_64-common.rpm
@@ -33,7 +33,7 @@ cpu | mem | hostname | public ip | cluster ip | CentOS | MariaDB
mysql_install_db --user=mysql
```
## yum 安装
### yum 安装
- 创建 MariaDB-10.1 的 yum 源文件(就近选择一个)
```bash
#官方
@@ -68,12 +68,12 @@ cpu | mem | hostname | public ip | cluster ip | CentOS | MariaDB
# galera_4 会作为依赖自动安装
```
# 启动server
## 启动server
```bash
systemctl start mariadb
```
# 安全设置
## 安全设置
- 设置root账户密码推荐
```bash
mysqladmin -u root password 'password'
@@ -83,7 +83,7 @@ cpu | mem | hostname | public ip | cluster ip | CentOS | MariaDB
mysql_secure_installation
```
# 配置Galera Cluster
## 配置Galera Cluster
- 修改/etc/my.cnf.d/server.cnf如下
```
[server]
@@ -114,12 +114,12 @@ cpu | mem | hostname | public ip | cluster ip | CentOS | MariaDB
[mariadb-10.1]
```
# 停止 server
## 停止 server
```bash
systemctl stop mariadb
```
# 启动集群
## 启动集群
- 启动 galera cluster
```bash
mysqld --wsrep-new-cluster --user=mysql
@@ -137,7 +137,7 @@ cpu | mem | hostname | public ip | cluster ip | CentOS | MariaDB
show status like 'wsrep_%';
```
# 注意事项
## 注意事项
- 防火墙开放 3306、4444 和 4567 端口
- 关闭 selinux
- 集群关闭时,/var/lib/mysql/grastate.dat 文件中 safe_to_bootstrap 项为 1 的节点服务器是最后关闭的数据库,数据最全,所以下次集群启动时应从这台节点服务器启动