Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Galera cluster-build (2 data nodes + 1 arbitration)

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Installation preparation

Installation package: mariadb-galera-10.0.15-linux-x86_64.tar.gz

Test environment

Ip hostname remarks

192.168.1.111 test1 Node 1

192.168.1.112 test2 Node 2

192.168.1.113 test3 Arbitration Node

1. Close selinux:

Set the selinux of / etc/sysconfig/selinux to disabled

2. Modify or turn off the firewall

Modify the firewall:

Vi / etc/sysconfig/iptables

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 3306-j ACCEPT

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 4444-j ACCEPT

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 4567-j ACCEPT

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 4568-j ACCEPT

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 4569-j ACCEPT

Service iptables restart

Turn off the firewall:

Systemctl stop firewalld service iptables stop

Install lsof (database may not start without installation)

Yum install-y lsof

3. Install the database mariadb

Download the installation package: mariadb-galera-10.0.15-linux-x86_64.tar.gz

Decompression

Tar zxf mariadb-galera-10.0.15-linux-x86_64.tar.gz

Modify address

Mv mariadb-galera-10.0.15-linux-x86_64 / usr/local/mysql

Create a mysql user

Groupadd mysql

Useradd-g mysql mysql

Chmod mysql:mysql-Rf / usr/local/mysql

Chmod + x-Rf / usr/local/mysql

Cp / usr/local/mysql/support-files/my-medium.cnf / etc/my.cnf

Initialize the database

/ usr/local/mysql/scripts/mysql_install_db-user=mysql-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data

Cp / usr/local/mysql/support-files/mysql.server / etc/init.d/mysqld

Add mysql to boot boot

Chkconfig mysql on

Start mysql

Service mysqld start

Set the mysql command

Vi / etc/profile

Add export PATH=/usr/local/mysql/bin:$PATH

Source / etc/profile

Set mysql password

Mysqladmin-u root passwd '123456'

Practical root login

Mysql-uroot-p123456

4. Set up galera cluster

Note: there is already a galera plug-in in mariadb-galera-10.0.15-linux-x86_64.tar.gz, or you can download and install galera installation. The version of the software in the cluster must be consistent.

First start 111l, then 112th, and finally join the arbitration (the configuration of wsrep_cluster_address in wsrep.cnf file is slightly different due to different startup order)

Install galera

Yum install-y galera

Find the wsrep.cnf file

Find /-name wsrep.cnf

Results:

Find:.... / usr/local/mysql/support-files/wsrep.cnf

Copy this file to etc/

Cp / usr/local/mysql/support-files/wsrep.cnf / etc/my.cnf.d/

Modify the configuration file

Vi / etc/my.cnf.d/wsrep.cnf

Wsrep_cluster_name= "my_wsrep_cluster"

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

Wsrep_cluster_address=gcomm://

# the first node starts. The address above is empty, and the subsequent node joins the cluster. Add the ip address of the cluster after gcomm. If port 4567 is not the default, the address format is ip:port.

# wsrep_cluster_address=gcomm://192.168.1.112

Wsrep_node_name='localhost'

Wsrep_node_address=192.168.1.111

Wsrep_sst_method=rsync

Modify / etc/my.cnf

Vim / etc/my.cnf

Add a statement! Includedir / etc/my.cnf.d/

Comment out statement # binlog_format=mixed

Server-id = 1

Galera,server-id in configuration 112is 2, modify node address and cluster gcomm address

Wsrep_cluster_address=gcomm://192.168.1.111

Wsrep_node_name='localhost'

Wsrep_node_address=192.168.1.112

Server-id = 2

5. Set the account number and permissions to access the database

Mysql-u root-p123456

> grant all privileges on *. * to 'root'@'localhost' identified by' 123456'

> grant all privileges on *. * to 'root'@'%' identified by' 123456'

> flush privileges

Modify the corresponding part of the wsrep.cnf file

Vim / etc/my.cnf.d/wsrep.cnf

Wsrep_sst_auth=root:

6. Start the cluster

Start 111 first, then start 112, and finally join 113 arbitration node

Execute service mysqld start on 111and 112respectively

Enforcement on 113 arbitration

(when starting the quorum node, you may encounter a missing libssl.so.6 file and need to add a soft connection with ln)

Garbd-a "gcomm://192.168.1.111:4567192.168.1.112:4567-g my_wsrep_cluster-d

Modify the listening port of the arbitration node to prevent conflicts with the database

Garbd-a "gcomm://192.168.1.111:4567192.168.1.112:4567?gmcast.listen_addr=tcp://0.0.0.0:4569&pc.wait_prim=no"-g my_wsrep_cluster-d

After executing the command, use ps-ef | grep garbd to view the process

7. Check the cluster status

After executing the command, use ps-ef | grep garbd to view the process

View the status in the database on 111 and 112

Mysql-uroot-p123456

> show status like 'wsrep%'

View wsrep_incoming_addresses 192.168.1.111VOR 3306192.168.1.112VRO 3306

Wsrep_cluster_size 3

Complete the cluster

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report