SSDB basics and usage

Source: Internet
Author: User
Tags install redis

SSDB basics and usage

There are several reasons for using SSDB at that time. First, when designing the contest module, You need to query the Rank of the current competition multiple times because you click to query the Rank of the current competition, the amount of data queried each time is large. to efficiently obtain data, the SSDB database is used. The second aspect is to record the user's AC status. After the user logs in, the web page must display the questions and questions that the user AC has tried but failed. In order to traverse all the submit stored in the current system, the data volume is also large. Follow the previous principles and continue to use SSDB for solutions.

1: What is SSDB?

Baidu once failed to find Baidu encyclopedia. One definition is that SSDB is an open-source high-performance database server that uses Google LevelDB as the storage engine and supports T-level data. Literally, this database has high performance (/□ \)). Then, we need to use the feature of high query speed.

2: Main Characteristics of SSDB (Entry statistics (/□\), we mainly use the k-v mode, that is, the key-value ):

Supports zset, map/hash, list, and kv data structures to replace Redis

It is particularly suitable for storing a large amount of Set Data and supports a wide range of data structures: key-value, key-map, key-zset, and key-list.

Use Google LevelDB as the storage engine

Supports master-slave synchronization and multi-master synchronization.

The client supports PHP, C ++, Python, Lua, Java, Ruby, nodejs, and Go.

Memory usage is very small

3: Installation and start stop

We recommend that you install the release method in SSDB by compiling and installing the source code. We recommend that you run the release line environment in mainstream Linux releases of the release line version. log on to your server remotely using SSH, and then use the following commands to download, compile, install, and run the following commands:

# Installation

$ 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

$ Sudo./ssdb-server ssdb. conf

# Start as a daemon

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

# Stop

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

SSDB is installed in the/usr/local/ssdb logs directory by default. ssdb-server is the server program, and ssdb-cli is the command line client.

 

4: Configuration

The SSDB. conf file attached to ssdb is a configuration file, which can be used without modification .. 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.

Use the ssdb that comes with the producer when you enable the consumer. when the conf file is configured, the volume log volume file generated by SSDB logs is segmented by volume. therefore, you need to write your own crontab to compress logs and regularly clean the logs.
If a system fault such as server power failure or kernel panic occurs, after the system is restarted, You need to manually delete the ssdb PID file ssdb. pid before starting the ssdb.

Install Redis and build an ssdb master-slave environment under Ubuntu 14.04

Open-source bitcoin transaction record project Btcplex uses SSDB Database

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

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.