NoSQL database What is a NoSQL database?
Non-relational database is NoSQL, relational database represents MySQL;
relational database, it is necessary to store data into libraries, tables, rows, fields, the query needs to be based on the criteria of a row of matching, need to retrieve from the disk, time and resources to consume;
NoSQL database, the storage principle is simple (data type is K-V), data can be stored in memory, query speed is very fast, the extension is very easy, support distributed;
A common NoSQL database
K-v form: memcached, Redis suitable for storing user information, such as reply, configuration files, parameters, shopping cart and so on. This information is usually linked to the ID (key), which is a good choice in the context of the key-value database;
Document database: MongoDB stores the data as a document;
Column storage: Hbase
Figure: neo4j, Infinite graph, Orientdb
memcached Introduction
Features: Cache database query results, reduce database access times, illegible improve dynamic Web site performance;
Official website: www.memcached.org
The data structure is simple (k-v), the data is stored in memory, the restart data is lost, and the data must be saved to the hard disk before restarting;
Multithreaded
Based on C/S architecture, the protocol is simple;
Time processing based on libevent;
Autonomic memory storage processing (slab allowcation)
Data expiration methods: Lazy Expiration and LRU
~~
Install memcached Source Package
yum install -y libmemcached libeventyum install -y memcached
Start
systemctl start memcached
Configuration file
监听的ip,可以将OPTIONS="" 改为OPTIONS="127.0.0.1"其中-m指定memcached 分配内存,单位为M-c 指定最大并发数-u 指的是运行memcached服务的用户-p 为监听端口
View Run status
memcached-tool 127.0.0.1:11211 stats或者echo stats |nc 127.0.0.1 11211 需要安装nc工具memstat --servers=127.0.0.1:11211get_hits:命中了多少curr_items:缓存了多少
NoSQL Database Introduction, memcached Installation