Discover mysql replication status, include the articles, news, trends, analysis and practical advice about mysql replication status on alibabacloud.com
archive.When flush TABLES with read lock is in effect (that is, the MySQL client program does not exit), read the current binary log name and offset value on the primary server:MySQL > SHOW MASTER STATUS;+---------------+----------+--------------+------------------+| File | Position | binlog_do_db | binlog_ignore_db |+---------------+----------+--------------+------------------+|
MySQL replication is quite complex compared to the replication of NoSQL databases such as MongoDB,redis !
Overview
The primary server first logs data changes to the primary log, then reads the master log on the primary server through the I/O thread from the server, writes it to the relay log from the server, and then the SQL thread reads the relay log and repla
executing the following command on slave:Change MASTER to Master_delay = N; The Master_delay option is added directly #读者可在配置延迟从库Change master.This statement sets the slave database to delay n seconds and then replicates the data with the primary database by logging on to the Slave database server (this is 52) and then executing the following command.mysql> stop Slave;Query OK, 0 rows affected (0.45 sec)mysql> change MASTER to Master_delay = 20; #这是延
database and slave database respectively.Copy codeThe Code is as follows:[Root @ master ~] # Service mysql restart[Root @ slave ~] # Service mysql restart
Step 6: create an account for master-slave replication on the master database
Copy codeThe Code is as follows:[Root @ master ~] # Mysql-uroot-pMysql> grant
configuration content
# Replication Master Server ( Default)
for replication
log-bin=master-bin // Modify
server-ID 1 // primary server, the smaller the number the higher the level
Log-slave-updates=true // Modify[[Email protected] ~]# service mysqld Restart //restart Services
The primary server logs on to MySQL to synchronize permis
account with copy rights4. Start the I/O thread and SQL threadEdit the configuration file, start the trunk log function and define Server-id[Email protected] ~]# vim/etc/mysql/my.cnf #log-bin=mysql-binrelay-log=/mysql/relaylogs/relay-logserver-id = 11View status information for the master nodeMariaDB [(None)]> SHOW MA
that the host name of the synchronization Master is A (IP: 192.168.0.1), the Slave host name is B (IP: 192.168.0.2), and the two basedir directories of MySQL are/usr/local/mysql, datadir is both:/var/lib/mysql.
II. set synchronization server
1. set synchronization Master
Modify the my. cnf file in
# Replication Master
= 203Replicate-do-db = abc # synchronize only the abc LibrarySlave-skip-errors = all # ignore all errors caused by Replication
3. Restart the master-slave mysql server.
/Etc/init. d/mysqld restart
4. Create an account on the master server and authorize slave
Mysql> mysql-u root-p123.comMysql> grant
I. Tutorial purpose:
Mysql also supports semi-synchronous replication in master-slave replication. mysql replication is asynchronous because of poor synchronization performance. After the master database distributes events, you must wait until the slave database completes co
performance bottleneck of the entire system.Of course, there are other replication models, such as multi-level relay and loop replication. The basic principles of these replication models are similar to those mentioned above. I will not explain them in detail here.3. Configure master-slave Replication(1) asynchronous
MySQL replication advantages and principles
Replication transfers the DDL and DML operations of the primary database to the slave database through binary logs, and rewrites the data from the slave database to ensure data synchronization between the slave database and the primary database. MySQL can replicate data from
';Flush privileges;Slave before adding the master information, look at the Bin-log logging location node of the master library and execute it in the Master library:Mysql> Show master status;+-------------------+----------+--------------+------------------+| File | Position | binlog_do_db | binlog_ignore_db |+-------------------+----------+--------------+------------------+| master-bin.000029 | 107 | | |+-------------------+----------+--------------+-
names, set them multiple times.
Next, check whether the server load balancer instance can be correctly connected to the Master instance and have corresponding permissions.
Root $ mysql-hrep1-urep-prepMysql> show grants;+ Certificate ------- +| Grants for rep @ rep2 |+ Certificate ------- +| Grant select, FILE, replication slave on *. * TO 'rep '@ 'rep2 'identified BY password' * 9FF2C222F44C7BBA5CC7E3BE857
password
2. Modify Master server Master#vi /etc/my.cnf [mysqld] log-bin=mysql-bin //[必须]启用二进制日志 server-id=222 //[必须]服务器唯一ID,默认是1,一般取IP最后一段3. Modify the slave from the server:#vi /etc/my.cnf [mysqld] log-bin=mysql-bin //[不是必须]启用二进制日志 server-id=226 //[必须]服务器唯一ID,默认是1,一般取IP最后一段4. Restart MySQL for two servers/etc/init.d/
read the binary log of the master.
Enable the slave Service
The specific implementation process is as follows:
I. preparations:
1. The Master/Slave database versions are best consistent.
2. Data Consistency in the master and slave Databases
Primary Database: 182.92.172.80/linux
Slave Database: 123.57.44.85/linux
2. master database modification:
1. Modify mysql Configuration
Find the configuration file my. cnf (or my. ini) of the primary database
installation module succeeds)# mysql > Set global rpl_semi_sync_slave_enabled = 1;# stop Slave;# start Slave;Finally, the common configuration parameters are written in the configuration file:192.168.1.141:[Mysqld]Rpl_semi_sync_master_enabled=1rpl_semi_sync_master_timeout=1000192.168.1.142:[Mysqld]Rpl_semi_sync_slave_enabled=14. View status information for semi-synchronous replicationExecute the following
Compared with the replication of NoSQL databases such as MongoDB and Redis, MySQL replication is quite complex! Overview first, the master server records data changes to the master log, then reads the master log on the master server from the server through the I/O thread, and writes it to the slave server mysql managem
Binlog, before it is put back to the client;
5.5 integrated into MySQL, in the form of plugins, need to be installed separately
Ensure that Binlog is transferred to at least one slave library after the transaction commits
There is no guarantee that the Binlog of this transaction is done from the library application
A certain reduction in performance
Network exception or outage from library, CARTICU, until timeout
more numbers in hexadecimal notation for this long string. for example, you can change 0 to 1 and 2 to a. You can change it as needed to ensure that it is different from the 41 server.
7. mysql master/slave configuration
1. set server_id and log-bin.
192.168.1.41 master server
Vi/etc/my. cnf;
Modify server_id = 1;
Modify log-bin = mysqlbin-log;
Service mysqld restart mysql service
192.168.1.42 slave server
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.