This is a process of creating duplicate database versions. The replication process not only copies a database, but also synchronizes changes from the master node to a slave node. But this does not mean
This is a process of creating duplicate database versions. The replication process not only copies a database, but also synchronizes changes from the master node to a slave node. But this does not mean
This is a process of creating duplicate database versions. The replication process not only copies a database, but also synchronizes changes from the master node to a slave node. But this does not mean that the slave database is the same as the master database, because replication can be configured to copy only the table structure, rows, or columns, which is called local replication. Replication ensures that specific configuration objects are consistent across different databases.
Mariadb replication Concept
Backup: copy can be used for database backup. For example, when you perform master-> slave replication. If data on the master node is lost (such as hard disk damage), you can recover your database from the node.
Extension: You can use master-> slave replication as an extension solution. For example, if you have large databases and SQL queries, you can use replication to separate these queries from each replication node. The write operation SQL should be performed only on the master node, while the read-only query can be performed on the slave node.
Distribution solution: You can use replication for distribution. For example, you can distribute different sales data to different databases.
Fault solution: assume that you have created a replication structure with the master node> slave Node 1> slave Node 2> slave Node 3. You can write script monitoring for the master node. If the master node fails, the script can quickly switch from node 1 to the new master node, in this way, the replication structure is changed to the master node-> slave Node 1-> slave Node 2. Your application can continue to work without stopping services.
Simple illustration of Replication
Before you start, you should know what binary log files and Ibdata1 are.
The binary log file contains records of all changes to the database, data, and structure, and how long each statement has been executed. Binary log files include a series of log files and an index file. This means that the main SQL statements, such as CREATE, ALTER, INSERT, UPDATE, and DELETE, will be placed in this log file, and the statements such as SELECT will not be recorded, they can be recorded to common queries. log File.
In simple terms, Ibdata1 is a file that includes all tables and all database information.
-------------------------------------- Split line --------------------------------------
Install LAMP (Apache with MariaDB and PHP) in CentOS/RHEL/Scientific Linux 6)
Implementation of MariaDB Proxy read/write splitting
How to compile and install the MariaDB database in Linux
Install MariaDB database using yum in CentOS
Install MariaDB and MySQL
How to migrate MySQL 5.5 database to MariaDB 10 on Ubuntu
Install MariaDB on the Ubuntu 14.04 (Trusty) Server
-------------------------------------- Split line --------------------------------------
Master Server Configuration
First, upgrade the server
We work on the centos7 server.
Install MariaDB
Start MariaDB and enable start with server
The output is as follows:
Check MariaDB status
Sudo service mariadb status
Or use
The output is as follows:
Set MariaDB Password
Here, SOME_ROOT_PASSWORD is your root password. For example, I use q As the password and then try to log on:
The output is as follows:
Enter 'help; 'or' \ H' to view help information. Enter '\ C' to clear the current input statement.
Let's create a database that includes tables with some data
Create Database/Mode
Where:
Output:
Create a Persons Table
The output is as follows:
Insert some data
The output is as follows:
Check Data
The output is as follows:
For more details, please continue to read the highlights on the next page: