Nosql database introduction, Memcached installation

NoSQL database

What is a NoSQL database?

Non-relational databases are NoSQL, and relational databases represent MySQL;

Relational databases need to store data in libraries, tables, In the rows and fields, the query needs to match the rows according to the conditions, and needs to be retrieved from the disk, which consumes time and resources;
NoSQL database, the storage principle is simple (the data type is KV), and the data can be Stored in memory, query speed is very fast; expansion is very easy, support distributed;

Common NoSQL database

kv form: memcached , Redis is suitable for storing user information, such as answers, configuration files, parameters, shopping carts, and so on. This information is generally linked to ID (key). In this scenario, a key-value database is a good choice;
document database: mongodb stores data in the form of documents;
column storage: Hbase
Picture: Neo4j, Infinite Graph, OrientDB

Introduction to memcached

Features: cache database query results, reduce the number of database visits, and improve dynamic web site performance;
Official website: www.memcached.org

The data structure is simple (kv), and the data is stored in the memory; the data will be lost after restarting. Data must be saved to the hard disk before restarting;
Multithreaded;
Based on c/s architecture, simple protocol;
Time processing based on libevent;
Autonomous memory storage processing (slab allowcation)
Data expiration method: Lazy Expiration and LRU
~~

Install memcached

Source package

yum install- y libmemcached libevent
yum install -y memcached

Start

systemctl start memcached

Configuration file

vim /etc/ sysconfig/memcached
The monitored ip, you can change OPTIONS="" to OPTIONS="127.0.0.1"
where -m specifies the memory allocated by memcached, the unit is M
-c Specify the maximum number of concurrency
-u refers to the user running the memcached service
-p is the listening port

View running status

memcached-tool 127.0.0.1 :11211 stats
or echo stats |nc 127.0.0.1 11211 need to install nc tool
memstat --servers=127.0.0.1:11211

get_hits: how many hits
curr_it ems: How much is cached

Leave a Comment

Your email address will not be published.