标签:生产 blackhole 中继 架构 binary SQL_error var 0.00 数据
MySQL Replication
一般来说,应用系统性能扩展不外乎Scale up如用性能更好的主机,或者Scale out增加主机数量通过负载均衡的方式
MySQL的扩展:Scale up的扩展瓶颈很容易突破,在Scale out的扩展方式下,数据如何同步是其核心的管理模块。如下图所示,slave节点向主节点请求二进制日志并在本地replay。应用访问数据库时必须通过7层的读写分离器R/W spliter,能够把应用使用的SQL语句按照按读写类型,把写的请求只发给Master,把读的请求按照负载均衡的方式发送给多个从节点Slaves。
复制的功用:
1. 数据分布
2. 负载均衡读请求
3. 备份
4. 高可用性和故障切换
5. MySQL升级测试
主Master节点:
从Slave节点:
MySQL复制特点:
复制架构:
主从复制配置过程:
实验1(两个全新的M/S):
从节点,开始同步
```
MariaDB [(none)]> HELP CHANGE MASTER TO
MariaDB [(none)]> CHANGE MASTER TO MASTER_HOST=‘172.20.42.204‘,MASTER_USER=‘repluser‘,MASTER_PASSWORD=‘replpass‘,MASTER_LOG_FILE=‘mysql-bin.000015‘,MASTER_LOG_POS=685;
MariaDB [(none)]> SHOW SLAVE STATUS\G;
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 172.20.42.204
Master_User: repluser
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000015
Read_Master_Log_Pos: 685
Relay_Log_File: relay-log.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql-bin.000015
Slave_IO_Running: No
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 685
Relay_Log_Space: 256
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 0
Master_SSL_Crl:
Master_SSL_Crlpath:
Using_Gtid: No
Gtid_IO_Pos:
Replicate_Do_Domain_Ids:
Replicate_Ignore_Domain_Ids:
Parallel_Mode: conservative
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
从节点上查看同步状态
MariaDB [mydb]> SHOW GLOBAL VARIABLES LIKE ‘server_id‘; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | server_id | 2 | +---------------+-------+ MariaDB [mydb]> SHOW SLAVE STATUS\G; MariaDB [mydb]> SELECT COUNT(*) FROM testtb; +----------+ | COUNT(*) | +----------+ | 100000| +----------+
实验二(模拟生产环境,主库已经有很多的数据,需要扩容只读库满足性能需求)
标签:生产 blackhole 中继 架构 binary SQL_error var 0.00 数据
原文地址:https://www.cnblogs.com/liangjindong/p/9193448.html