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 read-write separation experiment

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Server1 (master) Server2 (slave) Server3 (Middleware middleware)

First of all, build a master-slave database server on server1 and server2

Server1 (master)

Install the software:

Yum install-y mysql mysql-server

Modify configuration file / etc/my.cnf

Start service login authorization:

Server2 (slave)

Install the software:

Yum install-y mysql mysql-server

Modify configuration file / etc/my.cnf

Server3 (middleware)

Install the gcc environment

Yum install-y gcc*

Install jdk (Java environment required to configure amoeba)

Declare how programs written in Java are used (/ etc/profile)

Source / etc/profile (declare the environment)

JAVA_HOME=/amoeba/jdk

Export JAVA_HOME

PATH=$JAVA_HOME/bin:$PATH

Export PATH

CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$CLASSPATH

Export CLASSPTH

Install amoeba

Decompress:

Configure amoeba

Make a copy for server2 (the IP address is the IP of the slave server)

Start amoeba

Modify startup script

Grant execution permissions:

Vim / usr/local/amoeba/bin/amoeba

You need to install the mysql toolkit yum-y install mysql (login address is IP for middleware)

Test:

Stop the stop slave service on the slave server

In server1

In server2

Query on server3 (middleware)

The results show that when I query the information, it provides services to me from the server.

At this point, I add information to the database:

Then check server1 and server2 respectively to see which server the data is written to.

Server1

Server2

In this experiment, data separation is realized.

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

Servers

Wechat

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

12
Report