共计 2175 个字符,预计需要花费 6 分钟才能阅读完成。
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.zip
unzip master
cd ssdb-master
make
# 将安装在 /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 = ./var
pidfile = ./var/ssdb.pid
server:
ip: 0.0.0.0
port: 8888
replication:
binlog: yes
sync_speed: -1
slaveof:
id: svc_2
type: sync
host: 10.105.10.128
port: 8888
logger:
level: info
output: log.txt
rotate:
size: 1000000000
leveldb:
cache_size: 500
block_size: 32
write_buffer_size: 64
compaction_speed: 1000
compression: yes
重启 ssdb
master-2:10.105.10.128
work_dir = ./var
pidfile = ./var/ssdb.pid
server:
ip: 0.0.0.0
port: 8888
replication:
binlog: yes
sync_speed: -1
slaveof:
id: svc_2
type: sync
host: 10.105.10.77
port: 8888
logger:
level: info
output: log.txt
rotate:
size: 1000000000
leveldb:
cache_size: 500
block_size: 32
write_buffer_size: 64
compaction_speed: 1000
compression: yes
重启 SSDB
安装配置 haproxy
yum -y install haproxy
vim /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/stats
defaults
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 3000
listen test
bind 0.0.0.0:8899
mode tcp
balance roundrobin
server s1 10.105.10.128:8888 weight 1 maxconn 10000 check inter 10s
server s2 10.105.10.77:8888 weight 1 maxconn 10000 check inter 10s
重新启动 haproxy, 以后可以利用 keepalive 将 haproxy 设计成双主或准备都可以
/etc/init.d/haproxy restart
测试(客户端连接 haproxy 地址)
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-05/143800.htm