An article detailed Nosql database Redis

A picture to explain the branch products of DB
An article to explain the NOsql database Redis
Introduction to osql database

It is a non-relational database service that can solve the concurrency capabilities of conventional databases, such as traditional database IO and performance bottlenecks, the same It is a supplement to the relational database and has relatively good high efficiency and high performance.

Redis, memcached, ttserver focusing on key-value queries

Solve the following problems:

1) High concurrent read and write requirements for the database
2) Requirements for efficient storage and access of big data
3) Requirements for high scalability and high availability
Application environment of Nosql database

1) Data model Relatively simple
2) Need a more flexible IT system
3) High performance requirements for the database
4) No high data consistency
5) For a given KEY, it is easier Mapping complex value environment
Classification and characteristics of Nosql software

1) Key-value key-value storage database (redis, memcached)< /p>

1. Used for content caching, suitable for loading and expanding large data sets

2. The data type is a series of key-value pairs

3. Fast Query function, but the stored data is less structured

4. The support for transactions is not good, and the rollback cannot be performed when a database failure occurs.
An article explains the NOsql database Redis
2) Column storage database (HBase)

1. For distribution File system

2. Store the same column of data together in clusters of columns

3. Fast search speed, strong scalability, and easier distributed expansion

p>

4. Relatively limited functions
An article explains NOsql database Redis
3) File-oriented database (mongoDB)

1. It is more used for WEB applications

2. The data type is a series of key-value pairs

3. The query performance is not high and there is no unified query syntax.
An article explains NOsql database Redis
4) Graph database (Graph)

1. There are many social network applications

2. It is not easy to make distributed cluster solutions

Introduction to commonly used Nosql databases

1) memcached

Is an open source high-performance cache system with distributed memory objects

Features:

p>

1. Simple installation and deployment
2. Supports high concurrency and high performance
3. Distributed by program or load balancing
4. Only memory cache, restart Service data loss

2)memcacheDB

It is an open source project developed by Sina based on memcached, with transaction recovery function

Features:

1, high concurrent read and write
2, high-efficiency storage
3, high-availability data storage

How to choose a Nosql database for the production environment

1. The most conventional caching application, memcached is the most suitable
2, the persistent storage solution memcacheDB
3, the amount of data within 20 million Memcached for small data
4, redis for large data volume
redis persistent data service

REmote DIctionary server (redis) is a key-value-based key The persistent database storage system of value pairs supports more data storage types, including strings, lists, collections, etc.

It is a persistent cache service that periodically writes updated data to disk And the modification operation record is appended to the file to record, and it also supports the master-slave synchronization mode. It is an open source C language based on the log type and key-value database that supports network and memory persistence.

Characteristics of redis persistent service

Key-value key-value type storage system

Support reliable data storage

Single process and single thread High-performance server

Recovery is slower

Single machine qps (second concurrency) can reach 10W

Suitable for high-speed read and write access to small data

The advantages and disadvantages of the redis storage system:

Data can be stored persistently

Support 1 per second 0W read and write frequency

Support rich data types

All operations are atomic

Support different machine master-slave replication

High memory management overhead (lower than 3/5 of physical memory)

Different commands vary greatly in latency

Introduction to redis persistence

< p>redis stores data in memory and implements persistent storage in two ways: snapshots and logs. The former has high performance and data loss may occur, while the latter is the opposite.
An article explains NOsql database Redis
Redis application scenarios

The problem with the MYSQL+memcached website architecture: the large amount of data needs to be dismantled and the table needs to be expanded. Data consistency is a problem

1) The best application scenario is the memory service
2) As an alternative to memcached
3) Businesses that have certain requirements for data consistency but not high
4) Businesses that require more data type support
5) Businesses that require master-slave synchronization and load balancing
Redis installation

To perform master-slave synchronization configuration, failover can be achieved, data persistence is disabled on the master, and the configuration from the top must be large enough for memory

wget http://download.redis.io/releases/redis-2.8.24.tar.gz
[[emailprotected] tools]#tar zxf redis-2.8.24.tar. gz
[[emailprotected] tools]#cd redis-2.8.24
[[emailprotected] redis-2.8.24]#make
[[emailprotected] redis-2.8.24]#make PREFIX=/application/redis-2.8.24 install
[[emailprotected] redis-2.8.24]#ln -s /application/redis-2.8.24 /application/redis
[[emailprotected] tools ]# tree /application/redis
/application/redis
-- bin
|-- redis-benchmark #performance test tool
|-- redis-check-aof # Check the update log
|-- redis-check-dump #Check the local database rdb file
|-- redis-cli #Command line client operation tool
|-- redis- sentinel -> redis-server
— redis-server #Service startup program

Configure environment variables

[[emailprotected] tools]# echo “PATH=/application/redis/bin:$PATH”>>/etc/profile
[[emailprotected] tools]# source /etc/profile
[[email Protected] tools]# which redis-server
/application/redis/bin/redis-server

View help documentation< /p>

[[email protected] tools]# redis-server –help
Usage: ./redis-server [/path/to/redis.conf] [options]
. /redis-server-(read config from stdin)
./redis-server -v or –version
./redis-server -h or –help
./redis-server –test -memory
Examples:
./redis-server (run the server with default conf)
./redis-server /etc/redis/6379.conf
./redis-server –port 7777
./redis-server –port 7777 –slaveof 127.0.0.1 8888
./redis-server /etc/myredis.conf –loglevel verbose

< p>Start service

[[emailprotected] ~]# cd /application/redis/
[[emailprotected] redis]# ll
total 4
drwxr-xr-x 2 root root 4096 Mar 22 04:50 bin< br>[[email Protected] redis]# mkdir conf
[[email Protected] redis]# cp /download/tools/redis-2.8.24/redis.conf ./conf/
[[email Protected] redis]# redis-server /application/redis/conf/redis.conf &
[6072] 22 Mar 05:00:51.373 # Server started, Redis version 2.8.24
[6072] 22 Mar 05:00 :51.374 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add’vm.overcommit_memory = 1’to /etc/sysctl.conf and then reboot or run the command’sysctl vm.overcommit_memory =1′ for this to take effect.

#When the memory is insufficient, data loading to the disk may fail. You can use commands to solve or modify the configuration file

[6072] 22 Mar 05:00:51.375 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
[6072] 22 Mar 05:00:51.375 The server is now ready to accept connections on port 6379
[[emailprotected] redis]# lsof -i :6379
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
redis-ser 6072 root 4u IPv6 24271 0t0 TCP
:6379 (LISTEN)
redis-ser 6072 root 5u IPv4 24273 0t0 TCP *:6379 (LISTEN)
vm.overcommit_memory

0 means user space requests more memory When the kernel tries to estimate the remaining available memory
1 means that the kernel allows the maximum use of memory

Turn off the service command

[ [email protected] redis]# redis-cli shutdown
[6072] 22 Mar 05:09:32.699 # User requested shutdown…
[6072] 22 Mar 05:09:32.699 Saving the final RDB snapshot before exiting.
[6072] 22 Mar 05:09:32.710
DB saved on disk
[6072] 22 Mar 05:09:32.711 # Redis is now ready to exit, bye bye. ..
[1]+ Done redis-server /application/redis/conf/redis.conf

Redis cluster production environment high availability solution actual combat process

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 661 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.