Sign inSign up

wangsying/kingshard

By wangsying

Updated over 5 years ago

Image
0

150

wangsying/kingshard repository overview

Open source:


https://github.com/flike/kingshard

kingshard

Overview

kingshard is a high-performance proxy for MySQL powered by Go. Just like other mysql proxies, you can use it to split the read/write sqls. Now it supports basic SQL statements (select, insert, update, replace, delete). The most important feature is the sharding function. Kingshard aims to simplify the sharding solution of MySQL.
The Performance of kingshard is about 80% compared to connecting to MySQL directly.

Feature

1. Basic Function
  • Splits reads and writes
  • Client's ip ACL control.
  • Transaction in single node.
  • Support limiting the max count of connections to MySQL database.
  • Support setting the backend database online or offline dynamically.
  • Supports prepared statement: COM_STMT_PREPARE, COM_STMT_EXECUTE, etc.
  • Support multi slaves, and load balancing between slaves.
  • Support reading master database forcely.
  • Support last_insert_id().
  • Support MySQL backends HA.
  • Support set the charset of proxy.
  • Support SQL blacklist.
  • Support dynamically changing the config value of kingshard.
2. Sharding Function
  • Support hash,range and date sharding across multiple nodes.
  • Support sending sql to the specified node.
  • Support most commonly used functions, such as max, min, count, sum, and also support join, limit, order by,group by.

Docker run:

docker run -it -v ${pwd}/ks.yaml:/etc/ks.yaml wangsying/kingshard:1.6 kingshard

Config in ks.yaml

addr : 0.0.0.0:9696
user_list:
  -
    user :  kingshard
    password : kingshard
web_addr : 0.0.0.0:9797
web_user : admin
web_password : admin
log_level : debug
log_sql : on
slow_log_time : 100
log_path : /var/log/kingshard
allow_ips: 127.0.0.1
nodes :
  -
    name : node1
    max_conns_limit : 16
    user :  kingshard
    password : kingshard
    master : 127.0.0.1:3306
    down_after_noalive : 300
  -
    name : node2
    max_conns_limit : 16
    user :  kingshard
    password : kingshard
    master : 192.168.59.103:3307
    slave :
    down_after_noalive: 100
schema_list :
  -
    user: kingshard
    nodes: [node1,node2]
    default: node1
    shard:
      -
        db : kingshard
        table: test_shard_hash
        key: id
        nodes: [node1, node2]
        type: hash
        locations: [4,4]
      -
        db : kingshard
        table: test_shard_range
        key: id
        type: range
        nodes: [node1, node2]
        locations: [4,4]
        table_row_limit: 10000

Tag summary

Content type

Image

Digest

Size

11.3 MB

Last updated

over 5 years ago

docker pull wangsying/kingshard:1.6-alpine3.13