MySQL/MariaDB数据库的主主复制

                       作者:尹正杰 

版权声明:原创作品,谢绝转载!否则将追究法律责任。

一.主主复制概述

1>.什么是主主复制

  1.   所谓的主主复制,说白了就是两台节点互为主从关系。

2>.主主复制考虑要点

  1.   由于主主复制,2MySQL实例均可以进行写操作,需要考虑客户端在Innodb存储引擎中对同一行的操作,以及自动增长id的关系。

3>.主主复制的缺点

  1.   由于2个节点都可以进行写操作,很容易产生数据不一致的问题,因此生产环境中咱们得慎用呀!
      一般情况下主从复制就够用了,考虑到可用性的话可以对master节点使用keepalived做一个高可用即可~

二.主主复制实战

1>.试验环境说明

  1. [root@node102.yinzhengjie.org.cn ~]# cat /etc/redhat-release
  2. CentOS Linux release 7.6. (Core)
  3. [root@node102.yinzhengjie.org.cn ~]#
  4. [root@node102.yinzhengjie.org.cn ~]# uname -r
  5. 3.10.-.el7.x86_64
  6. [root@node102.yinzhengjie.org.cn ~]#
  7. [root@node102.yinzhengjie.org.cn ~]# uname -m
  8. x86_64
  9. [root@node102.yinzhengjie.org.cn ~]#
  10. [root@node102.yinzhengjie.org.cn ~]# free -h
  11. total used free shared buff/cache available
  12. Mem: .7G 239M .0G 24M 446M .2G
  13. Swap: .9G 0B .9G
  14. [root@node102.yinzhengjie.org.cn ~]#
  15. [root@node102.yinzhengjie.org.cn ~]#
  16. [root@node102.yinzhengjie.org.cn ~]#
  17. [root@node102.yinzhengjie.org.cn ~]# mysql --version
  18. mysql Ver 15.1 Distrib 5.5.-MariaDB, for Linux (x86_64) using readline 5.1
  19. [root@node102.yinzhengjie.org.cn ~]#

node102.yinzhengjie.org.cn节点信息

  1. [root@node103.yinzhengjie.org.cn ~]# cat /etc/redhat-release
  2. CentOS Linux release 7.6. (Core)
  3. [root@node103.yinzhengjie.org.cn ~]#
  4. [root@node103.yinzhengjie.org.cn ~]# uname -r
  5. 3.10.-.el7.x86_64
  6. [root@node103.yinzhengjie.org.cn ~]#
  7. [root@node103.yinzhengjie.org.cn ~]# uname -m
  8. x86_64
  9. [root@node103.yinzhengjie.org.cn ~]#
  10. [root@node103.yinzhengjie.org.cn ~]# free -h
  11. total used free shared buff/cache available
  12. Mem: .7G 245M .9G 8.6M 552M .2G
  13. Swap: .9G 0B .9G
  14. [root@node103.yinzhengjie.org.cn ~]#
  15. [root@node103.yinzhengjie.org.cn ~]# mysql --verwsion
  16. mysql: unknown option '--verwsion'
  17. [root@node103.yinzhengjie.org.cn ~]#
  18. [root@node103.yinzhengjie.org.cn ~]# mysql --version
  19. mysql Ver 15.1 Distrib 5.5.-MariaDB, for Linux (x86_64) using readline 5.1
  20. [root@node103.yinzhengjie.org.cn ~]#
  21. [root@node103.yinzhengjie.org.cn ~]#

node103.yinzhengjie.org.cn节点信息

2>.编辑node102.yinzhengjie.org.cn节点的my.cnf配置文件

  1. [root@node102.yinzhengjie.org.cn ~]# cat /etc/my.cnf
  2. [mysqld]
  3. server-id =               #为当前节点设置一个全局惟一的ID号,用于标识当前MySQL实例
  4. binlog_format = row                 #推荐使用基于行数据的复制
  5. log_bin = /data/mysql/logbin/master-   #需要启用二进制日志,生产环境建议和数据文件分开放存放
  6. relay_log = relay-log-             #relay log的文件路径,默认值hostname-relay-bin
  7. relay_log_index = relay-log-.index          #默认值hostname-relay-bin.index
  8. auto_increment_offset =               #指定当前实例自动增长的开始数字
  9. auto_increment_increment =                  #指定当前实例自动增长的幅度
  10. character-set-server = utf8mb4  
  11. default_storage_engine = InnoDB
  12. datadir = /var/lib/mysql
  13. socket = /var/lib/mysql/mysql.sock
  14.  
  15. [mysqld_safe]
  16. log-error = /var/log/mariadb/mariadb.log
  17. pid-file = /var/run/mariadb/mariadb.pid
  18.  
  19. !includedir /etc/my.cnf.d
  20.  
  21. [root@node102.yinzhengjie.org.cn ~]#
  22. [root@node102.yinzhengjie.org.cn ~]#

3>.启动node102.yinzhengjie.org.cn节点的MySQL实例

  1. [root@node102.yinzhengjie.org.cn ~]# mkdir -pv /data/mysql/logbin/      #创建二进制日志存放目录
  2. mkdir: created directory ‘/data
  3. mkdir: created directory ‘/data/mysql
  4. mkdir: created directory ‘/data/mysql/logbin/’
  5. [root@node102.yinzhengjie.org.cn ~]#
  6. [root@node102.yinzhengjie.org.cn ~]# ll /data/mysql/logbin/
  7. total
  8. [root@node102.yinzhengjie.org.cn ~]#

[root@node102.yinzhengjie.org.cn ~]# mkdir -pv /data/mysql/logbin/     #创建二进制日志存放目录

  1. [root@node102.yinzhengjie.org.cn ~]# ll -d /data/mysql/logbin/
  2. drwxr-xr-x root root Nov : /data/mysql/logbin/
  3. [root@node102.yinzhengjie.org.cn ~]#
  4. [root@node102.yinzhengjie.org.cn ~]# chown -R mysql:mysql /data/mysql/logbin/  #切记要授权!
  5. [root@node102.yinzhengjie.org.cn ~]#
  6. [root@node102.yinzhengjie.org.cn ~]# ll -d /data/mysql/logbin/
  7. drwxr-xr-x mysql mysql Nov : /data/mysql/logbin/
  8. [root@node102.yinzhengjie.org.cn ~]#
  9. [root@node102.yinzhengjie.org.cn ~]#

