the database of the master server.1. # mysql-u root-p123456 2. Edit the configuration file my. cnf and add it under [mysqld:1. server-id = 22. You can define it as long as it is unique.3. Save the file and restart mysqld.1. # service mysqld restart4. log on to the mysql server and run the following command.1. mysql> CHANGE MASTER2. MASTER_HOST = 'x. X. X. x ',3.
MySQL master-slave replication:Lab Environment:Linux CentOS7 two: 192.168.230.10 (master)----192.168.230.11 (from) (System installed, switch off the firewall or configure the firewall).MySQL 5.7 (Download the official Yum source, yum install-y MySQL mysql-server)To start the
The data synchronization function of mysql not only provides load balancing for database queries to a certain extent, but also provides great help for database redundancy, backup, recovery, and load balancing. The data synchronization function can be implemented through master-slave replication, while master-slave replication is performed asynchronously.
1.MySQL High-availability backgroundsThe master-slave replication of a database is a useful feature, but it is difficult to ensure its high availability. Implements MySQL master-slave replication high-availability tools, common are:
(1). MMM: Eliminated, there are some problems in consistency and high concurre
new semi-sync solution. Waiting Slave dump is before Storage Commit.
AFTER_COMMIT
The old semi-sync solution ,.
Installation and deployment of semi-synchronous Replication
To use semi-synchronous replication, the following conditions must be met:
1. MySQL 5.5 and later versions
2. The variable have_dynamic_loading is YES.
3. asynchronous
partMaster_log_file file corresponding to masterMaster_log_pos corresponding to master positionRun command: mysql>show slave status\gSlave_io_state, slave_io_running, and slave_sql_running indicate that Slave has not started the replication process. The location of the log is 4 instead of 0, because 0 is only the start of the log file, not the log location. In f
connection, do a quick test, do not change the number of connections to reach 4 o'clock to enable read-write separationVim/opt/mysql-proxy/scripts/rw-splitting.lua=============================--Connection poolIf not Proxy.global.config.rwsplit thenProxy.global.config.rwsplit = {Min_idle_connections = 1,//default is 4Max_idle_connections = 1,//default is 8Is_debug = False}End=============================After the modification is complete,
Record the last transaction GTID value during Backup.
Export data
Mysqldump -- single-transaction -- master-data = 2 -- triggers-routines -- all-databases-uroot-p-P3308> all2. SQL
Import Data
Mysql-uroot-p-P3309
5. Start GTID-based Replication
Change master to master-host = 'master service ip ',
Master_user = 'repl ',
Master_password = 'Password
the master server to the slave server.If the innodb engine is available, copy the innodb data file. The file name may be ibdata1.4. master database: confirm that the file has been generated and copied.Mysql> unlock tables;Slave Server:1. Stop the server used for the slave server and add the following lines to its my. cnf file:[Mysqld]Server-id = slave_idSlave_id distinguishes Master_id values. It must be a positive integer between 2 and 2 ^ 32-1.
2. Start
master, it will sleep and wait for the master to generate a new event. The I/O thread writes these events to the relay log.Step 3: The last step for SQL slave thread to process the process. The SQL thread reads the event from the relay log and executes the event again to update the slave data so that it is consistent with the data in the master. This thread is consistent with the I/O thread,Relay logs are usually stored in the OS cache, so the overhead of relay logs is very small.
Note: The dat
file name and the value of Position, which is recorded for both values. Specify the MySQL master server and set replication information on the MySQL Slave server via the Ansible mysql_replication module. Ansible mysql-slave-m mysql_replication
–a "Login_user=root login_password=123456
mode=changemaster master_
thread (SQL slave thread) handles the last step of the process. The SQL thread reads events from the log and replays the events in them to update the slave data so that it is consistent with the data in master. As long as the thread is consistent with the I/O thread, the trunk log is typically located in the OS cache, so the overhead of the trunk log is minimal. In addition, there is a worker thread in master: As with other MySQL connections, slave
MySQL Semi-synchronous Replication (Semi-synchronous Replication) in enterprise applications, MySQL often uses a master-slave architecture or a master-master architecture to achieve load balancing of MySQL servers, improves the performance of the
MySQL replication table structure, mysql replication StructureIntroduction
Sometimes we need to copy the table structure of a table intact to generate a new table. MYSQL provides two convenient methods.
Example:
CREATE TABLE tb_base(id INT NOT NULL PRIMARY KEY,name VARCHAR(
The replication latency caused by the mutual blocking of MySQL 5.7 concurrent replication and mysqldump.
The MySQL BINLOG and show processlist commands were originally two transactions that could not be reached by the client. However, in the recent troubleshooting, it was found that there was a serious
-uroot-p123 7. MY.CNF Configuration from servercat/etc/my.cnf[Mysqld]server-id=2 and the primary server do not have to be duplicatedmaster-host=192.168.1.131 Primary server IPmaster-user=slave account at loginmaster-password=123 MySQL reads the configuration file, it knows it is running from the server 8. When you read binlog from the server from the primary server to generate problemsmysql-u root-pmysql> Change Master tomysql> master_host= ' 192.168.
Role of the master and slave:
1. It can be used as a backup method.
2. read/write splitting to relieve the pressure on a database
MySQL master-slave backup principle:
Mysql master-slave replication requires at least two Mysql services. Of course, Mysql services can be distri
The role of Master and subordinate:
1. Can be used as a backup method
2. Used to achieve the separation of read and write, ease the pressure of a database
MySQL master-slave backup principle:
MySQL's master-slave replication is at least two MySQL services, of course, MySQL services can be distributed on different s
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.