GithubHelp home page GithubHelp logo

wfxiang08 / sm-kingshard Goto Github PK

View Code? Open in Web Editor NEW
1.0 6.0 2.0 337 KB

扩展自kingshard,添加了graceful restart, 添加了自己的sharding方式,重构了代码

Go 96.20% Shell 0.95% Yacc 2.85%
mysql sharding mysql-proxy graceful-restart-process

sm-kingshard's Introduction

SMDbProxy:

* https://github.com/wfxiang08/sm_kingshard
* SMDbProxy用法上和MySQL基本相同

运维:

  • 下载代码
git clone https://github.com/wfxiang08/sm_kingshard.git
cd sm_kingshard/src
  • 编译代码
source start_env.sh
glide install
go build cmds/cmds/service_sm_proxy.go
  • 部署
# 拷贝&通过systemctl运维
bash scripts/scp_dbproxy.sh host_name
# 不影响现有服务,直接进行更新
systemctl reload dbproxy
Graceful Restart
pidof service_sm_prox
# 启动新的进程:可以更新binary/conf, 并且继承当前进程的listeners; 
# 新的请求交给新的进程,旧的请求在旧的进程中处理,直到所有的旧的请求处理完毕才推出或者10s后强制退出
kill -USR2 `pidof service_sm_prox`

Golang中定义的Signal和Linux的Signal不太一样,不要通过数字来代替 USR1, USR2

访问

mysql -u root -pxxx -P9900 -h172.1.2.12
use shard_sm

或
mysql -u root -pxxx -P9900 -h172.1.2.12  shard_sm

Prepared Statement

  • 不建议使用Prepared Statement, 在Sharding模式下禁用
  • golang中推荐使用:
    • user:password@tcp(db.hostname:3306)/db_name?charset=utf8mb4,utf8&interpolateParams=true&parseTime=True&loc=UTC
    • interpolateParams=true, 表示不直接使用prepared statement

sm-kingshard's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

tom2jack phial3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.