[root@node102.yinzhengjie.org.cn ~]# chown -R mysql:mysql /data/mysql/logbin/  #切记要授权!

  1. [root@node102.yinzhengjie.org.cn ~]# ll /data/mysql/logbin/
  2. total
  3. [root@node102.yinzhengjie.org.cn ~]#
  4. [root@node103.yinzhengjie.org.cn ~]# ll /var/lib/mysql/
  5. total
  6. [root@node103.yinzhengjie.org.cn ~]#
  7. [root@node102.yinzhengjie.org.cn ~]# systemctl start mariadb      #启动数据库
  8. [root@node102.yinzhengjie.org.cn ~]#
  9. [root@node102.yinzhengjie.org.cn ~]# ll /data/mysql/logbin/
  10. total
  11. -rw-rw---- mysql mysql Nov : master-102.000001
  12. -rw-rw---- mysql mysql Nov : master-102.000002
  13. -rw-rw---- mysql mysql Nov : master-102.000003
  14. -rw-rw---- mysql mysql Nov : master-.index
  15. [root@node102.yinzhengjie.org.cn ~]#
  16. [root@node102.yinzhengjie.org.cn ~]# ll /var/lib/mysql/
  17. total
  18. -rw-rw---- mysql mysql Nov : aria_log.
  19. -rw-rw---- mysql mysql Nov : aria_log_control
  20. -rw-rw---- mysql mysql Nov : ibdata1
  21. -rw-rw---- mysql mysql Nov : ib_logfile0
  22. -rw-rw---- mysql mysql Nov : ib_logfile1
  23. drwx------ mysql mysql Nov : mysql
  24. srwxrwxrwx mysql mysql Nov : mysql.sock
  25. drwx------ mysql mysql Nov : performance_schema
  26. drwx------ mysql mysql Nov : test
  27. [root@node102.yinzhengjie.org.cn ~]#
  28. [root@node102.yinzhengjie.org.cn ~]#

[root@node102.yinzhengjie.org.cn ~]# systemctl start mariadb      #启动数据库

4>.在node102.yinzhengjie.org.cn节点上创建有复制权限的用户账号

  1. [root@node102.yinzhengjie.org.cn ~]# mysql
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is
  4. Server version: 5.5.-MariaDB MariaDB Server
  5.  
  6. Copyright (c) , , Oracle, MariaDB Corporation Ab and others.
  7.  
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9.  
  10. MariaDB [(none)]>
  11. MariaDB [(none)]> SHOW MASTER LOGS;
  12. +-------------------+-----------+
  13. | Log_name | File_size |
  14. +-------------------+-----------+
  15. | master-102.000001 | |
  16. | master-102.000002 | |
  17. | master-102.000003 | |
  18. +-------------------+-----------+
  19. rows in set (0.00 sec)
  20.  
  21. MariaDB [(none)]>
  22. MariaDB [(none)]> GRANT REPLICATION SLAVE ON *.* TO 'copy'@'172.30.1.10%' IDENTIFIED BY 'yinzhengjie';
  23. Query OK, rows affected (0.00 sec)
  24.  
  25. MariaDB [(none)]>
  26. MariaDB [(none)]> SHOW MASTER LOGS;
  27. +-------------------+-----------+
  28. | Log_name | File_size |
  29. +-------------------+-----------+
  30. | master-102.000001 | |
  31. | master-102.000002 | |
  32. | master-102.000003 | |
  33. +-------------------+-----------+
  34. rows in set (0.00 sec)
  35.  
  36. MariaDB [(none)]>
  37. MariaDB [(none)]> SELECT user,host,password FROM mysql.user;
  38. +------+----------------------------+-------------------------------------------+
  39. | user | host | password |
  40. +------+----------------------------+-------------------------------------------+
  41. | root | localhost | |
  42. | root | node102.yinzhengjie.org.cn | |
  43. | root | 127.0.0.1 | |
  44. | root | :: | |
  45. | | localhost | |
  46. | | node102.yinzhengjie.org.cn | |
  47. | copy | 172.30.1.10% | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 |
  48. +------+----------------------------+-------------------------------------------+
  49. rows in set (0.00 sec)
  50.  
  51. MariaDB [(none)]>
  52. MariaDB [(none)]>

MariaDB [(none)]> GRANT REPLICATION SLAVE ON *.* TO 'copy'@'172.30.1.10%' IDENTIFIED BY 'yinzhengjie';

5>.编辑node103.yinzhengjie.org.cn节点的my.cnf配置文件

  1. [root@node103.yinzhengjie.org.cn ~]# cat /etc/my.cnf
  2. [mysqld]
  3. server-id =
  4. binlog_format = row
  5. log_bin = /data/mysql/logbin/master-
  6. relay_log = relay-log-
  7. relay_log_index = relay-log-.index
  8. auto_increment_offset =         #注意这个起始位置不要和node102.yinzhengjie.org.cn配置一样哟
  9. auto_increment_increment =
  10. character-set-server = utf8mb4
  11. default_storage_engine = InnoDB
  12. datadir = /var/lib/mysql
  13. socket = /var/lib/mysql/mysql.sock
  14.  
  15. [mysqld_safe]
  16. log-error = /var/log/mariadb/mariadb.log
  17. pid-file = /var/run/mariadb/mariadb.pid
  18.  
  19. !includedir /etc/my.cnf.d
  20. [root@node103.yinzhengjie.org.cn ~]#

6>.启动node103.yinzhengjie.org.cn节点的MySQL实例

  1. [root@node103.yinzhengjie.org.cn ~]# install -d /data/mysql/logbin -o mysql -g mysql    #创建存放的二进制目录
  2. [root@node103.yinzhengjie.org.cn ~]#
  3. [root@node103.yinzhengjie.org.cn ~]# ll -d /data/mysql/logbin/
  4. drwxr-xr-x mysql mysql Nov : /data/mysql/logbin/
  5. [root@node103.yinzhengjie.org.cn ~]#
  6. [root@node103.yinzhengjie.org.cn ~]# ll /data/mysql/logbin/
  7. total
  8. [root@node103.yinzhengjie.org.cn ~]#

