青蛙小白
#Redis

Redis 3.2集群环境搭建和测试

Redis 3开始支持了Cluster模式,增强了Redis的水平扩展能力,Redis Cluster的节点分片通过hash slot实现,每个节点上的键都属于16384(0~16383)个slots中的一个,每个节点负责处理一部分slots。 Redis Cluster采用无中心节点方式实现,无需proxy代理,客户端直接与redis集群的每个节点连接,根据同样的hash算法计算出key对应的slot,然后直接在slot对应的Redis上执行命令。

#Mysql

使用MySQL的可传输表空间特性恢复表或迁移表数据

在MySQL运维中可能会遇到以下两个需求的场景,一个是从MySQL的备份中恢复单个表;另一个是将一套环境数据库某个表中的数据导入到另一套环境的数据中。 对于前者肯定需要用到数据库的备份,而对于后者如果使用普通的mysqldump导出表数据再导入的方式将十分缓慢。 MySQL从5.6开始支持了可传输表空间(Transportable Tablespaces)特性,该特性允许表空间(table.ibd)从一个实例拷贝到另一个实例上,使用这个特性可以实现前面提到的两个运维场景。

#Mysql

MySQL多源复制故障修复, 重新初始化一个channel的复制

MySQL 5.7数据库多源复制拓扑如下: M1 --------+ | | v M2 ------->S M1和M2为两个主数据库实例,S为从数据库实例,建立了从M1到S和从M2到S的多源复制。 S上执行: SHOW SLAVE STATUS \G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: x.x.x.x Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: binlog.000106 Read_Master_Log_Pos: 15847815 Relay_Log_File: relay-bin-m1.000003 Relay_Log_Pos: 15684092 Relay_Master_Log_File: binlog.000106 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: sys.%,performance_schema.%,mysql.%,information_schema.% Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 15847815 Relay_Log_Space: 15684290 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: 0 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: 86 Master_UUID: @17070e4d-a4bc-49b6-88d4-cbbc610abc2b Master_Info_File: mysql.slave_master_info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 134db0a3-61a4-4f96-8574-a3ec77045987:68811801-68821751 Executed_Gtid_Set: 30d1ce13-e8b0-43ae-b989-667aa0394fb8:1-240, f7123455-4085-4e24-a028-e0cff16d1cc6:1-8409014, f0c67103-9183-46c3-b34f-1b7fac7c0f51:1, 17070e4d-a4bc-49b6-88d4-cbbc610abc2b:1, bb09bbce-c153-4af2-ab6f-85e70b74a13c:1-3, cc96b6de-d317-4881-9a86-9c9b690cb8cc:1-15, 178dde0c-492c-4365-96e2-57008f2bd232:1-524521756, da0e0547-a1ca-4cae-8db9-f3a90b3a996a:1, 134db0a3-61a4-4f96-8574-a3ec77045987:1-68821751 Auto_Position: 1 Replicate_Rewrite_DB: Channel_Name: m1 Master_TLS_Version: *************************** 2. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: x.x.x.x Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: binlog.002584 Read_Master_Log_Pos: 127954993 Relay_Log_File: relay-bin-m2.003944 Relay_Log_Pos: 127955152 Relay_Master_Log_File: binlog.002584 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: sys.%,performance_schema.%,mysql.%,information_schema.% Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 127954993 Relay_Log_Space: 127955430 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: 0 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: 69 Master_UUID: c8822a1d-d39c-11e9-8301-fa163e13923c Master_Info_File: mysql.slave_master_info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 178dde0c-492c-4365-96e2-57008f2bd232:524093802-524521756 Executed_Gtid_Set: 30d1ce13-e8b0-43ae-b989-667aa0394fb8:1-240, f7123455-4085-4e24-a028-e0cff16d1cc6:1-8409014, f0c67103-9183-46c3-b34f-1b7fac7c0f51:1, 17070e4d-a4bc-49b6-88d4-cbbc610abc2b:1, bb09bbce-c153-4af2-ab6f-85e70b74a13c:1-3, cc96b6de-d317-4881-9a86-9c9b690cb8cc:1-15, 178dde0c-492c-4365-96e2-57008f2bd232:1-524521756, da0e0547-a1ca-4cae-8db9-f3a90b3a996a:1, 134db0a3-61a4-4f96-8574-a3ec77045987:1-68821751 Auto_Position: 1 Replicate_Rewrite_DB: Channel_Name: m2 Master_TLS_Version: 2 rows in set (0.00 sec) 多源复制(Multi-source replication)是指在一个数据库中从多个源数据库中复制数据到同一个目标数据库的过程。要在 MySQL 中实现多源复制,需要在目标数据库中创建多个复制通道(replication channel),每个通道对应一个源数据库。每个通道都需要有独立的复制配置,包括源数据库的连接信息、复制过滤规则等。