MS series: Mysql, Mycat

Consistent Hash Sharding

What is Consistent Hash
http://www.zsythink.net/archives/1182
Consistent Hash Expansion
https://blog.csdn.net/ydyang1126/article/details/70773557?locationNum=11&fps=1

slow log

http://www.zsythink.net/archives/1260

Read Snapshot – Repeatable Read

Exporting large batches of data - how to ensure data consistencyhttp
://www.zsythink.net/archives/1436

GTID

After MySQL 5.6, a solution for multi-threaded synchronous replication based on GTID is provided, that is, each library has a separate (sql thread).
Perform synchronous replication, which will greatly improve the data delay problem of MySQL master-slave synchronization. With Mycat sharding, it can better reduce the data synchronization delay of a super large table to a minimum. In addition, using GTID avoids relying on file names and physical offsets in the transmission of binlog logic, and can better support automatic disaster recovery switching, which should be a happy thing for operation and maintenance personnel, because the traditional method , you need to find the binlog and POS points, and then change the master to point, instead of very experienced operation and maintenance, they often find it wrong, causing master-slave synchronous replication errors, in mysql5.6, no need to know binlog and POS anymore You need to know the master's IP, port, account password, because synchronous replication is automatic, and mysql automatically finds points for synchronization through the internal mechanism GTID.
Even with the concurrent replication mechanism, the problem of instantaneous out-of-sync data in the master-slave database cannot be avoided, so there is an enhanced solution, namely galera for mysql, percona-cluster or mariadb cluster and other cluster mechanisms, which are a multi- The master synchronous replication mode can read and write on any node, automatically control members, automatically delete faulty nodes, automatically join nodes, and truly give row-level concurrent replication and other powerful capabilities!
For GDIT, please refer to: https://yq .aliyun.com/articles/57731

MyCat usage bottleneck

https://blog.csdn.net/u013235478/article/details/53178657
1. When the number of shards is large, the query performance of non-sharded fields is low
2. The paging sorting performance is low
3. Unless ER sharding, the join query performance is low
4. XA transaction: when mysql is set to auto-commit, mycat cannot roll back the committed database; when mysql is not set to auto-commit, mycat waits for the transaction to time out and rolls back.

MyCat High Availability

Keepalived+HAproxy+Mycat cluster+MySQL master-slave

MySql high availability scheme comparison

https://blog.csdn.net/slwang001/article/details/71080002
https://blog.csdn.net/u013399093/article/details/70597712
https://www.2cto.com/database/201504/387166. html
MySQL MGR and Galera performance testhttps :
//blog.csdn.net/chenhaifeng2016/article/details/77530569Highly
consistent distributed database Galera Cluster
http://geek.csdn.net/news/detail/159228Note
: About mysql High availability, the advanced chapter of mycat authoritative guide is also discussed in detail

Crowd:

Advantages:
(1). Synchronous replication
(2). Active-active multi-master topology logic
(3). Data can be read and written to any node in the cluster
(4). Automatic member control, the faulty node automatically returns from the cluster (5). Automatic
node join
(6). True parallel replication, based on row level
(7). Direct client connection, native MySQL interface
(8). Each node contains a complete copy of the data
(9 ) ).Data synchronization in multiple databases is implemented by the wsrep interface

Disadvantages:
(1). The current replication only supports the InnoDB storage engine, any tables written to other engines, including mysql.* tables will not be replicated, but DDL statements will be replicated, so creating users will be replicated, but insert into mysql.user...will not be replicated.
(2).DELETE operation does not support tables without primary keys, tables without primary keys will be in different order on different nodes, if you execute SELECT...LIMIT... will appear different result sets .
(3). LOCK/UNLOCK TABLES is not supported in multi-master environment, and lock functions GET_LOCK(), RELEASE_LOCK()…
(4). Query logs cannot be saved in the table. If the query log is enabled, it can only be saved to a file.
(5). The maximum transaction size allowed is defined by wsrep_max_ws_rows and wsrep_max_ws_size. Any large operation will be rejected. Such as large LOAD DATA operations.
(6). Since the cluster is optimistic concurrency control, the transaction commit may be aborted at this stage. If two transactions write and commit to the same row to different nodes in the cluster, the failed node will abort. For cluster-level aborts, the cluster returns a deadlock error code (Error: 1213 SQLSTATE: 40001 (ER_LOCK_DEADLOCK)).
(7). XA transactions are not supported due to possible rollback on commit.
(8) The write throughput of the entire cluster is limited by the weakest node, if one node becomes slow, then the entire cluster will be slow. For stable high performance requirements, all nodes should use unified hardware.
(9). At least 3 cluster nodes are recommended.
(10). If there is a problem with the DDL statement, the cluster will be destroyed.

Find the 3 students with the highest grades in each class

select * from student s1 left join class c on s1.class_id=c.id 
where ( 
    select count(1) from student s2 where s2.class_id=s1.class_id and s2.score>=s1.score
) <=3;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324818385&siteId=291194637
ms