[root@node103.yinzhengjie.org.cn ~]# install -d /data/mysql/logbin -o mysql -g mysql    #创建存放的二进制目录

  1. [root@node103.yinzhengjie.org.cn ~]# ll /var/lib/mysql/
  2. total
  3. [root@node103.yinzhengjie.org.cn ~]#
  4. [root@node103.yinzhengjie.org.cn ~]# ll /data/mysql/logbin/
  5. total
  6. [root@node103.yinzhengjie.org.cn ~]#
  7. [root@node103.yinzhengjie.org.cn ~]# systemctl start mariadb
  8. [root@node103.yinzhengjie.org.cn ~]#
  9. [root@node103.yinzhengjie.org.cn ~]# ll /var/lib/mysql/
  10. total
  11. -rw-rw---- mysql mysql Nov : aria_log.
  12. -rw-rw---- mysql mysql Nov : aria_log_control
  13. -rw-rw---- mysql mysql Nov : ibdata1
  14. -rw-rw---- mysql mysql Nov : ib_logfile0
  15. -rw-rw---- mysql mysql Nov : ib_logfile1
  16. drwx------ mysql mysql Nov : mysql
  17. srwxrwxrwx mysql mysql Nov : mysql.sock
  18. drwx------ mysql mysql Nov : performance_schema
  19. drwx------ mysql mysql Nov : test
  20. [root@node103.yinzhengjie.org.cn ~]#
  21. [root@node103.yinzhengjie.org.cn ~]# ll /data/mysql/logbin/
  22. total
  23. -rw-rw---- mysql mysql Nov : master-103.000001
  24. -rw-rw---- mysql mysql Nov : master-103.000002
  25. -rw-rw---- mysql mysql Nov : master-103.000003
  26. -rw-rw---- mysql mysql Nov : master-.index
  27. [root@node103.yinzhengjie.org.cn ~]#

[root@node103.yinzhengjie.org.cn ~]# systemctl start mariadb

7>.配置两节点互为主主节点并验证

  1. [root@node103.yinzhengjie.org.cn ~]# mysql
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is
  4. Server version: 5.5.-MariaDB MariaDB Server
  5.  
  6. Copyright (c) , , Oracle, MariaDB Corporation Ab and others.
  7.  
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9.  
  10. MariaDB [(none)]>
  11. MariaDB [(none)]> CHANGE MASTER TO
  12. -> MASTER_HOST='172.30.1.102',
  13. -> MASTER_USER='copy',
  14. -> MASTER_PASSWORD='yinzhengjie',
  15. -> MASTER_PORT=,
  16. -> MASTER_LOG_FILE='master-102.000003',
  17. -> MASTER_LOG_POS=,
  18. -> MASTER_CONNECT_RETRY=;
  19. Query OK, rows affected (0.01 sec)
  20.  
  21. MariaDB [(none)]>
  22. MariaDB [(none)]> SHOW PROCESSLIST;
  23. +----+------+-----------+------+---------+------+-------+------------------+----------+
  24. | Id | User | Host | db | Command | Time | State | Info | Progress |
  25. +----+------+-----------+------+---------+------+-------+------------------+----------+
  26. | | root | localhost | NULL | Query | | NULL | SHOW PROCESSLIST | 0.000 |
  27. +----+------+-----------+------+---------+------+-------+------------------+----------+
  28. row in set (0.00 sec)
  29.  
  30. MariaDB [(none)]>
  31. MariaDB [(none)]> START SLAVE;
  32. Query OK, rows affected (0.00 sec)
  33.  
  34. MariaDB [(none)]>
  35. MariaDB [(none)]> SHOW PROCESSLIST\G
  36. *************************** . row ***************************
  37. Id:
  38. User: root
  39. Host: localhost
  40. db: NULL
  41. Command: Query
  42. Time:
  43. State: NULL
  44. Info: SHOW PROCESSLIST
  45. Progress: 0.000
  46. *************************** . row ***************************
  47. Id:
  48. User: system user
  49. Host:
  50. db: NULL
  51. Command: Connect
  52. Time:
  53. State: Waiting for master to send event
  54. Info: NULL
  55. Progress: 0.000
  56. *************************** . row ***************************
  57. Id:
  58. User: system user
  59. Host:
  60. db: NULL
  61. Command: Connect
  62. Time:
  63. State: Slave has read all relay log; waiting for the slave I/O thread to update it
  64. Info: NULL
  65. Progress: 0.000
  66. rows in set (0.00 sec)
  67.  
  68. MariaDB [(none)]>
  69. MariaDB [(none)]> SHOW SLAVE STATUS\G
  70. *************************** . row ***************************
  71. Slave_IO_State: Waiting for master to send event
  72. Master_Host: 172.30.1.102
  73. Master_User: copy
  74. Master_Port:
  75. Connect_Retry:
  76. Master_Log_File: master-102.000003
  77. Read_Master_Log_Pos:
  78. Relay_Log_File: relay-log-103.000002
  79. Relay_Log_Pos:
  80. Relay_Master_Log_File: master-102.000003
  81. Slave_IO_Running: Yes
  82. Slave_SQL_Running: Yes
  83. Replicate_Do_DB:
  84. Replicate_Ignore_DB:
  85. Replicate_Do_Table:
  86. Replicate_Ignore_Table:
  87. Replicate_Wild_Do_Table:
  88. Replicate_Wild_Ignore_Table:
  89. Last_Errno:
  90. Last_Error:
  91. Skip_Counter:
  92. Exec_Master_Log_Pos:
  93. Relay_Log_Space:
  94. Until_Condition: None
  95. Until_Log_File:
  96. Until_Log_Pos:
  97. Master_SSL_Allowed: No
  98. Master_SSL_CA_File:
  99. Master_SSL_CA_Path:
  100. Master_SSL_Cert:
  101. Master_SSL_Cipher:
  102. Master_SSL_Key:
  103. Seconds_Behind_Master:
  104. Master_SSL_Verify_Server_Cert: No
  105. Last_IO_Errno:
  106. Last_IO_Error:
  107. Last_SQL_Errno:
  108. Last_SQL_Error:
  109. Replicate_Ignore_Server_Ids:
  110. Master_Server_Id:
  111. row in set (0.00 sec)
  112.  
  113. MariaDB [(none)]>
  114. MariaDB [(none)]> SELECT user,host,password FROM mysql.user;
  115. +------+----------------------------+-------------------------------------------+
  116. | user | host | password |
  117. +------+----------------------------+-------------------------------------------+
  118. | root | localhost | |
  119. | root | node103.yinzhengjie.org.cn | |
  120. | root | 127.0.0.1 | |
  121. | root | :: | |
  122. | | localhost | |
  123. | | node103.yinzhengjie.org.cn | |
  124. | copy | 172.30.1.10% | *BD0B1F48FDC55BD27555FC2F22FF29A68A25A1D7 |
  125. +------+----------------------------+-------------------------------------------+
  126. rows in set (0.00 sec)
  127.  
  128. MariaDB [(none)]> SHOW MASTER LOGS;
  129. +-------------------+-----------+
  130. | Log_name | File_size |
  131. +-------------------+-----------+
  132. | master-103.000001 | |
  133. | master-103.000002 | |
  134. | master-103.000003 | |
  135. +-------------------+-----------+
  136. rows in set (0.00 sec)
  137.  
  138. MariaDB [(none)]>
  139. MariaDB [(none)]> QUIT
  140. Bye
  141. [root@node103.yinzhengjie.org.cn ~]#

