Mysql master-slave server architecture configuration
The so-called master-slave Mysql server architecture means that operations on the master server are also copied to the slave server.
Next, I will use two machines to do this process.
The role of replication:
1. Data division
2. Implement read load balancing
3. Backup (it cannot back up itself, but it can provide a backup machine)
4 .High availability and failover capabilities
5. Test Mysql upgrade
Types of replication:
a. Statement-based replication
b. Row-based replication
c. Mixed replication (combination of a and b)
Server Address planning
Master server IP: 192.168.1.108
Slave server IP: 192.168.1.110
Experimental topology:
master_mysql-----------------client_mysql
1. Install Mysql
#mkdir -vp /mydata/data
#groupadd -g 3306 mysql mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local
#ln -vs /usr/local/mysql-5.5.15-linux2.6-i686 /usr/local/mysql
# cd /usr/local/mysql
#chown -R mysql:mysql .
#scripts/mysql_install_db --user=mysql --datadir=/mydata/data
#chown -R root .
#cp support-files/mysql. server /etc/init.d/mysqld /data
service mysqld start
Specify the mysql binary file:
#export PATH=$PATH:/usr/local/mysql/bin (temporary)
#vim /etc/profile
Add PATH=$PATH:/usr/local /mysql/bin also works (permanent) to be | GREP mysql m header file:
#LN -SV/USR/LOCAL/MySQL/Include/USR/Include/MySQL
Help information:#vim /etc/man.config man
This configuration needs to be configured on both servers
2. Next, start the real master-slave mysql server configuration
The configuration of the main server is as follows
#vim /etc/my.cnf Add the following information
log-bin=mysql-bin
log-bin-index=mysql-bin.index
binlog-format=maxed
server id = 1
Save after modification is completed, restart Mysql
#service mysqld restart
Then log in to Mysql pair 192.168 .1.110 Host Authorization
#mysql
mysql> GRANT REPLICATION CLIENT,REPLICATION SLAVE ON *.* TO repl@'192.168.1.110'IDENTIFIED BY 'redhat';
mysql> FLUSH PRIVILEGES;
3. Configuration from file
#vim / etc/my.cnf
Comment out log-bin=mysql-bin, binlog-format=maxed
Add relay-log=relay-bin.index, relay-log=relay-bin, replicate-ignore-db=mysql
Modify server-id = 2
Restart Mysql after saving the configuration file
#service mysqld restart
#mysql
mysql> CHANGE MASTER TO MASTER_HOST='192.168.1.108',MASTER_USER='repl',MASTER_PASSWORD='redhat';
mysql> START SLAVE;
mysql> SHOW SLAVE STATUSG;Check the running status of the slave server
If the following information appears, you can be sure that the information has been copied from the master server to the slave server
mysql> SHOW DATABASES;
+--------------------------+
| Database |
+-------------------------- -----+
| information_schema |
| luowei mysql> SELECT * FROM st;
+----+------+
| ID | Name |
+----+------+
| 1 | a |
| 2 | b |
| 3 | c |
| 5 | E |
+----+------+
At this time, the databases on the master and slave servers are synchronized, and the experiment was successful! !

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.
