mysql中介軟體之kingshard

來源:互聯網
上載者:User

標籤:mysql   kingshard   


kingshard是一個由Go開發高效能MySQL Proxy項目,kingshard在滿足基本的讀寫分離的功能上,

致力於簡化MySQL分庫分表操作;能夠讓DBA通過kingshard輕鬆平滑地實現MySQL資料庫擴容。 

kingshard的效能大約是直連MySQL效能的80%以上。



一.基礎功能

支援SQL讀寫分離(已驗證)

支援多個slave,slave之間通過權值進行負載平衡。(已驗證)

支援SQL黑名單機制(已驗證)

分表(已驗證),kingshard支援按整數的hash和range分表,並且支援按日期的分表方式,

sharding(已驗證)



sharding支援以下功能:

1.支援按整數的hash和range分表方式。

2.支援按年、月、日維度時間分表方式。

3.支援跨節點分表,子表可以分布在不同的節點。

4.支援跨節點的count,sum,max和min等彙總函式。

5.支援單個分表的join操作,即支援分表和另一張不分表的join操作。

6.支援跨節點的order by,group by,limit等操作。

7.支援將sql發送到特定的節點執行。

8.支援在單個節點上執行事務,不支援跨多節點的分散式交易。

9.支援非事務方式更新(insert,delete,update,replace)多個node上的子表。




kingshard的效能測試。

影響kingshard效能的因素

1.客服端並發數。並發數過小,不能充分發揮kingshard的效能.具體多大的值合適需要壓測。

2.max_conns_limit。 具體設定多大還跟硬體有關,需要壓測,官方建議設定為128,根據官方的壓測結果獲得,

當設定為大於128的時候,效能上升不明顯

官方壓力測試報告:

https://github.com/flike/kingshard/blob/master/doc/KingDoc/kingshard_performance_test.md





kingshard 官方文檔

https://github.com/flike/kingshard/blob/master/README_ZH.md



golang環境的安裝

http://www.linuxidc.com/Linux/2015-02/113159.htm

yaml檢測

http://www.yamllint.com/



kingshard的守護進程

nohup ./bin/kingshard -config=/etc/ks.yaml &






以下是設定檔範例


####### hash  分表 #######################

--- 

addr: "0.0.0.0:9696"

blacklist_sql_file: /home/dengwang/software/src/github.com/flike/blacksql/blacklist

log_level: debug

log_path: /home/dengwang/software/src/github.com/flike/kingshard/log

nodes: 

  - 

    down_after_noalive: 32

    master: "mysql91:3306"

    max_conns_limit: 64

    name: node1

    password: [email protected]

    slave: "host55:[email protected],host51:[email protected]"

    user: root

password: kingshard

proxy_charset: gbk

schema: 

  db: test

  default: node1

  nodes: 

    - node1

  shard: 

    - 

      key: tid

      locations: 

        - 4

      nodes: 

        - node1

      table: tt

      type: hash

user: kingshard







### range 分表 #####################################################################

--- 

addr: "0.0.0.0:9696"

blacklist_sql_file: /home/dengwang/software/src/github.com/flike/blacksql/blacklist

log_level: debug

log_path: /home/dengwang/software/src/github.com/flike/kingshard/log

nodes: 

  - 

    down_after_noalive: 32

    master: "mysql91:3306"

    max_conns_limit: 64

    name: node1

    password: [email protected]

    slave: "host55:[email protected],host51:[email protected]"

    user: root

password: kingshard

proxy_charset: utf8

schema: 

  db: test

  default: node1

  nodes: 

    - node1

  shard: 

    - 

      key: tid

      locations: 

        - 4

      nodes: 

        - node1

      table: tt

      type: range

  table_row_limit: 1000

user: kingshard




############# 分表 中sharding

--- 

addr: "0.0.0.0:9696"

blacklist_sql_file: /home/dengwang/software/src/github.com/flike/blacksql/blacklist

log_level: debug

log_path: /home/dengwang/software/src/github.com/flike/kingshard/log

nodes: 

  - 

    down_after_noalive: 32

    master: "host51:3306"

    max_conns_limit: 64

    name: node1

    password: [email protected]

    slave: "host52:3306"

    user: root

  - 

    down_after_noalive: 32

    master: "host55:3306"

    max_conns_limit: 64

    name: node2

    password: [email protected]

    slave: "host56:3306"

    user: root

  - 

    down_after_noalive: 32

    master: "host53:3306"

    max_conns_limit: 64

    name: node3

    password: [email protected]

    slave: "host53:3306"

    user: root

password: kingshard

proxy_charset: utf8

schema: 

  db: test

  default: node3

  nodes: 

    - node1

    - node2

    - node3

  shard: 

    - 

      key: tid

      locations: 

        - 4

        - 4

      nodes: 

        - node1

        - node2

      table: tt

      table_row_limit: 1000

      type: range

user: kingshard



本文出自 “SQLServer MySQL” 部落格,請務必保留此出處http://dwchaoyue.blog.51cto.com/2826417/1754009

mysql中介軟體之kingshard

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.