配置node103.yinzhengjie.org.cn为node102.yinzhengjie.org.cn从节点详细过程

  1. [root@node102.yinzhengjie.org.cn ~]# mysql
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is
  4. Server version: 5.5.-MariaDB MariaDB Server
  5.  
  6. Copyright (c) , , Oracle, MariaDB Corporation Ab and others.
  7.  
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9.  
  10. MariaDB [(none)]>
  11. MariaDB [(none)]> SHOW PROCESSLIST\G
  12. *************************** . row ***************************
  13. Id:
  14. User: root
  15. Host: localhost
  16. db: NULL
  17. Command: Query
  18. Time:
  19. State: NULL
  20. Info: SHOW PROCESSLIST
  21. Progress: 0.000
  22. *************************** . row ***************************
  23. Id:
  24. User: copy
  25. Host: node103.yinzhengjie.org.cn:
  26. db: NULL
  27. Command: Binlog Dump
  28. Time:
  29. State: Master has sent all binlog to slave; waiting for binlog to be updated
  30. Info: NULL
  31. Progress: 0.000
  32. rows in set (0.00 sec)
  33.  
  34. MariaDB [(none)]>
  35. MariaDB [(none)]> SHOW MASTER LOGS;
  36. +-------------------+-----------+
  37. | Log_name | File_size |
  38. +-------------------+-----------+
  39. | master-102.000001 | |
  40. | master-102.000002 | |
  41. | master-102.000003 | |
  42. +-------------------+-----------+
  43. rows in set (0.00 sec)
  44.  
  45. MariaDB [(none)]>
  46. MariaDB [(none)]> QUIT
  47. Bye
  48. [root@node102.yinzhengjie.org.cn ~]#

查看node102.yinzhengjie.org.cn节点的线程数

  1. [root@node103.yinzhengjie.org.cn ~]# mysql
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is
  4. Server version: 5.5.-MariaDB MariaDB Server
  5.  
  6. Copyright (c) , , Oracle, MariaDB Corporation Ab and others.
  7.  
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9.  
  10. MariaDB [(none)]>
  11. MariaDB [(none)]> SHOW PROCESSLIST\G
  12. *************************** . row ***************************
  13. Id:
  14. User: root
  15. Host: localhost
  16. db: NULL
  17. Command: Query
  18. Time:
  19. State: NULL
  20. Info: SHOW PROCESSLIST
  21. Progress: 0.000
  22. *************************** . row ***************************
  23. Id:
  24. User: system user
  25. Host:
  26. db: NULL
  27. Command: Connect
  28. Time:
  29. State: Waiting for master to send event
  30. Info: NULL
  31. Progress: 0.000
  32. *************************** . row ***************************
  33. Id:
  34. User: system user
  35. Host:
  36. db: NULL
  37. Command: Connect
  38. Time:
  39. State: Slave has read all relay log; waiting for the slave I/O thread to update it
  40. Info: NULL
  41. Progress: 0.000
  42. rows in set (0.00 sec)
  43.  
  44. MariaDB [(none)]>
  45. MariaDB [(none)]> QUIT
  46. Bye
  47. [root@node103.yinzhengjie.org.cn ~]#

查看node103.yinzhengjie.org.cn节点的线程数

  1. [root@node102.yinzhengjie.org.cn ~]# mysql
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is
  4. Server version: 5.5.-MariaDB MariaDB Server
  5.  
  6. Copyright (c) , , Oracle, MariaDB Corporation Ab and others.
  7.  
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9.  
  10. MariaDB [(none)]>
  11. MariaDB [(none)]> SHOW DATABASES;
  12. +--------------------+
  13. | Database |
  14. +--------------------+
  15. | information_schema |
  16. | mysql |
  17. | performance_schema |
  18. | test |
  19. +--------------------+
  20. rows in set (0.00 sec)
  21.  
  22. MariaDB [(none)]>
  23. MariaDB [(none)]> CREATE DATABASE devops;
  24. Query OK, row affected (0.00 sec)
  25.  
  26. MariaDB [(none)]>
  27. MariaDB [(none)]> USE devops
  28. Database changed
  29. MariaDB [devops]>
  30. MariaDB [devops]> CREATE TABLE students(id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,name VARCHAR() NOT NULL,sex ENUM('boy','girl') DEFAULT 'boy',age TINYINT UNSIGNED,mobile CHAR(),address VARCHAR());
  31. Query OK, rows affected (0.00 sec)
  32.  
  33. MariaDB [devops]>
  34. MariaDB [devops]> DESC students;
  35. +---------+---------------------+------+-----+---------+----------------+
  36. | Field | Type | Null | Key | Default | Extra |
  37. +---------+---------------------+------+-----+---------+----------------+
  38. | id | int() unsigned | NO | PRI | NULL | auto_increment |
  39. | name | varchar() | NO | | NULL | |
  40. | sex | enum('boy','girl') | YES | | boy | |
  41. | age | tinyint() unsigned | YES | | NULL | |
  42. | mobile | char() | YES | | NULL | |
  43. | address | varchar() | YES | | NULL | |
  44. +---------+---------------------+------+-----+---------+----------------+
  45. rows in set (0.00 sec)
  46.  
  47. MariaDB [devops]> INSERT INTO students SET name='尹正杰',age=,address='北京';
  48. Query OK, row affected (0.00 sec)
  49.  
  50. MariaDB [devops]>
  51. MariaDB [devops]> SELECT * FROM students;
  52. +----+-----------+------+------+--------+---------+
  53. | id | name | sex | age | mobile | address |
  54. +----+-----------+------+------+--------+---------+
  55. | | 尹正杰 | boy | | NULL | 北京 |
  56. +----+-----------+------+------+--------+---------+
  57. row in set (0.00 sec)
  58.  
  59. MariaDB [devops]>
  60. MariaDB [devops]> SHOW MASTER LOGS;
  61. +-------------------+-----------+
  62. | Log_name | File_size |
  63. +-------------------+-----------+
  64. | master-102.000001 | |
  65. | master-102.000002 | |
  66. | master-102.000003 | |
  67. +-------------------+-----------+
  68. rows in set (0.00 sec)
  69.  
  70. MariaDB [devops]>
  71. MariaDB [devops]> SHOW MASTER STATUS;
  72. +-------------------+----------+--------------+------------------+
  73. | File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
  74. +-------------------+----------+--------------+------------------+
  75. | master-102.000003 | | | |
  76. +-------------------+----------+--------------+------------------+
  77. row in set (0.00 sec)
  78.  
  79. MariaDB [devops]>
  80. MariaDB [devops]> QUIT
  81. Bye
  82. [root@node102.yinzhengjie.org.cn ~]#
  83. [root@node102.yinzhengjie.org.cn ~]#

