SSDB简介
SSDB 是一个 C/C++ 语言开发的高性能 NoSQL 数据库, 支持 KV, list, map(hash), zset(sorted set) 等数据结构, 用来替代或者与 Redis 配合存储十亿级别列表的数据.
SSDB 是稳定的, 生产环境使用的, 已经在, 如奇虎 360, TOPGAME.
下载和安装wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zipunzip mastercd ssdb-mastermake# 将安装在 /usr/local/ssdb 目录下sudo make install
启动和停止
# 启动主库, 此命令会阻塞住命令行./ssdb-server ssdb.conf# 或者启动为后台进程(不阻塞命令行)./ssdb-server -d ssdb.conf# 停止 ssdb-server./ssdb-server ssdb.conf -s stop# 对于旧版本kill `cat ./var/ssdb.pid`# 重启./ssdb-server ssdb.conf -s restart
双主方案
master-1:10.105.10.77
work_dir = ./varpidfile = ./var/ssdb.pidserver: ip: 0.0.0.0 port: 8888replication: binlog: yes sync_speed: -1 slaveof: id: svc_2 type: sync host: 10.105.10.128 port: 8888logger: level: info output: log.txt rotate: size: 1000000000leveldb: cache_size: 500 block_size: 32 write_buffer_size: 64 compaction_speed: 1000 compression: yes
重启ssdb
master-2:10.105.10.128
work_dir = ./varpidfile = ./var/ssdb.pidserver: ip: 0.0.0.0 port: 8888replication: binlog: yes sync_speed: -1 slaveof: id: svc_2 type: sync host: 10.105.10.77 port: 8888logger: level: info output: log.txt rotate: size: 1000000000leveldb: cache_size: 500 block_size: 32 write_buffer_size: 64 compaction_speed: 1000 compression: yes
重启SSDB
安装配置haproxy
yum -y install haproxyvim /etc/haproxy/haproxy.cfg
global log 127.0.0.1 local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 4000 user haproxy group haproxy daemon stats socket /var/lib/haproxy/statsdefaults mode http log global option dontlognull option redispatch retries 3 timeout http-request 10s timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m timeout http-keep-alive 10s timeout check 10s maxconn 3000listen testbind 0.0.0.0:8899mode tcpbalance roundrobinserver s1 10.105.10.128:8888 weight 1 maxconn 10000 check inter 10sserver s2 10.105.10.77:8888 weight 1 maxconn 10000 check inter 10s
重新启动haproxy,以后可以利用keepalive 将haproxy设计成双主或准备都可以
/etc/init.d/haproxy restart
测试(客户端连接haproxy地址)