SSDB is a high-performance KV storage database, personally developed and open source. With its compatibility with redis protocol, support for data hard disk storage, and ease of use, it has a certain reputation in the industry. The main solution for SSDB is the storage problem of Redis. The bottom layer is based on LevelDB for storage, which can greatly reduce data storage costs. For specific product introductions, please refer to its official website.
Tendis is a Redis hybrid storage version product launched by Tencent Cloud, which is 100% compatible with the native redis cluster protocol, which satisfies the low-cost storage of massive data while taking into account the usage habits of Redis. For most small and medium-sized customers, redis is used frequently, and the amount of cached data is also increasing day by day, and the data costs they face are also increasing. The launch of Tendis is a product to solve the pain points of such customers. For specific product introduction, please refer to Official Website Document.
The main differences between SSDB and Tendis are as follows:
Comparison item | Tendis | SSDB |
---|---|---|
Product Type | Cloud Service | Open Source |
Product Team | Tencent Cloud Database Product Expert Team | Personal |
Product iteration | The business side does not need to pay attention | The personal energy is limited, the problem cannot be solved in time, the business side needs to be familiar with the source code |
redis compatible | redis-cluster protocol compatible | redis protocol compatible |
Storage Type | Build based on RocksDB | Build based on LevelDB |
Large data storage | PB level, stable performance | GB level, when the master-slave single instance data specification reaches 100+GB, the performance drops severely |
The performance loss of the storage layer is small, the architecture is determined, the cache layer (redis) and the storage layer (rocksdb) are separated, the business directly interacts with the cache layer | large, the business directly interacts with LevelDB, and some mechanisms of the storage layer such as Compaction consume resources More serious, it will block business read and write, and other things like data synchronization and backup also have a greater impact on the node |
Only some of the comparison items are listed above. The biggest problem found in the process of testing ssdb is that there are many places where the implementation is not rigorous. Once the amount of data is large, the impact on the business is relatively large, such as the Compaction of the LevelDB layer, memory OOM issues, etc. It is a common problem in the community. It requires the business side to be familiar with the SSDB source code and make corresponding modifications to meet certain business needs, which places higher requirements on the business side and cannot focus on the business itself. This is why the SSDB data migration program is designed.
SSDB is a Redis-compliant KV storage product developed based on LevelDB. The product architecture model is the same as the Redis standard single instance, which supports single-master and master-slave synchronization architecture. Tendis belongs to the cluster mode, similar to the Redis Cluster architecture. There are some differences between the single-instance version of Redis and the clustered version of Redis. For example, all keys are distributed on a single master instance. Now the slot is split into multiple node instances in the cluster, and the keys are further broken up, like the original Some logic involving transactions and pipelines may be affected. If there is a lot of code logic involving transactions and pipelines on the business side, you need to consider how to adapt to the cluster version of the instance. This involves specific business analysis, so I won't introduce it in this article. Some other non-standard version of redis supports commands, such as keys and scan. The implementation logic on the cluster version is also different from the single instance version and requires special treatment.
During the migration process, the third-party open source synchronization tool [ssdb-port] (https://github.com/imneov/ssdb-port) will be relied on. On the basis of open source tools, some source code transformations have been made to adapt to the synchronization efficiency of large keys and billion-level keys. The download address of the internal transformation version is Siphon-V2. Tool description:
Used to connect and log in to Tendis instances, currently compatible with the protocol of the Redis-4.x
version. Download the redis source code package directly from the official website and compile it. Refer to the official compilation and installation tutorial.
The verification migration plan relies on the Tencent Cloud environment, and you need to apply for a Tencent Cloud account in advance to apply for related Tencent Cloud resources. Please refer to Tencent Cloud official website tutorial for account application method
The migration plan requires the installation of the SSDB environment and related migration tools, and a CVM resource needs to be applied for as a data source verification. Specifications: 2C4G, Centos 7.X or CentOS 8.X.
The migration plan needs to rely on Tendis as the destination data source, apply for a minimum configuration Tendis instance (4 slices/64GB memory/200GB disk), and charge according to the flow. Currently, Tendis is deployed in Beijing, Shanghai, Guangzhou and Hong Kong.
The test connection to the tendis instance depends on the native redis-cli, you need to download the redis source code package to compile or download redis-cli directly. The Redis version compatible with Tendis is: 4.x
.
Download the source code package from the official website, version: 1.9.8
, download link. After downloading, upload the source code package ssdb-master.zip
to the CVM machine, unzip, compile and install. As follows:
unzip ssdb-master.zip
cd ssdb-master
make
make install
# Installed by default/usr/local/ssdb directory
cd /usr/local/ssdb
# Start ssdb-server
. /ssdb-server -d ./ssdb.conf -s start
# Enter the ssdb command line
. /ssdb-cli
The content of the SSDB-Server configuration file is as follows:
work_dir =./var
pidfile =./var/ssdb.pid
server:
ip:127.0.0.1
# Start port 8888 by default
port:8888
replication:
binlog: yes
sync_speed:-1
slaveof:
logger:
level: debug
output: log.txt
rotate:
size:1000000000
leveldb:
cache_size:500
write_buffer_size:64
compaction_speed:1000
compression: yes
From the above steps, the SSDB compilation and startup method is similar to redis, and it is easy to get started. For the setting of configuration parameters, you can refer to the instructions on the SSDB official website. The default parameters are used above.
Download the migration tool [iphon-v2] (https://tendis-public-1258272208.cos.ap-guangzhou.myqcloud.com/siphon_v2). Copy the tool to the corresponding directory of the CVM machine. The tools are used as follows:
Usage:
siphon sync [--pprof=0.0.0.0:6060][--ncpu=N][--parallel=M]--from=MASTER --target=TARGET [--frompassword=MASTERPASSWORD][--targetpassword=SLAVEPASSWORD][--hashlen=len][--dry=isdry]
Options:--pprof Set pprof addr and port,like 0.0.0.0:6060.-p M,--parallel=M Set the number of parallel, connection to redis.default is 10.-f MASTER,--from=MASTER Set host:port of master .-t TARGET,--target=TARGET Set host:port of target .-F MASTERPASSWORD,--frompassword Set password of master .-T SLAVEPASSWORD,--targetpassword Set password of target .-H LEN,--hashlen=len Set Hash field append length .-d isdry,--dry=isdry Just read from ssdb, not write target.
Compared with the native one, there are two more parameters: -H
and -d
.
The specific commands for using siphon-v2 are as follows:
#- p: control of the number of concurrent threads,-f: Specify ssdb-server address,-t: Specify the destination tendis address,-T: Specify tendis instance password
. /siphon_v2 sync -p 1-f 127.0.0.1:8888-t 172.16.16.47:6379-T tendis@pwd
Log in to ssdb-server and write a few pieces of data with commands. As follows:
[ root@VM-16-44-centos]# cd /usr/local/ssdb
[ root@VM-16-44-centos ssdb]# ./ssdb-cli
ssdb(cli)- ssdb command line tool.Copyright(c)2012-2016 ssdb.io
' h' or 'help'for help,'q' to quit.
ssdb-server 1.9.8
ssdb 127.0.0.1:8888> hset myhash k1 v1
ok(0.000 sec)
ssdb 127.0.0.1:8888> hset myhash k2 v2
ok(0.000 sec)
ssdb 127.0.0.1:8888> hset myhash k3 v3
ok(0.000 sec)
Open a new terminal to log in to CVM, and execute the following command to start the migration tool.
. /siphon_v2 sync -p 1-f 127.0.0.1:8888-t 172.16.16.47:6379-T tendis@pwd
After startup, you can see some console output, as shown below:
siphon_start.png
The red box in the figure identifies the full data synchronization process:
Then open a new terminal to log in to the CVM, log in to the Tendis instance to view the results of the full data synchronization.
[ root@VM-16-44-centos ~]# redis-cli -h 172.16.16.47-p 6379-a tendis@pwd
Warning: Using a password with'-a' option on the command line interfacemay not be safe.172.16.16.47:6379> hget myhash k1
" v1"172.16.16.47:6379> hget myhash k2
" v2"172.16.16.47:6379> hget myhash k3
" v3"172.16.16.47:6379>
From the above results, Tendis has synchronized the data just inserted in the ssdb-server.
For incremental data, the migration tool first synchronizes the full amount of data, and then the process does not exit, waiting for the generation of new data and performing incremental synchronization to Tendis.
This article only simulates the synchronization process of a small amount of data. In the actual business migration process, there are still many issues to consider, as follows:
Tencent Cloud has accumulated a lot of experience in the production and migration of business data, and there are also many tools that are open to customers, such as DTS services. If you need consultation and assistance in data migration, you can consult Tencent Cloud customer service at any time for corresponding services.
undefined