在node102.yinzhengjie.org.cn中创建测试数据

  1. [root@node103.yinzhengjie.org.cn ~]# mysql
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is
  4. Server version: 5.5.-MariaDB MariaDB Server
  5.  
  6. Copyright (c) , , Oracle, MariaDB Corporation Ab and others.
  7.  
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9.  
  10. MariaDB [(none)]>
  11. MariaDB [(none)]> SHOW DATABASES;
  12. +--------------------+
  13. | Database |
  14. +--------------------+
  15. | information_schema |
  16. | devops |
  17. | mysql |
  18. | performance_schema |
  19. | test |
  20. +--------------------+
  21. rows in set (0.00 sec)
  22.  
  23. MariaDB [(none)]>
  24. MariaDB [(none)]> USE devops
  25. Reading table information for completion of table and column names
  26. You can turn off this feature to get a quicker startup with -A
  27.  
  28. Database changed
  29. MariaDB [devops]>
  30. MariaDB [devops]> SHOW TABLES;
  31. +------------------+
  32. | Tables_in_devops |
  33. +------------------+
  34. | students |
  35. +------------------+
  36. row in set (0.00 sec)
  37.  
  38. MariaDB [devops]>
  39. MariaDB [devops]> SELECT * FROM students;
  40. +----+-----------+------+------+--------+---------+
  41. | id | name | sex | age | mobile | address |
  42. +----+-----------+------+------+--------+---------+
  43. | | 尹正杰 | boy | | NULL | 北京 |
  44. +----+-----------+------+------+--------+---------+
  45. row in set (0.00 sec)
  46.  
  47. MariaDB [devops]>
  48. MariaDB [devops]> QUIT
  49. Bye
  50. [root@node103.yinzhengjie.org.cn ~]#

在node103.yinzhengjie.org.cn节点上可以看到和node102.yinzhengjie.org.cn节点一样的数据(配置成功)

  1. [root@node102.yinzhengjie.org.cn ~]# mysql
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is
  4. Server version: 5.5.-MariaDB MariaDB Server
  5.  
  6. Copyright (c) , , Oracle, MariaDB Corporation Ab and others.
  7.  
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9.  
  10. MariaDB [(none)]>
  11. MariaDB [(none)]> SHOW PROCESSLIST\G
  12. *************************** . row ***************************
  13. Id:
  14. User: copy
  15. Host: node103.yinzhengjie.org.cn:
  16. db: NULL
  17. Command: Binlog Dump
  18. Time:
  19. State: Master has sent all binlog to slave; waiting for binlog to be updated
  20. Info: NULL
  21. Progress: 0.000
  22. *************************** . row ***************************
  23. Id:
  24. User: root
  25. Host: localhost
  26. db: NULL
  27. Command: Query
  28. Time:
  29. State: NULL
  30. Info: SHOW PROCESSLIST
  31. Progress: 0.000
  32. rows in set (0.00 sec)
  33.  
  34. MariaDB [(none)]>
  35. MariaDB [(none)]> CHANGE MASTER TO
  36. -> MASTER_HOST='172.30.1.103',
  37. -> MASTER_USER='copy',
  38. -> MASTER_PASSWORD='yinzhengjie',
  39. -> MASTER_PORT=,
  40. -> MASTER_LOG_FILE='master-103.000003',
  41. -> MASTER_LOG_POS=,
  42. -> MASTER_CONNECT_RETRY=;
  43. Query OK, rows affected (0.01 sec)
  44.  
  45. MariaDB [(none)]>
  46. MariaDB [(none)]> START SLAVE;
  47. Query OK, rows affected (0.00 sec)
  48.  
  49. MariaDB [(none)]>
  50. MariaDB [(none)]> SHOW PROCESSLIST\G
  51. *************************** . row ***************************
  52. Id:
  53. User: copy
  54. Host: node103.yinzhengjie.org.cn:
  55. db: NULL
  56. Command: Binlog Dump
  57. Time:
  58. State: Master has sent all binlog to slave; waiting for binlog to be updated
  59. Info: NULL
  60. Progress: 0.000
  61. *************************** . row ***************************
  62. Id:
  63. User: root
  64. Host: localhost
  65. db: NULL
  66. Command: Query
  67. Time:
  68. State: NULL
  69. Info: SHOW PROCESSLIST
  70. Progress: 0.000
  71. *************************** . row ***************************
  72. Id:
  73. User: system user
  74. Host:
  75. db: NULL
  76. Command: Connect
  77. Time:
  78. State: Waiting for master to send event
  79. Info: NULL
  80. Progress: 0.000
  81. *************************** . row ***************************
  82. Id:
  83. User: system user
  84. Host:
  85. db: NULL
  86. Command: Connect
  87. Time:
  88. State: Slave has read all relay log; waiting for the slave I/O thread to update it
  89. Info: NULL
  90. Progress: 0.000
  91. rows in set (0.00 sec)
  92.  
  93. MariaDB [(none)]>
  94. MariaDB [(none)]> SHOW SLAVE STATUS\G
  95. *************************** . row ***************************
  96. Slave_IO_State: Waiting for master to send event
  97. Master_Host: 172.30.1.103
  98. Master_User: copy
  99. Master_Port:
  100. Connect_Retry:
  101. Master_Log_File: master-103.000003
  102. Read_Master_Log_Pos:
  103. Relay_Log_File: relay-log-102.000002
  104. Relay_Log_Pos:
  105. Relay_Master_Log_File: master-103.000003
  106. Slave_IO_Running: Yes
  107. Slave_SQL_Running: Yes
  108. Replicate_Do_DB:
  109. Replicate_Ignore_DB:
  110. Replicate_Do_Table:
  111. Replicate_Ignore_Table:
  112. Replicate_Wild_Do_Table:
  113. Replicate_Wild_Ignore_Table:
  114. Last_Errno:
  115. Last_Error:
  116. Skip_Counter:
  117. Exec_Master_Log_Pos:
  118. Relay_Log_Space:
  119. Until_Condition: None
  120. Until_Log_File:
  121. Until_Log_Pos:
  122. Master_SSL_Allowed: No
  123. Master_SSL_CA_File:
  124. Master_SSL_CA_Path:
  125. Master_SSL_Cert:
  126. Master_SSL_Cipher:
  127. Master_SSL_Key:
  128. Seconds_Behind_Master:
  129. Master_SSL_Verify_Server_Cert: No
  130. Last_IO_Errno:
  131. Last_IO_Error:
  132. Last_SQL_Errno:
  133. Last_SQL_Error:
  134. Replicate_Ignore_Server_Ids:
  135. Master_Server_Id:
  136. row in set (0.00 sec)
  137.  
  138. MariaDB [(none)]>
  139. MariaDB [(none)]> QUIT
  140. Bye
  141. [root@node102.yinzhengjie.org.cn ~]#

