Mariadb Gelera 部署-centos7

Mariadb Gelera 部署


1.安装环境

系统:centos7

IP:

节点ipname
第一个节点192.168.1.131node1
第二个节点192.168.1.132node2
第三个节点192.168.1.133node3
2.安装准备

让三个节点互相解析 在/etc/hosts 中添加如下代码:

192.168.1.131   node1
192.168.1.132   node2
192.168.1.133   node3

分别给三个节点设置hostname

[root@node1 ~]# hostnamectl set-hostname node1
[root@node1 ~]# hostnamectl set-hostname node1
[root@node1 ~]# hostnamectl set-hostname node1

关闭防火墙

[root@node1 ~]# systemctl stop firewalld
[root@node1 ~]# systemctl disable firewalld

关闭SELINUX

[root@node1 ~]# vi /etc/selinux/config
修改成如下:
SELINUX=disabled

此时安装准备基本完成,推荐重启使配置生效

验证

[root@node1 ~]# sestatus

SELinux status: disabled

[root@node1 ~]# systemctl status firewalld

● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)

3.安装软件

在安装软件之前先把yum源进行一下配置在三个节点中都要配置:

[root@node1 ~]# vi /etc/yum.repos.d/MariaDB.repo

# MariaDB 10.3 CentOS repository list - created 2018-05-17 15:36 UTC
# http://downloads.mariadb.org/mariadb/repositories
[mariadb]
name = MariaDB
baseurl =https://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos7-amd64
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1

在node1 node2 node3中分别执行:

[root@node1 ~]# yum install -y MariaDB-server

4.配置MariaDB Galera Cluster

在三个节点同时配置 /etc/my.cnf.d/server.cnf

[root@node1 ~]# vi /etc/my.cnf.d/server.cnf

[galera]
# Mandatory settings
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address=gcomm://192.168.0.181,192.168.0.182,192.168.0.183
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2

5.启动 MariaDB cluster

在node1节点上执行:

[root@node1 ~]# galera_new_cluster

执行过后,我们就会有一个 mariadb server 在运行,查看:

[root@node1 ~]# ps -f -u mysql | more

UID PID PPID C STIME TTY TIME CMD
mysql 3472 1 0 14:42 ? 00:00:00 /usr/sbin/mysqld –wsrep-new-cluster –wsrep_start_position=00000000-0000-0000-0000-000000000000:-1

我们可以进入Mariadb中查看节点个数
进入数据库

[root@node1 ~]# mysql -u root

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.3.8-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]>

执行查看命令

MariaDB [(none)]> show global status like ‘wsrep_cluster_size’;
+——————–+——-+
| Variable_name | Value |
+——————–+——-+
| wsrep_cluster_size | 1 |
+——————–+——-+
1 row in set (0.00 sec)

在其他两节点执行:

[root@node2 ~]#systemctl start mariadb.service
就可以直接加入集群

在node1的数据库中执行

MariaDB [(none)]> show global status like
就可以看到节点数量在增加
+——————–+——-+
| Variable_name | Value |
+——————–+——-+
| wsrep_cluster_size | 2 |
+——————–+——-+
1 row in set (0.00 sec)

如此教程有问题,欢迎评论指正
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值