0. Introduction
NoSQL (NoSQL = not-only sql), meaning "not just SQL," refers to a non-relational database, because NoSQL is more than just a database. Like MySQL and Oracle in relational databases, NoSQL also has memcached, MongoDB, and Redis.
NoSQL Database Storage principle is very simple (the typical data type is k-v), there is no complex chain of relationships, such as MySQL query, you need to find the corresponding library, table (usually multiple tables) and fields. NoSQL data can be stored in memory and queries are very fast, so NoSQL databases have rapidly taken over the market with the development of massive data demand in the Internet in recent years. Although NoSQL outperforms relational databases in performance, it does not completely replace relational databases. NoSQL supports distributed storage, but its distribution is implemented by client-side algorithms, which can be used to store data in a variety of formats, including images, videos, files, and database retrieval results, by maintaining a unified, huge hash table in memory. The simple thing is to call the data into memory and then read it from memory, which greatly improves the reading speed. Reduce database load and improve performance in dynamic systems.
The Memcache module is an efficient daemon that provides procedural and object-oriented interfaces for in-memory caching, especially when designing dynamic Web programs to reduce access to the database. It is suitable for situations where data access is very frequent.
Now you're going to look at the NoSQL technology, and you're planning to write three articles, mostly for getting started.
1. How to install memcached
As the first article in the memcached database, let's start with the installation of the environment. Installation method is relatively simple, right when a record to understand it.
System Environment: CENTOS7
The memcached operation requires support for the Libevent library because memcached needs to support non-blocking IO access.
1.1 Source Installation Libevent
cd /usr/local/src/ wget wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gztar zxvf libevent-2.1.8-stable.tar.gzcd libevent-2.1.8-stable./configure --prefix=/usr/local/libevent/make && make install
1.2 Source Installation memcached
wget https://www.memcached.org/files/memcached-1.5.7.tar.gztar -zxvf memcached-1.5.7.tar.gz ./configure --with-libevent=/usr/local/libevent --prefix=/usr/local/memcachedmake && make installnetstat -lntp
2. Start memcached
/usr/local/memcached/bin/memcached -d -m 100 -u root -p 11211 -c 256 -P ./memcached.pid
Parameter description:
-d 选项是启动一个守护进程。-m 是分配给Memcache使用的内存数量,单位是MB。-u 是运行Memcache的用户。-l 是监听的服务器IP地址。-p 是设置Memcache监听的端口。-c 选项是最大运行的并发连接数,默认是1024。-P 是设置保存Memcache的pid文件,保存在 /tmp/memcached.pid。也可以启动多个守护进程,不过端口不能重复。
3. Verify the Listening port
[[email protected] memcached-1.5.7]# netstat-lntpactive Internet connections (only servers) Proto recv-q send-q Local address Foreign Address State Pid/program name TCP 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 9593/nginx:master TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1073/sshd TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2173/master TCP 0 0 0.0.0.0:12000 0.0.0.0:* LISTEN 20089/memcached TCP6 0 0::: +:::* LISTEN 9593/nginx:master TCP6 0 0::: $:::* LISTEN 1073/sshd tcp6 0 0 :: 1:25:::* LISTEN 2173/master tcp6 0 0::: 12000 :::* LISTEN 20089/memcached
4. Summary
This is a brief introduction to Memcached's function and installation steps. The next article analyzes how it is used in memory.
NoSQL Series (1)--memcached source installation use