配置node102.yinzhengjie.org.cn为node103.yinzhengjie.org.cn从节点详细过程

  1. [root@node102.yinzhengjie.org.cn ~]# mysql
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is
  4. Server version: 5.5.-MariaDB MariaDB Server
  5.  
  6. Copyright (c) , , Oracle, MariaDB Corporation Ab and others.
  7.  
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9.  
  10. MariaDB [(none)]>
  11. MariaDB [(none)]> SHOW PROCESSLIST\G
  12. *************************** . row ***************************
  13. Id:
  14. User: copy
  15. Host: node103.yinzhengjie.org.cn:
  16. db: NULL
  17. Command: Binlog Dump
  18. Time:
  19. State: Master has sent all binlog to slave; waiting for binlog to be updated
  20. Info: NULL
  21. Progress: 0.000
  22. *************************** . row ***************************
  23. Id:
  24. User: system user
  25. Host:
  26. db: NULL
  27. Command: Connect
  28. Time:
  29. State: Waiting for master to send event
  30. Info: NULL
  31. Progress: 0.000
  32. *************************** . row ***************************
  33. Id:
  34. User: system user
  35. Host:
  36. db: NULL
  37. Command: Connect
  38. Time:
  39. State: Slave has read all relay log; waiting for the slave I/O thread to update it
  40. Info: NULL
  41. Progress: 0.000
  42. *************************** . row ***************************
  43. Id:
  44. User: root
  45. Host: localhost
  46. db: NULL
  47. Command: Query
  48. Time:
  49. State: NULL
  50. Info: SHOW PROCESSLIST
  51. Progress: 0.000
  52. rows in set (0.00 sec)
  53.  
  54. MariaDB [(none)]>
  55. MariaDB [(none)]> SHOW MASTER LOGS;
  56. +-------------------+-----------+
  57. | Log_name | File_size |
  58. +-------------------+-----------+
  59. | master-102.000001 | |
  60. | master-102.000002 | |
  61. | master-102.000003 | |
  62. +-------------------+-----------+
  63. rows in set (0.00 sec)
  64.  
  65. MariaDB [(none)]>
  66. MariaDB [(none)]> QUIT
  67. Bye
  68. [root@node102.yinzhengjie.org.cn ~]#

查看node102.yinzhengjie.org.cn节点的线程数

  1. [root@node103.yinzhengjie.org.cn ~]# mysql
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is
  4. Server version: 5.5.-MariaDB MariaDB Server
  5.  
  6. Copyright (c) , , Oracle, MariaDB Corporation Ab and others.
  7.  
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9.  
  10. MariaDB [(none)]>
  11. MariaDB [(none)]> SHOW PROCESSLIST\G
  12. *************************** . row ***************************
  13. Id:
  14. User: system user
  15. Host:
  16. db: NULL
  17. Command: Connect
  18. Time:
  19. State: Waiting for master to send event
  20. Info: NULL
  21. Progress: 0.000
  22. *************************** . row ***************************
  23. Id:
  24. User: system user
  25. Host:
  26. db: NULL
  27. Command: Connect
  28. Time:
  29. State: Slave has read all relay log; waiting for the slave I/O thread to update it
  30. Info: NULL
  31. Progress: 0.000
  32. *************************** . row ***************************
  33. Id:
  34. User: copy
  35. Host: node102.yinzhengjie.org.cn:
  36. db: NULL
  37. Command: Binlog Dump
  38. Time:
  39. State: Master has sent all binlog to slave; waiting for binlog to be updated
  40. Info: NULL
  41. Progress: 0.000
  42. *************************** . row ***************************
  43. Id:
  44. User: root
  45. Host: localhost
  46. db: NULL
  47. Command: Query
  48. Time:
  49. State: NULL
  50. Info: SHOW PROCESSLIST
  51. Progress: 0.000
  52. rows in set (0.00 sec)
  53.  
  54. MariaDB [(none)]>
  55. MariaDB [(none)]> SHOW MASTER LOGS;
  56. +-------------------+-----------+
  57. | Log_name | File_size |
  58. +-------------------+-----------+
  59. | master-103.000001 | |
  60. | master-103.000002 | |
  61. | master-103.000003 | |
  62. +-------------------+-----------+
  63. rows in set (0.00 sec)
  64.  
  65. MariaDB [(none)]> QUIT
  66. Bye
  67. [root@node103.yinzhengjie.org.cn ~]#
  68. [root@node103.yinzhengjie.org.cn ~]#

