SSDB基础

2022-04-23 18:29:21 浏览数 (1)

前言

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

它与Redis相比具备明显优势的一个特性就是基于硬盘存储,所以它支撑的数据量不会因为内存的限制而受约束。

至于性能,由于存取效率一部分取决于硬盘的IOPS,所以官网给的benchmark结果应该是极高IOPS的硬盘(比如固态硬盘)上测试出的结果,有人在正常环境下做过测试,实际效率是redis的42%~57%,CPU负载要高出一倍,并发效率也与redis有明显差距,详细可以参考 redis和ssdb读取性能对比

虽然SSDB效率上不如REDIS,但基于磁盘存储有着其最大的优势,毕竟很多业务数据远超过服务器内存的容量,即便不超过,相较硬盘,内存也要贵很多,所以时间与空间的取舍就取决于具体的应用场景了

下面分享一下 ssdb 的基本操作,详细可以参阅 官方文档

Tip: 目前官方版本是 SSDB 1.9.2


概要


下载和安装

使用下面的方法进行安装

代码语言:javascript复制
wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip
unzip master
cd ssdb-master
make
sudo make install

安装过程

代码语言:javascript复制
[root@h101 src]# wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip
--2015-11-24 19:36:34--  https://github.com/ideawu/ssdb/archive/master.zip
Resolving github.com... 192.30.252.130
Connecting to github.com|192.30.252.130|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/ideawu/ssdb/zip/master [following]
--2015-11-24 19:36:35--  https://codeload.github.com/ideawu/ssdb/zip/master
Resolving codeload.github.com... 192.30.252.147
Connecting to codeload.github.com|192.30.252.147|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/zip]
Saving to: “master.zip”

    [                                                                                                     <=>

2015-11-24 19:37:19 (33.7 KB/s) - “master.zip” saved [1460288]

[root@h101 src]# ll master.zip 
-rw-r--r-- 1 root root 1460288 Nov 24 19:37 master.zip
[root@h101 src]# 
[root@h101 src]# unzip master.zip 
Archive:  master.zip
9497637f54da00f364e310de42000284545cfebe
   creating: ssdb-master/
  inflating: ssdb-master/.gitignore  
  inflating: ssdb-master/ChangeLog   
  inflating: ssdb-master/Dockerfile  
  inflating: ssdb-master/LICENSE     
  inflating: ssdb-master/Makefile    
  inflating: ssdb-master/README.md 
...
...
   creating: ssdb-master/tools/ssdb_cli/
  inflating: ssdb-master/tools/ssdb_cli/cluster.cpy  
  inflating: ssdb-master/tools/ssdb_cli/exporter.cpy  
  inflating: ssdb-master/tools/ssdb_cli/flushdb.cpy  
  inflating: ssdb-master/tools/ssdb_cli/importer.cpy  
  inflating: ssdb-master/tools/ssdb_cli/util.cpy  
  inflating: ssdb-master/tools/unittest.php  
 extracting: ssdb-master/version     
[root@h101 src]# 
[root@h101 src]# ll ssdb-master/
total 4912
drwxr-xr-x 6 root root    4096 Nov 23 20:34 api
-rw-r--r-- 1 root root     671 Nov 24 19:41 build_config.mk
-rwxr-xr-x 1 root root    3468 Nov 23 20:34 build.sh
-rw-r--r-- 1 root root    4831 Nov 23 20:34 ChangeLog
drwxr-xr-x 6 root root    4096 Nov 23 20:34 deps
-rw-r--r-- 1 root root     971 Nov 23 20:34 Dockerfile
drwxr-xr-x 2 root root    4096 Nov 23 20:34 docs
-rw-r--r-- 1 root root    1470 Nov 23 20:34 LICENSE
-rw-r--r-- 1 root root    1573 Nov 23 20:34 Makefile
-rw-r--r-- 1 root root    4412 Nov 23 20:34 README.md
drwxr-xr-x 6 root root    4096 Nov 24 19:41 src
-rwxr-xr-x 1 root root     946 Nov 23 20:34 ssdb.conf
-rwxr-xr-x 1 root root 4950089 Nov 24 19:40 ssdb-server
-rwxr-xr-x 1 root root     705 Nov 23 20:34 ssdb_slave.conf
drwxr-xr-x 3 root root    4096 Nov 24 19:40 tools
drwxr-xr-x 2 root root    4096 Nov 24 19:40 var
drwxr-xr-x 2 root root    4096 Nov 24 19:40 var_slave
-rw-r--r-- 1 root root       6 Nov 23 20:34 version
[root@h101 src]# 
[root@h101 src]# cd ssdb-master/
[root@h101 ssdb-master]# make 

##### building snappy... #####
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
...
...
g   -o ssdb-repair ssdb-repair.o ../src/net/link.o ../src/net/fde.o ../src/util/log.o ../src/util/bytes.o   --1.18/libleveldb.a" "/usr/local/src/ssdb-master/deps/snappy-1.1.0/.libs/libsnappy.a" "/usr/local/src/ssdb-mas
g   -o leveldb-import leveldb-import.o ../src/net/link.o ../src/net/fde.o ../src/util/log.o ../src/util/byteseveldb-1.18/libleveldb.a" "/usr/local/src/ssdb-master/deps/snappy-1.1.0/.libs/libsnappy.a" "/usr/local/src/ss
g   -o ssdb-migrate ssdb-migrate.o ../api/cpp/libssdb-client.a ../src/util/libutil.a
make[1]: Leaving directory `/usr/local/src/ssdb-master/tools'
[root@h101 ssdb-master]# echo $?
0
[root@h101 ssdb-master]# make install 
mkdir -p /usr/local/ssdb
mkdir -p /usr/local/ssdb/_cpy_
mkdir -p /usr/local/ssdb/deps
mkdir -p /usr/local/ssdb/var
mkdir -p /usr/local/ssdb/var_slave
cp -f ssdb-server ssdb.conf ssdb_slave.conf /usr/local/ssdb
cp -rf api /usr/local/ssdb
cp -rf 
		tools/ssdb-bench 
		tools/ssdb-cli tools/ssdb_cli 
		tools/ssdb-cli.cpy tools/ssdb-dump 
		tools/ssdb-repair 
		/usr/local/ssdb
cp -rf deps/cpy /usr/local/ssdb/deps
chmod 755 /usr/local/ssdb
chmod -R ugo rw /usr/local/ssdb/*
rm -f /usr/local/ssdb/Makefile
[root@h101 ssdb-master]#

0 人点赞