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 (multi-master and one slave) construction

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

Share

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

Topology Diagram:

Lab environment: (three virtual machines)

Server1 (master1-178), server2 (master2-179), server3 (slave-175)

Master1:

Install softwar

Yum install-y mysql mysql-server

Enable the binlog log function

Start MySQL login and authorize

Master2 (179)

Install MySQL softwar

Yum install-y mysql mysql-server

Enable the binlog log function

Start MySQL login and authorize

Slave (175)

Install softwar

Yum install-y mysql mysql-server

Modify MySQL configuration file to enable Multi function to support multi-threaded MySQL operation

[mysqld_muliti]

Mysqld=/usr/bin/mysqld_safe

Mysqladmin=/usr/bin/mysqladmin

User=root

Password=123

[mysqld178]

Port=3306

Datadir=/var/lib/mysqla

Pid-file=/var/lib/mysqla/mysqld.pid

Socket=/var/lib/mysqla/mysql.sock

User=mysql

Server-id=175

[mysqld179]

Port=3307

Datadir=/var/lib/mysqlb

Pid-file=/var/lib/mysqlb/mysqld.pid

Socket=/var/lib/mysqlb/mysql.sock

User=mysql

Server-id=175

Initialize the generation of mysqa and mysqlb directories

Mysql_install_db-datadir=/var/lib/mysqla-user=mysql

Mysql_install_db-datadir=/var/lib/mysqlb-user=mysql

Modify permissions:

Chown-R mysql / var/lib/mysqla

Chown-R mysql / var/lib/mysqlb

Start the service:

Mysqld_multi-- defaults-file=/etc/my.cnf start 178

Mysqld_multi-defaults-file=/etc/my.cnf start 179

Login test (and do authorization separately):

Mysql-P 3306-S / var/lib/mysqla/mysql.sock

Mysql-P 3307-S / var/lib/mysqlb/mysql.sock

Since their two ports correspond to different servers, we create different database files on the two servers, and then log in to the two ports to view. Each port can only see the corresponding database file, which is a success:

Master1:

Master2:

Log in and view the slave server separately.

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