查看node103.yinzhengjie.org.cn节点的线程数

  1. [root@node103.yinzhengjie.org.cn ~]# mysql
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is
  4. Server version: 5.5.-MariaDB MariaDB Server
  5.  
  6. Copyright (c) , , Oracle, MariaDB Corporation Ab and others.
  7.  
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9.  
  10. MariaDB [(none)]>
  11. MariaDB [(none)]> USE devops;
  12. Reading table information for completion of table and column names
  13. You can turn off this feature to get a quicker startup with -A
  14.  
  15. Database changed
  16. MariaDB [devops]>
  17. MariaDB [devops]> SHOW TABLES;
  18. +------------------+
  19. | Tables_in_devops |
  20. +------------------+
  21. | students |
  22. +------------------+
  23. row in set (0.00 sec)
  24.  
  25. MariaDB [devops]>
  26. MariaDB [devops]> SELECT * FROM students;
  27. +----+-----------+------+------+--------+---------+
  28. | id | name | sex | age | mobile | address |
  29. +----+-----------+------+------+--------+---------+
  30. | | 尹正杰 | boy | | NULL | 北京 |
  31. +----+-----------+------+------+--------+---------+
  32. row in set (0.00 sec)
  33.  
  34. MariaDB [devops]>
  35. MariaDB [devops]> INSERT INTO students SET name='yinzhengjie',age=,address='shanxi';
  36. Query OK, row affected (0.01 sec)
  37.  
  38. MariaDB [devops]>
  39. MariaDB [devops]> SELECT * FROM students;
  40. +----+-------------+------+------+--------+---------+
  41. | id | name | sex | age | mobile | address |
  42. +----+-------------+------+------+--------+---------+
  43. | | 尹正杰 | boy | | NULL | 北京 |
  44. | | yinzhengjie | boy | | NULL | shanxi |
  45. +----+-------------+------+------+--------+---------+
  46. rows in set (0.00 sec)
  47.  
  48. MariaDB [devops]> QUIT
  49. Bye
  50. [root@node103.yinzhengjie.org.cn ~]#

在node103.yinzhengjie.org.cn中创建测试数据

  1. [root@node102.yinzhengjie.org.cn ~]# mysql
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is
  4. Server version: 5.5.-MariaDB MariaDB Server
  5.  
  6. Copyright (c) , , Oracle, MariaDB Corporation Ab and others.
  7.  
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9.  
  10. MariaDB [(none)]>
  11. MariaDB [(none)]> USE devops
  12. Reading table information for completion of table and column names
  13. You can turn off this feature to get a quicker startup with -A
  14.  
  15. Database changed
  16. MariaDB [devops]>
  17. MariaDB [devops]> SHOW TABLES;
  18. +------------------+
  19. | Tables_in_devops |
  20. +------------------+
  21. | students |
  22. +------------------+
  23. row in set (0.00 sec)
  24.  
  25. MariaDB [devops]>
  26. MariaDB [devops]> SELECT * FROM students;
  27. +----+-------------+------+------+--------+---------+
  28. | id | name | sex | age | mobile | address |
  29. +----+-------------+------+------+--------+---------+
  30. | | 尹正杰 | boy | | NULL | 北京 |
  31. | | yinzhengjie | boy | | NULL | shanxi |
  32. +----+-------------+------+------+--------+---------+
  33. rows in set (0.00 sec)
  34.  
  35. MariaDB [devops]>
  36. MariaDB [devops]> QUIT
  37. Bye
  38. [root@node102.yinzhengjie.org.cn ~]#

在node102.yinzhengjie.org.cn节点上可以看到和node103.yinzhengjie.org.cn节点一样的数据(配置成功)

 

三.主主复制在生产环境中容易出现的问题刨析

1>.在node102.yinzhengjie.org.cn节点的操作

  1. [root@node102.yinzhengjie.org.cn ~]# mysql
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is
  4. Server version: 5.5.-MariaDB MariaDB Server
  5.  
  6. Copyright (c) , , Oracle, MariaDB Corporation Ab and others.
  7.  
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9.  
  10. MariaDB [(none)]>
  11. MariaDB [(none)]>
  12. MariaDB [(none)]>
  13. MariaDB [(none)]> USE devops
  14. Reading table information for completion of table and column names
  15. You can turn off this feature to get a quicker startup with -A
  16.  
  17. Database changed
  18. MariaDB [devops]>
  19. MariaDB [devops]> SELECT * FROM students;
  20. +----+-------------+------+------+--------+---------+
  21. | id | name | sex | age | mobile | address |
  22. +----+-------------+------+------+--------+---------+
  23. | | 尹正杰 | boy | | NULL | 北京 |
  24. | | yinzhengjie | boy | | NULL | shanxi |
  25. +----+-------------+------+------+--------+---------+
  26. rows in set (0.00 sec)
  27.  
  28. MariaDB [devops]>
  29. MariaDB [devops]> INSERT INTO students (name,age,mobile,address) VALUES ('Jason Yin',,,'beijing'),('Jay','',,'Taiwan'); #我们同时往表里插入2条记录
    Query OK, rows affected (0.00 sec)
  30. Records: Duplicates: Warnings:
  31.  
  32. MariaDB [devops]>
  33. MariaDB [devops]> SELECT * FROM students;          #不难发现,node102.yinzhengjie.org.cn自动增长是基于奇数的
  34. +----+-------------+------+------+--------+---------+
  35. | id | name | sex | age | mobile | address |
  36. +----+-------------+------+------+--------+---------+
  37. | | 尹正杰 | boy | | NULL | 北京 |
  38. | | yinzhengjie | boy | | NULL | shanxi |
  39. | | Jason Yin | boy | | | beijing |
  40. | | Jay | boy | | | Taiwan |
  41. +----+-------------+------+------+--------+---------+
  42. rows in set (0.00 sec)
  43.  
  44. MariaDB [devops]>
  45. MariaDB [devops]> QUIT
  46. Bye
  47. [root@node102.yinzhengjie.org.cn ~]#

