Skip to content

Pika Sharding Tutorials

Zhao Minghuan edited this page Sep 16, 2019 · 8 revisions

关于sharding mode,pika底层提供slot 的概念。Pika将key进行哈希取模之后散列到各个slot当中处理。sharding mode 根据线上的具体情况可以应用于单个pika,也可以应用到多个pika组成的pika cluster。这个tutorial主要介绍开启sharding mode 需要了解的一些概念,以及需要调整的一些配置参数。

1. 所需要版本

Pika 从3.2.0版本之后支持sharding mode,建议用最新release。

2. 基本操作

关于slots的基本操作详见 slot commands

3. 配置文件说明

# default slot number each table in sharding mode
  default-slot-num : 1024

# if this option is set to 'classic', that means pika support multiple DB, in
# this mode, option databases enable
# if this option is set to 'sharding', that means pika support multiple Table, you
# can specify slot num for each table, in this mode, option default-slot-num enable
# Pika instance mode [classic | sharding]
  instance-mode : sharding

default-slot-num 参数是slot的总数,对于单个pika上需要承载多少slot 用户需要手动在这个pika实例上添加slot。添加命令详见slot commands

4. 兼容coids,twemproxy方案

目前的分布式框架依赖于开源项目,目前pika兼容codis,twemproxy。

具体的兼容方案详见Support Cluster Slots

Clone this wiki locally