A detailed article on NoSQL database Redis

Source: Internet
Author: User
Tags memcached redis version redis cluster value store

A detailed description of the branch product of DB

osql Database Introduction

is a non-relational database service, it can solve the common database concurrency, such as traditional database IO and performance bottlenecks, as well as a relational database is a supplement, has a relatively good efficiency and high performance.

Redis, memcached, Ttserver focused on key-value queries

Resolve the following issues:

1) High concurrent read and write requirements to the database
2) Efficient storage and access requirements for big data
3) High scalability and high availability requirements
The application environment of NoSQL database

1) data model is relatively simple
2) Need for more flexible IT systems
3) High performance requirements for the database
4) No need for high data consistency
5) for a given key, it is easier to map complex values to the environment
The classification and characteristics of NoSQL software

1) Key-value key-value store database (Redis, memcached)

1. For content caching, suitable for load and extended large datasets

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

3. Quick query function, but less structure of storage data

4. Poor support for transactions, no rollback when database failure occurs

2) Columnstore Database (HBase)

1. For Distributed File systems

2. Clustered storage, together with the same column data

3. Find Fast, scalable and easy to distribute

4. Function relative limitation

3) file-oriented database (MongoDB)

1. More For Web applications

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

3. Query performance is not high, there is no unified query syntax

4) Graphical Database (graph)

1. More Social network applications

2. Not easy to do distributed cluster scheme

Introduction to commonly used NoSQL databases

1) memcached

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

Characteristics:

1, install the deployment of simple
2. Support High concurrency, high performance
3, through the program or load balancing can achieve distributed
4, memory cache only, restart service data loss

2) Memcachedb

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

Characteristics:

1. High concurrent Read and write
2. Efficient storage
3. High-availability data storage

How to choose NoSQL Database in production environment

1, the most common cache application, memcached most suitable
2. Persistent storage Solution Memcachedb
3, 20 million the amount of data within the small data with memcached
4, large data volume can be used Redis
Redis Persistent Data Service

REmote DIctionary Server (redis) is a persistent database storage system based on Key-value key-value pairs, with more support for data storage types, including strings, lists, collections, etc.

is a persistent caching service, which periodically writes updated data to disk and records the modification operation record appended to the file, also supports master-slave synchronization mode, is an open source C-based language, supporting the network, memory persistence of the log-type, Key-value database

Features of the Redis durable service

Key-value key value type storage System

Support for reliable data storage

Single-process single-thread high-performance server

Recovery is relatively slow

Single-machine QPS (seconds concurrent) up to 10W

For small data high-speed read/write access

Redis Storage System Advantages and disadvantages:

Can persist data storage

Supports read and write frequencies of 10W per second

Support for rich data types

All operations are atomic.

Support for master-slave replication of different machines

High memory management overhead (3/5 less than physical memory)

Different command delays vary greatly

Introduction to Redis Persistence

Redis stores data in memory, using snapshots and logs to achieve persistent storage, where performance is high and data is lost, the latter being the opposite.

Redis Application Scenarios

Mysql+memcached Web site Architecture problems: Large data needs to be split, need to scale, data consistency is a problem

1) The best application scenario is the memory service
2) as a memcached alternative
3) business with a certain requirement for data consistency but not high
4) Need more data type support for business
5) The need for master-slave synchronization and load balancing business
Installation of Redis

For master-Slave synchronization configuration, failover can be achieved, the Lord disable data persistence, from the configuration, memory is big enough

wget http://download.redis.io/releases/redis-2.8.24.tar.gz
[[email protected] tools] #tar zxf redis-2.8.24.tar.gz
[[email protected] tools] #cd redis-2.8.24
[[email protected] redis-2.8.24] #make
[[email protected] redis-2.8.24] #make prefix=/application/redis-2.8.24 Install
[[email protected] redis-2.8.24] #ln-S/application/redis-2.8.24/application/redis
[Email protected] tools]# Tree/application/redis
/application/redis
-- bin<br/>|-- redis-benchmark #性能测试工具<br/>|-- redis-check-aof #检测更新日志<br/>|-- redis-check-dump #检查本地数据库rdb文件<br/>|-- redis-cli #命令行客户端操作工具<br/>|-- redis-sentinel -&gt; redis-server<br/>--Redis-server #服务的启动程序

Configuring Environment variables

[Email protected] tools]# echo "Path=/application/redis/bin: $PATH" >>/etc/profile
[Email protected] tools]# Source/etc/profile
[email protected] tools]# which redis-server
/application/redis/bin/redis-server

View Help documentation

[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 <megabytes>
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

Start the service

[Email protected] ~]# cd/application/redis/
[email protected] redis]# LL
Total 4
Drwxr-xr-x 2 root root 4096 Mar 04:50 bin
[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] Mar 05:00:51.373 # Server started, Redis version 2.8.24
[6072] April 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.overcomm It_memory=1 ' for the take effect.

#内存不足的时候, data loading to disk may fail, and you can use the command to resolve or modify the configuration file

[6072] April 05:00:51.375 # warning:the TCP Backlog setting of 511 cannot be enforced BECAUSE/PROC/SYS/NET/CORE/SOMAXCO NN is set to the lower value of 128.
[6072] 05:00:51.375 the server is now ready to accept connections on port 6379
[[email protected] 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 indicates that the kernel is trying to estimate the remaining available memory when the user space requests more memory
1 means the kernel allows maximum use of memory

Close Service Command

[Email protected] redis]# REDIS-CLI shutdown
[6072] 05:09:32.699 # User requested shutdown ...
[6072] April 05:09:32.699 Saving the final RDB snapshot before exiting.
[6072] 05:09:32.710
DB saved on disk
[6072] April 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 scenario combat process

A detailed article on NoSQL database Redis

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.