绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
mysql/mariadb数据的galera集群搭建
2022-05-07 15:04:55

一 安装相同版本的mariadb与galera


1 修改添加本地源

cd /etc/yum.repos.d/

vim CentOS-Base.repo



2 添加hosts

vim /etc/hosts


3 修改hostnames

hostnamectl set-hostname 。。。


4 安装 (确保galera与mariadb与别的几个节点一致)

yum install epel-release -y

yum install um-plugin-priorities -y

yum install MariaDB-client.x86_64 mariadb-server.x86_64 galera percona-xtrabackup -y


5 修改galera的配置文件

cd /etc/my.cnf.d/

vim server.cnf

#

# These two groups are read by the client library

# Use it for options that affect all clients, but not the server

#

[client]

# This group is not read by mysql client library,

# If you use the same .cnf file for MySQL and MariaDB,

# use it for MariaDB-only client options

[client-mariadb]

[root@falcon_db my.cnf.d]# cat server.cnf

[server]

# this is only for the mysqld standalone daemon

[mysqld]

port = 3306

socket = /var/lib/mysql/mysql.sock

skip-external-locking

key_buffer_size = 256M

max_allowed_packet = 1M

table_open_cache = 256

sort_buffer_size = 1M

read_buffer_size = 1M

read_rnd_buffer_size = 4M

myisam_sort_buffer_size = 64M

thread_cache_size = 8

query_cache_size= 16M

# Try number of CPU's*2 for thread_concurrency

thread_concurrency = 8

max_connections = 800

#

log-bin=mysql-bin

binlog_format=mixed

#server-id = 1

#

# * Galera-related settings

#

[galera]

# Mandatory settings

wsrep_on=ON

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

wsrep_cluster_address="gcomm://" #主节点ip

wsrep_cluster_name="wsrep_cluster"

wsrep_node_name=falcon_db #本机hostname

wsrep_node_address= #本机ip

binlog_format=row

default_storage_engine=InnoDB

innodb_autoinc_lock_mode=2

#

# Allow server to accept connections on all interfaces.

#

#bind-address=0.0.0.0

#

# Optional setting

#wsrep_slave_threads=1

#innodb_flush_log_at_trx_commit=0

# this is only for embedded server

[embedded]

# This group is only read by MariaDB servers, not by MySQL.

# If you use the same .cnf file for MySQL and MariaDB,

# you can put MariaDB-only options here

[mariadb]

log-error=/var/log/mariadb/mariadb.log

pid-file=/var/run/mariadb/mariadb.pid

# This group is only read by MariaDB-10.1 servers.

# If you use the same .cnf file for MariaDB of different versions,

# use this group for options that older servers don't understand

[mariadb-10.1]



mkdir -p /var/log/mariadb/

mkdir -p /var/run/mariadb/

chown -R mysql:mysql /var/run/mariadb

chown -R mysql:mysql /var/log/mariadb

service mysql start --wsrep_cluster_address=gcomm://ip地址 每次启动需要指定主节点




show status like “%wsrep%”; 数据库内查看集群信息

  1. show status like 'wsrep_local_state_comment';
  2. show status like 'wsrep_cluster_size';
  3. 来源 
  4. https://zhuanlan.zhihu.com/p/467036685

分享好友

分享这个小栈给你的朋友们,一起进步吧。

MariaDB
创建时间:2022-03-01 11:18:54
MariaDB
展开
订阅须知

• 所有用户可根据关注领域订阅专区或所有专区

• 付费订阅:虚拟交易,一经交易不退款;若特殊情况,可3日内客服咨询

• 专区发布评论属默认订阅所评论专区(除付费小栈外)

技术专家

查看更多
  • itt0918
    专家
戳我,来吐槽~