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

Mysql+keepalived High availability Business configuration tutorial

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly gives you a brief introduction to the mysql+keepalived High availability Business configuration tutorial. You can check the relevant professional terms on the Internet or find some related books to supplement them. We won't dabble here. Let's go straight to the topic. I hope this article on mysql+keepalived High availability Business configuration tutorial can bring you some practical help.

Keepalived+mysql

The principle of keepalived:

Use keepalived to realize the high availability of MySQL database.

Because of the high availability, we naturally need MySQL dual master mode, and because of the particularity of the database, we need to pay special attention to the switching between master and slave (not switching as soon as we want to). At this time, we need keepalived non-preemptive mode. So we need to do:

Install MySQL dual active (passive) mode to realize redundant backup of data

Install keepalived mode to realize the failover of MySQL database

Installation and configuration of two mysql:

Yum install mariadb-server-y

The following is the configuration of two mysql dual main modes:

Vim / etc/my.cnf

Log-bin = bin

Relay-log = relay-bin

Server-id = 1

Skip-slave-start = 1

Log-bin must be enabled, which is mainly used for synchronization between master and standby.

It is also necessary for relay-log to rename the following. This parameter may not be configured.

The server-id of the two instances must be configured differently

Skip-slave-start is for data consistency.

Core configuration:

Authorization Log read:

Grant replication slave,replication client on *. * to 'repluser'@'192.168.2.89' identified by' 123456'

Determine the master:

CHANGE MASTER TO MASTER_HOST='d-89',MASTER_USER='replication', MASTER_PASSWORD='123456',MASTER_PORT=3306, MASTER_LOG_FILE='bin.000001',MASTER_LOG_POS=245

The sql thread will be ready after start slave.

User (user of replication slave), the password is correct and the io thread is also correct.

Test whether the dual-master configuration is possible. After the dual-master configuration, the subsequent authorization, which only needs to be done on one machine, will be synchronized to the two machines.

Then authorize the client

Grant select on *. * to ly@'192.168.2.39' identified by'1'

Netstat-tulnp | grep 3306

Show master status\ G

. If there is a problem with the change statement, slave stop.

Create user zyx@192.168.2.110 identified by '123456'

You don't have to create vip users, vip is just a reverse proxy

Let help check the grant and change master to commands.

The location of binlog should be seen on msater.

Add VI-2 vrrp instance to the configuration file of keepalived: id should be different

Vrrp_instance VI_2 {

State MASTER

Interface ens33

Virtual_router_id 52

Priority 100

Advert_int 1

Authentication {

Auth_type PASS

Auth_pass 11

}

Virtual_ipaddress {

192.168.2.110/24 dev ens33 label ens33:1

}

Track_script {

Mysql

}

}

Experimental test:

After downtime of a mysql, the client can still access it normally.

You should also add test scripts for mysql later.

This is the end of the mysql+keepalived High availability Business configuration tutorial. If you want to know about other related issues, you can continue to follow our industry information. Our section will capture some industry news and professional knowledge to share with you every day.

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

Wechat

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

12
Report