SSDB: High-Performance Database Server

Source: Internet
Author: User

SSDB is an open-source high-performance database server that uses Google LevelDB as the storage engine and supports T-level data. It also supports data structures such as zset and hash in Redis, apsaradb for Redis can be used as an alternative to high performance and big data.

Because SSDB initially aims to replace Redis, SSDB often compares with Redis. we know that Redis is a frequent "master-slave" architecture. Although load balancing and cross-region data backup functions can be achieved, high availability cannot be achieved. considering this situation, the master and slave nodes of Redis are in two IDCs respectively. When the master data center fails, the entire service is actually stopped. because all write operations fail, the application generally does not automatically downgrade the service.

While SSDB supports "dual-master" Architecture (SSDB distributed architecture: https://github.com/ideawu/ssdb/wiki/Replication), two or more Master servers. when some of the primary servers fail, the remaining primary servers can still normally accept write requests to ensure normal service availability. After the DNS resolution is modified, 100% availability can be restored immediately after the data center fails.

After SSDB is developed and open-source, IT has been tested in the production environment for three quarters. SSDB is the first to try to use IT on the IT blog website, then we got a large-scale application in the 360 game department. Currently, the supported data volume has reached several hundred GB. these applications were originally using Redis, and the cost for migrating to SSDB was very low, resulting in minimal code changes.

SSDB open source database project: https://github.com/ideawu/ssdb

Author blog: http://www.ideawu.net/blog/ssdb

Install

Is it recommended to install SSDB? The method is source code compilation and installation. How can this problem be solved? Is the row environment popular in Linux? Line version. remote SSH login to your server, then? Use? Download, compile, install, and run the following commands? Row:

$ Sudo wget -- no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip

$ Sudo unzip master

$ Cd ssdb-master

$ Sudo make

$ # Optional, install ssdb in/usr/local/ssdb

$ Sudo make install

# Start master

$ Sudo./ssdb-server ssdb. conf

# Or start as daemon

$ Sudo./ssdb-server-d ssdb. conf

# Ssdb command line

$ Sudo./ssdb-cli-p 8888

# Stop ssdb-server

$ Sudo kill 'cat./var/ssdb. Pi'

By default, SSDB is installed in the/usr/local/ssdb directory. ssdb-server is a server program, and ssdb-cli is a command? Line client.

SSDB configuration file http://www.ideawu.net/blog/archives/733.html]

SSDB attached to ssdb. conf can be used without modification. if you want to customize it, you still need to modify some configurations. the following is an introduction. the SSDB configuration file is a hierarchical key-value static configuration file that uses a TAB indent to represent hierarchical relationships. the line starting with '#' is a comment. the standard configuration file is as follows:

# Ssdb-server config
# MUST indent by TAB!

# Relative to path of this file, directory must exists
Work_dir =./var
Pidfile =./var/ssdb. pid

Server:
Ip: 127.0.0.1
Port: 8888
# Bind to public ip
# Ip: 0.0.0.0
# Format: allow | deny: all | ip_prefix
# Multiple allows or denys is supported
# Deny: all
# Allow: 127.0.0.1
# Allow: 192.168

Replication:
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: sync
# Ip: 127.0.0.1
# Port: 8889

Logger:
Level: info
Output: log.txt
Rotate:
Size: 1000000000

Leveldb:
# In MB
Cache size: 500
# In KB
Block_size: 32
# In MB
Write_buffer_size: 64
# In MB
Compaction_speed: 1000
# Yes | no
Compression: no

Work_dir: the working directory of ssdb-server. After startup, two directories, data and meta, are generated under this directory to save the database files of LevelDB. this directory is relative to ssdb. the relative path of conf. You can also specify the absolute path.

Server: ip and port specify the IP address and port number of the server to listen. if the ip address is 0.0.0.0, it indicates binding all IP addresses. based on security considerations, you can set the ip address to 127.0.0.1, so that only the local machine can access it. to implement more stringent network security restrictions, you must rely on the iptables of the operating system.

Replication: used to specify master-slave synchronous replication. slaveof. ip, slaveof. port indicates that this SSDB server will synchronize data from this target machine (that is, the server corresponding to this configuration file is slave ). you can refer to the preparation of ssdb_slave.conf.

Logger: Configure logging. level is the log level, which can be trace | debug | info | error. output is the name of the log file. SSDB supports log rotation. After the log file reaches a certain size, rename log.txt and create a new log.txt.

Leveldb: configure the LevelDB parameters. You generally want to modify the cache_size parameter to specify the cache size. An appropriate cache can improve read performance, but a large cache will affect write performance.

In? Use? Built-in ssdb. conf configuration? SSDB? Generated? Logs? Add files by volume? Lines are separated. This is the only? That's all. So, what do you need to write? ? Have you entered crontab? OK? Log compression and regular cleanup.
If a system fault such as a server power failure or a kernel panic occurs, after the system is restarted, do you need it? Manually delete the ssdb PID? File ssdb. pid before you can start ssdb-server. In addition, you can refer? To start and close ssdb-server during system startup and shutdown:
#/Bin/sh
#
# Chkconfig: 345 98
# Description: SSDB is a fast NoSQL database for storing big list of billions of elements
# Processname: ssdb

Case "$1" in
'Start ')
/Usr/local/ssdb-server-d/usr/local/ssdb. conf
Echo "ssdb started ."
;;
'Stop ')
Kill 'cat/usr/local/ssdb/var/ssdb. pid'
Echo "ssdb stopped ."
;;
'Restart ')
Kill 'cat/usr/local/ssdb/var/ssdb. pid'
Echo "ssdb stopped ."
Sleep 0.5
/Usr/local/ssdb-server-d/usr/local/ssdb/
Ssdb. conf
Echo "ssdb started ."
;;
*)
Echo "Usage: $0 {start | stop | restart }"
Exit 1
;;
Esac

Exit 0

Put? Save as/etc/init. d/ssdb. sh (root permission required), and then execute? :
Chmod ugo + x/etc/init. d/ssdb. sh

Add ssdb to chkconfig and set startup.

[Azureuser @ mono init. d] $ sudo chkconfig -- add ssdb. sh
[Azureuser @ mono init. d] $ chkconfig ssdb. sh on

The command to start and stop is as follows:

[Azureuser @ mono init. d] $ sudo service ssdb. sh stop
Ssdb stopped.
[Azureuser @ mono init. d] $ sudo service ssdb. sh start
Ssdb 1.6.7
Copyright (c) 2012-2013 ideawu.com

Ssdb started.

C # APIs are added to the project code:

[Azureuser @ mono dotnet] $ sudo dmcs Client. cs Link. cs Program. cs-out: ssdbClient.exe
[Azureuser @ mono dotnet] $ mono ssdbClient.exe
OK
1
OK
100
99
-----------------
1 kvs
A: 99
-----------------
0 kvs
-----------------
0 kvs
0

Ssdb basics (Chinese)

Network protocol design concept and SSDB network protocol

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.