2>.在node103.yinzhengjie.org.cn节点的操作

  1. [root@node103.yinzhengjie.org.cn ~]# mysql
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is
  4. Server version: 5.5.-MariaDB MariaDB Server
  5.  
  6. Copyright (c) , , Oracle, MariaDB Corporation Ab and others.
  7.  
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  9.  
  10. MariaDB [(none)]>
  11. MariaDB [(none)]> USE devops
  12. Reading table information for completion of table and column names
  13. You can turn off this feature to get a quicker startup with -A
  14.  
  15. Database changed
  16. MariaDB [devops]>
  17. MariaDB [devops]> SELECT * FROM students;      #我们可以发现数据已经同步过来啦!
  18. +----+-------------+------+------+--------+---------+
  19. | id | name | sex | age | mobile | address |
  20. +----+-------------+------+------+--------+---------+
  21. | | 尹正杰 | boy | | NULL | 北京 |
  22. | | yinzhengjie | boy | | NULL | shanxi |
  23. | | Jason Yin | boy | | | beijing |
  24. | | Jay | boy | | | Taiwan |
  25. +----+-------------+------+------+--------+---------+
  26. rows in set (0.00 sec)
  27.  
  28. MariaDB [devops]>
  29. MariaDB [devops]> INSERT students (age,sex,name,mobile,address) VALUES (,'girl','Gloria Tang Tsz-Kei',null,'Hong Kong');      #我们再次插入一条记录
    Query OK, row affected (0.00 sec)
  30.  
  31. MariaDB [devops]>
  32. MariaDB [devops]> SELECT * FROM students;        #我们发现新添加的记录自动增长ID竟然跳过了4,而是直接使用6,起始原因在于在添加记录之前就已经存在最大id数字5啦,虽说自动增长的id依旧是偶数,但这个问题我们得考虑一下哟~
  33. +----+---------------------+------+------+--------+-----------+
  34. | id | name | sex | age | mobile | address |
  35. +----+---------------------+------+------+--------+-----------+
  36. | | 尹正杰 | boy | | NULL | 北京 |
  37. | | yinzhengjie | boy | | NULL | shanxi |
  38. | | Jason Yin | boy | | | beijing |
  39. | | Jay | boy | | | Taiwan |
  40. | | Gloria Tang Tsz-Kei | girl | | NULL | Hong Kong |
  41. +----+---------------------+------+------+--------+-----------+
  42. rows in set (0.00 sec)
  43.  
  44. MariaDB [devops]>
  45. MariaDB [devops]> QUIT
  46. Bye
  47. [root@node103.yinzhengjie.org.cn ~]#
  48. [root@node103.yinzhengjie.org.cn ~]#

MySQL/MariaDB数据库的主主复制的更多相关文章

  1. MySQL/MariaDB数据库的半同步复制

      MySQL/MariaDB数据库的半同步复制 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.MySQL半同步复制概述 1>.MySQL默认的异步复制 默认情况下,M ...

  2. MySQL/MariaDB数据库的主从级联复制

      MySQL/MariaDB数据库的主从级联复制 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.主从复制类型概述 1>.主从复制 博主推荐阅读: https://ww ...

  3. MySQL/MariaDB数据库的复制监控和维护

      MySQL/MariaDB数据库的复制监控和维护 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.清理日志 1>.删除指定日志文件名称之前的日志(也可用基于时间) M ...

  4. MySQL/MariaDB数据库的复制加密

      MySQL/MariaDB数据库的复制加密 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.MySQL的安全问题 1>.基于SSL复制 在默认的主从复制过程或远程连接 ...

  5. MySQL/MariaDB数据库的复制过滤器

      MySQL/MariaDB数据库的复制过滤器 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.复制过滤器概述 1>.复制器过滤器功能 让从节点仅复制指定的数据库,或指 ...

  6. MySQL/MariaDB数据库的Galera高可用性集群实战

      MySQL/MariaDB数据库的Galera高可用性集群实战 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Galera Cluster概述 1>.什么是Gale ...

  7. MySQL/MariaDB数据库的MHA实现高可用实战

      MySQL/MariaDB数据库的MHA实现高可用实战 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.MySQL高可用常见的解决方案 1>.Multi-Master ...

  8. MySQL/MariaDB数据库的PROXY实现读写分离

    MySQL/MariaDB数据库的PROXY实现读写分离 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.ProxySQL概述 1>.各家互联网公司读写分离的解决方案 m ...

  9. MySQL/MariaDB数据库的主从复制

     MySQL/MariaDB数据库的主从复制  作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.MySQL复制概述 1>.传统扩展方式 垂直扩展(也叫向上扩展,Sacle ...

随机推荐

  1. start & stop kafka cluster shell script

    kafka_start_cluster.sh #!/bin/bash brokers="kafka-server-1 kafka-server-2 kafka-server-3" ...

  2. JAVA SpringBoot2 整合 ueditor 的 并实现前后端分离

    1,下载 jsp 版本的 百度编辑器,点击此处下载 2,解压文件,解压后目录如下 3,我们将 jsp 目录暂时移动到别的地方,剩下的文件作为一个 H5 前端项目使用,笔者这边导入到 idea 进行开发 ...

  3. The 10 Best Studio Headphones of 2019

    The 10 Best Studio Headphones of 2019 https://www.outeraudio.com/category/list/ https://www.outeraud ...

  4. 关于JavaScript面向对象那些事

    当你在使用手机的时候,你会发现,你并不懂得其中的原理就会操作了,其实这就是面向对象的思想.面向对象还有很多地方都会运用到.JavaScript也不例外,现在跟随我的脚步,来学习一下吧. 面向过程和面向 ...

  5. windows系统常用命令

    dir 指定要列出的驱动器,显示当前文件夹下的文件   /?可显示所有命令 显示当前路径下的所有文件的绝对路径,包含子文件夹中的内容 D:\test > dir /b /s /o:n /a:a  ...

  6. PHP对二维数组进行排序

    /** * 获取最近的店铺 * @param $lng * @param $lat * @return array */ protected function getClosestShop($lng, ...

  7. Math 类

    Math 类 java.lang.Object java.lang.Math 方法签名 public final class Math extends Object public static fin ...

  8. 移动APP接口安全性设计

    移动APP接口是怎么保证安全性的,可以采用https,或者是非对称加密. 接口加密的目的是防止被别人用抓包工具,抓包后篡改数据. 关于加密算法常见的有对称加密(DES)和非对称加密(RSA) 对称加密 ...

  9. 全球DEM高程数据下载

    本文主要介绍如何使用“迈高图-地图数据下载器”(以下简称:迈高图)下载全球DEM高程数据,任意下载范围自动拼接.裁剪.DEM高程数据支持下载导出为:GeoTIFF.XYZ.南方CASS等常用数据格式. ...

  10. day17——序列化、os、sys、hashlib、collections

    day17 序列化 json 两组4个方法: 1.dumps(序列化) -- loads(反序列) dumps(list):将对象转换成字符串 loads(str):将字符串转换成对象 list--s ...