Redis, memcached, MongoDB comparison and installation

Source: Internet
Author: User
Tags memcached

One, Redis, memcached, mongoDB contrast

Memcached and Redis are all in-memory databases, data is stored in memory, directly accessed via TCP, fast and high concurrency. MongoDB is a document-type non-relational database, its advantage is that the query function is more powerful, can store massive data.

Memcached is a high-performance distributed memory object caching system for dynamic Web applications to mitigate database load. It provides a dynamic, database-driven site speed by caching data and objects in memory to reduce the number of times the database is read. Memcached distribution is not implemented on the server side, but in the client application, that is, through the built-in algorithm to develop the target data node, Memcached distributed is based on the client's key hash to do the equalization, is a pseudo-distributed system.

Redis is a key-value storage system. Similar to Memcached, it supports storing more value types, including string (string), list (linked list), set (set), and Zset (ordered collection). These data types support Push/pop, Add/remove, and intersection-set and difference sets, and richer operations, and these operations are atomic. Based on this, Redis supports sorting in a variety of different ways. As with Memcached, data is cached in memory to ensure efficiency. The difference is that Redis periodically writes the updated data to the disk or writes the modification to the appended record file.

Second, Redis, memcached, MongoDB installation

Redis installation, one-click installation script Follow-up attached *************************************

1. Download Redis2.8.19 and install Tcl-8.6.3

wget http://download.redis.io/releases/redis-2.8.19.tar.gz
wget http://downloads.sourceforge.net/tcl/tcl8.6.3-src.tar.gz
TAR-ZXF tcl8.6.3-src.tar.gz
CD tcl8.6.3/unix/
./configure
Make
Make install
TAR-ZXF redis-2.8.19.tar.gz
CD redis-2.8.19

2. Compiling

[[email protected] redis-2.8.19]# make

3. Installation

[[email protected] redis-2.8.19]# make Prefix=/usr/local/redis install after this step, Redis is installed under the/usr/local/redis/.

4, configuration, the following is to modify the configuration file
CP./redis.conf/usr/local/redis/
Vim/usr/local/redis/redis.conf

Daemonize Yes #redis将以守护进程的方式运行, default to No will take up your terminal

Timeout #当 The client is idle for how long after the connection is closed, and if specified as 0, turns off the feature

Dir/data/redisdb #指定数据库持久化数据目录

Mkdir-p/data/redisdb #创建redis数据存放目录

5. Running/turning on Redis
/usr/local/redis/bin/redis-server


memcached installation, one-click installation script Follow-up attached ********************************* ****


First, install GCC, make and libevent
Yum-y Install GCC make

wget http://www.monkey.org/~provos/libevent-2.0.12-stable.tar.gz
Tar zxf libevent-2.0.12-stable.tar.gz
CD libevent-2.0.12-stable
./configure
Make && make install

Second, download memcached installation:
wget http://memcached.org/files/memcached-1.4.20.tar.gz
CD memcached-1.4.20
./configure--prefix=/usr/local/memcached--with-libevent=/usr/local/lib
Make && make install


Third, configuration start

# vi/etc/rc.local

#!/bin/sh
#
# This script is executed *after* all and the other init scripts.
# can put your own initialization stuff in here if you don ' t
# want to does the full Sys V style init stuff.
Touch/var/lock/subsys/local

/usr/local/memcached/bin/memcached-p 12621-u 0-d-r-u root-m 2040-c 1024-t 4

Quit after saving, start service manually
/usr/local/memcached/bin/memcached-p 12621-u 0-d-r-u root-m 2040-c 1024-t 4

MongoDB installation, one-click installation script Follow-up attached *********************************** **

1. Download and install

wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.0.1.tgz
TAR-ZXVF mongodb-linux-i686-2.0.2-rc2.tgz
MV Mongodb-linux-i686-2.0.2-rc2 MongoDB

Create a new data directory in the MongoDB directory to hold the information, create a new log directory to hold the log, and then create a new logfile under the directory named Mongodb.log

mkdir Log
mkdir data
CD Log
Touch Mongodb.log

Then go into the Mongodb/bin directory.

CD Mongodb/bin
Use the Mongod command to set up a MongoDB database link with a port number of 100001, a database path of/mongodb/data, and a log path of/mongodb/log/mongodb.log

2. Start test
Start command:
./bin/mongod-port 10001--dbpath data/--logpath log/mongodb.log
All output Going To:log/mongodb.log
Use the client to connect to the database
Re-open a terminal and switch to the MongoDB directory:

CD Usr/local/mongodb
Then use the Bin/mongo command to connect to the database

./bin/mongo localhost:10001


Access via browser
In the browser address bar, enter: http://localhost:10001/and then enter to access
You can see the following prompt: You is trying to access MongoDB on the native driver port. For HTTP diagnostic access, add the port number
Then follow the prompts to add the port number 1000 access http://localhost:11001/,
will be able to access the server-side web page of Monodb

Configuring MongoDB with configuration Files
First create a new file in the MongoDB directory, the file name arbitrary, here I named: mongodb.conf

VI mongodb.conf
Then add the configuration information in the configuration file

port=10001
dbpath=data/
Logpath=log/mongodb.log
Logappend=true
Explanatory notes:
Port=10001 "represents the port number and defaults to 27017 if not specified."
dbpath=data/"Database Path"
Logpath=log/mongodb.log "Log Path"
Logappend=true "Log files automatically accumulate, not overwrite"

Start MongoDB Service
./bin/mongod-f mongodb.conf
All output Going To:log/mongodb.log
And then access the same way as before.

Redis, memcached, MongoDB comparison and installation

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.