centos7下部署mariadb+galera数据库高可用集群

环境准备:

centos7;关闭selinux和firewalld;hosts文件解析;时间同步;root互信;三节点、

环境部署:

设置mariadbyum源并安装(所有节点都要)(下载包的时候会很慢。。。。。)

vi /etc/yum.repos.d/mariadb.repo

  [mariadb]

name = MariaDB

baseurl = http://yum.mariadb.org/10.1/centos7-amd64

gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

gpgcheck=1

enabled=0

  yum --enablerepo=mariadb -y install MariaDB-server galera

配置第一个 节点(172.16.12.91

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://172.16.12.91,172.16.12.92,172.16.12.93”

binlog_format=row

default_storage_engine=InnoDB

innodb_autoinc_lock_mode=2

bind-address=0.0.0.0

 

# add follows

# cluster name

wsrep_cluster_name="MariaDB_Cluster"

# own IP address(当前节点的IP

wsrep_node_address="172.16.12.91"

# replication provider

wsrep_sst_method=rsync

 

启动集群:/bin/galera_new_cluster

设置root用户密码mysql_secure_installation

 

 

 

配置第二个 节点(172.16.12.92)

vi /etc/my.cnf.d/server.cnf

 

[galera]

# Mandatory settings

wsrep_on=ON

wsrep_provider=/usr/lib64/galera/libgalera_smm.so

 

# specify all nodes in cluster

wsrep_cluster_address="gcomm://172.16.12.91,172.16.12.92,172.16.12.93 " 

 

binlog_format=row

default_storage_engine=InnoDB

innodb_autoinc_lock_mode=2

bind-address=0.0.0.0

 

# add follows

# cluster name

wsrep_cluster_name="MariaDB_Cluster"

# own IP address(当前节点的IP

wsrep_node_address="172.16.12.92"

# replication provider

wsrep_sst_method=rsync

 

启动集群节点:systemctl start mariadb

 

 

配置第三个 节点(172.16.12.93)

vi /etc/my.cnf.d/server.cnf

 

[galera]

# Mandatory settings

wsrep_on=ON

wsrep_provider=/usr/lib64/galera/libgalera_smm.so

 

# specify all nodes in cluster(所有节点的IP,这里只有2台机器)

wsrep_cluster_address="gcomm://172.16.12.91,172.16.12.92,172.16.12.93 " 

 

binlog_format=row

default_storage_engine=InnoDB

innodb_autoinc_lock_mode=2

bind-address=0.0.0.0

 

# add follows

# cluster name

wsrep_cluster_name="MariaDB_Cluster"

# own IP address(当前节点的IP

wsrep_node_address="172.16.12.93"

# replication provider

wsrep_sst_method=rsync

 

启动集群节点:systemctl start mariadb

 

 

集群宕机时,运行了/bin/galera_new_cluster命令的节点先启动


你可能感兴趣的:(Linux,OpenStack)