標籤: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