28
MySQL Cluster 实战初探 周彦伟 2013.04 DTCC2013

MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

  • Upload
    others

  • View
    15

  • Download
    0

Embed Size (px)

Citation preview

Page 1: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

MySQL Cluster 实战初探

周彦伟

2013.04

DTCC2013

Page 2: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

先说三个闹心事儿

• 计数

• 用户个人信息

• 好友最新动态

DTCC2013

Page 3: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

MySQL的解决思路

• 切分

• 多slave

• 缓存

DTCC2013

Page 4: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

还有没有更合适的方案?

• MySQL Cluster --- 一个美丽的传说

DTCC2013

Page 5: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

MySQL Cluster

• NDB,NDBCLUSTER,Network Database

• “memory database”

• Share-nothing

• High-availability

• High-redundancy

• Distributed

DTCC2013

Page 6: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

认识MySQL ClusterDTCC2013

Page 7: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

MySQL Cluster

• Managerment node

• Data node

• SQL node

• Management client

• NDB client

• MySQL client

DTCC2013

Page 8: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

MySQL Cluster

• Node Group

• Partition

• Replicas

DTCC2013

Page 9: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

HADTCC2013

Page 10: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

部署容易?DTCC2013

Page 11: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

需要做的事

• 准备机器(>3)

• 下载两个安装包(client,server)

• 修改两个配置文件

– my.cnf

– config.ini

DTCC2013

Page 12: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

my.cnfDTCC2013

Page 13: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

Config.iniDTCC2013

Page 14: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

启动

• ndb_mgmd –initial

• ndbd –initial

• mysqld_safe –user=mysql &

DTCC2013

Page 15: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

DTCC2013

Page 16: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

运维-备份DTCC2013

Page 17: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

运维-恢复

• ndb_restore

DTCC2013

Page 18: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

Rolling restart

• 修改配置

• 增加节点

• 维护机器

DTCC2013

Page 19: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

Add Data node online

• 修改config.ini

• Rolling restart

• Start new data nodes

• Create nodegroup

• Alter online table … reorganize partition

• Optimize table …

DTCC2013

Page 20: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

Disk data tables

• Tablespaces

– Data files

• Undo log files

– log file grop

DTCC2013

Page 21: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

Disk data tables

• create logfile group lg ... engine ndbcluster

• create tablespace ts ... engine ndbcluster

• create table t (...) tablespace ts storage disk engine ndbcluster

DTCC2013

Page 22: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

MySQL Cluster replicationDTCC2013

Page 23: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

Injector threadDTCC2013

Page 24: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

MySQL Cluster replicationDTCC2013

Page 25: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

MySQL Cluster replicationDTCC2013

Page 26: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

MySQL Cluster replicationDTCC2013

Page 27: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

讨论

• 适用场景

– 密集写

– 密集读

– 数据量可控

– 替代部分缓存

• 使用成本

– 硬件• 用磁盘换内存

– 运维• 标准化,自动化

DTCC2013

Page 28: MySQL Cluster 实战初探 周彦伟topic.it168.com/factory/DTCC2013/doc/a14.pdf•MySQL client DTCC2013 MySQL Cluster •Node Group •Partition •Replicas DTCC2013 HA DTCC2013 部署容易?

EOF@周彦伟

[email protected]

DTCC2013