WEB架构之存储-SSDB(03)

1.1 SSDB介绍

SSDB一个高性能的支持丰富数据结构的 NoSQL 数据库, 用于替代 Redis。

1.1.1 SSDB特性

  • 替代 Redis 数据库, Redis 的 100 倍容量
  • LevelDB 网络支持, 使用 C/C++ 开发
  • Redis API 兼容, 支持 Redis 客户端
  • 适合存储集合数据, 如 list, hash, zset…
  • 客户端 API 支持的语言包括: C++, PHP, Python, Java, Go
  • 持久化的队列服务
  • 主从复制, 负载均衡

1.1.2 SSDB与Redis性能对比

图片[1]|WEB架构之存储-SSDB(03)|leon的博客

1.2 部署SSDB主-主同步

1.2.1 编译安装SSDB

[root@ssdb-node ~]# wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip
[root@ssdb-node ~]# unzip master.zip
[root@ssdb-node ~]# cd ssdb-master
[root@ssdb-node ssdb-master]# make && make install

1.2.2 编辑双主配置文件

[root@ssdb-node01 ~]# vim /usr/local/ssdb/ssdb.conf
server:
        # specify an ipv6 address to enable ipv6 support
        # ip: ::1
        ip: 0.0.0.0
        port: 8888
replication:
        binlog: yes
        # Limit sync speed to *MB/s, -1: no limit
        sync_speed: -1
        slaveof:
                # to identify a master even if it moved(ip, port changed)
                # if set to empty or not defined, ip:port will be used.
                id: svc_1
                # sync|mirror, default is sync
                type: mirror
                host: 10.10.10.104  # 对端主服务器IP
                port: 8888          # 对端主服务器端口

[root@ssdb-node02 ~]# vim /usr/local/ssdb/ssdb.conf
server:
        # specify an ipv6 address to enable ipv6 support
        # ip: ::1
        ip: 0.0.0.0
        port: 8888
replication:
        binlog: yes
        # Limit sync speed to *MB/s, -1: no limit
        sync_speed: -1
        slaveof:
                # to identify a master even if it moved(ip, port changed)
                # if set to empty or not defined, ip:port will be used.
                id: svc_2
                # sync|mirror, default is sync
                type: mirror
                host: 10.10.10.103  # 对端主服务器IP
                port: 8888          # 对端主服务器端口

1.2.3 启动服务

[root@ssdb-node ~]# echo 'export PATH=$PATH:/usr/local/ssdb' >> /etc/profile
[root@ssdb-node ~]# source /etc/profile
[root@ssdb-node ~]# ssdb-server -d /usr/local/ssdb/ssdb.conf

1.2.4 验证运行结果

[root@ssdb-node01 ~]# ssdb-cli 10.10.10.103
ssdb (cli) - ssdb command line tool.
Copyright (c) 2012-2016 ssdb.io

'h' or 'help' for help, 'q' to quit.

ssdb-server 1.9.8

ssdb 10.10.10.103:8888> info
version
    1.9.8
links
    1
total_calls
    8
dbsize
    0
binlogs
        capacity : 20000000
        min_seq  : 0
        max_seq  : 2
replication
    client 10.10.10.104:53332
        type     : mirror
        status   : SYNC
        last_seq : 2
replication
    slaveof 10.10.10.104:8888
        id         : svc_1
        type       : mirror
        status     : SYNC
        last_seq   : 2
        copy_count : 0
        sync_count : 0
serv_key_range
        kv  : "" - ""
        hash: "" - ""
        zset: "" - ""
        list: "" - ""
data_key_range
        kv  : "age" - "name"
        hash: "" - ""
        zset: "" - ""
        list: "" - ""
leveldb.stats
                                   Compactions
    Level  Files Size(MB) Time(sec) Read(MB) Write(MB)
    --------------------------------------------------
 
21 result(s) (0.001 sec)
(0.001 sec)
ssdb 10.10.10.103:8888> set name leon
ok
(0.000 sec)
ssdb 10.10.10.103:8888> set age 20
ok
(0.000 sec)
ssdb 10.10.10.103:8888> get name
leon
(0.000 sec)
ssdb 10.10.10.103:8888> get age
20
(0.000 sec)
ssdb 10.10.10.103:8888> q
bye.

[root@ssdb-node01 ~]# ssdb-cli 10.10.10.104
ssdb (cli) - ssdb command line tool.
Copyright (c) 2012-2016 ssdb.io

'h' or 'help' for help, 'q' to quit.

ssdb-server 1.9.8

ssdb 10.10.10.104:8888> info
version
    1.9.8
links
    1
total_calls
    7
dbsize
    0
binlogs
        capacity : 20000000
        min_seq  : 0
        max_seq  : 4
replication
    client 10.10.10.103:46810
        type     : mirror
        status   : SYNC
        last_seq : 4
replication
    slaveof 10.10.10.103:8888
        id         : svc_2
        type       : mirror
        status     : SYNC
        last_seq   : 4
        copy_count : 0
        sync_count : 4
serv_key_range
        kv  : "" - ""
        hash: "" - ""
        zset: "" - ""
        list: "" - ""
data_key_range
        kv  : "age" - "name"
        hash: "" - ""
        zset: "" - ""
        list: "" - ""
leveldb.stats
                                   Compactions
    Level  Files Size(MB) Time(sec) Read(MB) Write(MB)
    --------------------------------------------------
 
21 result(s) (0.002 sec)
(0.002 sec)
ssdb 10.10.10.104:8888> get name
leon
(0.003 sec)
ssdb 10.10.10.104:8888> get age
20
(0.001 sec)
ssdb 10.10.10.104:8888> q
bye.

1.3 参考资料

官方网站:http://ssdb.io/zh_cn/

官方文档:http://ssdb.io/docs/zh_cn/index.html

https://www.cnblogs.com/hxlasky/p/11381021.html

温馨提示:本文最后更新于2022-12-20 20:57:39,已超过523天没有更新。某些文章具有时效性,若文章内容或图片资源有错误或已失效,请联系站长。谢谢!
转载请注明本文链接:https://blog.leonshadow.cn/763482/2103.html
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享