itang / todo.itang.me

4 stars 2 forks source link

Redis, SSDB、Hazelcast 熟悉 [进行中] #48

Open itang opened 10 years ago

itang commented 10 years ago
String(字符串)
Hash(哈希表)
List(列表)
Set(集合)
有序集(Sorted set)

模型

Pub/Sub(发布/订阅)

使用场景

http://www.ideawu.net/blog/archives/770.html

我们是单个实例百亿条数据, 使用双主架构, 仅使用其中一个作为写, 故障时整体切换到另一

ssdb 的双主配置比较简单, 只需要将 replication.type 设为 mirror, 然后各指向对方即可.

搭建与测试

配置项:

Memory Usage:

cache_size + write_buffer_size * 66 + 32

默认的memory usage of a ssdb-server instance是:

500 + 64 * 66 + 32 = 4756 (M)

简单启动

 ./ssdb-server ssdb.conf

Setting up master/slave distribution

Master-Slave:

server 1: ./ssdb-server ssdb.conf

replication:
    slaveof:

server 2: ./ssdb-server ssdb_slave.conf

replication:
    slaveof:
        id: svc_1
        # sync|mirror, default is sync
        type: sync
        ip: 127.0.0.1
        port: 8888

Master-Master:

server 1:

replication:
    slaveof:
        id: svc_2
        # sync|mirror, default is sync
        type: mirror
        ip: 127.0.0.1
        port: 8889

server2:

replication:
    slaveof:
        id: svc_1
        # sync|mirror, default is sync
        type: mirror
        ip: 127.0.0.1
        port: 8888

通过telnet 测试

➜  ssdb-master  telnet localhost 8888
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
3
get
3
key

9
not_found

3
set
3
aaa
3
bbb

2
ok
1
1

3
get
3
aaa

2
ok
3
bbb