Redis vs Memcached and installation configuration under CentOS

Source: Internet
Author: User

Check out Redis

Redis is an open source, support network, memory-based, key-value-pair Key-value database, written in ANSI C, and available in a variety of language APIs, it's almost no difficulty, it takes only a few minutes to complete the installation work, and let it start working seamlessly with the application. In other words, with just a fraction of the time and effort, you can get an immediate and very good performance boost, which means it's a very simple caching solution. It supports storage of the Value type is not limited to strings, support master-slave synchronization, data persistence and so on, we all think that Redis is the most popular key-value storage database, someone must have asked Memcached?

Redis VS Memcached

First of all, I just went to db-engines.com database ranking, Redis ranked Nineth, Key-value store first place, Memcached ranked 23, Key-value store second place. That certainly doesn't explain anything.

Redis supports more data types, including: string, Hash, List, set;memcached support only one string data type.
Redis can support the concept of transactions through commands such as Multi/watch/exec, atomically execute a batch of commands, and in Memcached's application mode, there is no support for transactions except for atomic operations commands such as Increment/decrement.
Redis can configure the server to implement master-slave synchronous backup in a master-slave way, while holding only two persistence schemes, Memcached does not guarantee the validity of the stored data and does not persist the data. Of course, none of this can explain anything.

Every thing that exists in this world always has his meaning. Memcached's internal memory management mechanism, though not as complex as Redis's, is more effective because Memcached consumes less memory resources when it processes metadata, and is more advantageous in scale-out than Redis. Due to its design mindset and relatively simple function setting. For example, it is better to use Memcached when caching a string or HTML page.

Installing Redis under CentOS

1. Download the unzip installation Redis, this is the latest version of the 3.2.5, which is downloaded from the official website, still downloaded via wget (I like this way).

wget Http://download.redis.io/releases/redis-3.2.5.tar.gztar xzf REDIS-3.2.5.TAR.GZMV Redis-3.2.5/usr/local/redis

The above MV Redis-3.2.5/usr/local/redis command is a mobile Redis installation file to the installation directory, of course this directory you can customize.

2. Go to directory, compile and install

Cd/usr/local/redismakemake Install

Installation is complete, this time will see in the/usr/local/bin/directory Redis-server, REDIS-CLI and so on this executable script, enter to see, if not, will go to unzip the directory to copy into.

cd/usr/local/bin/

3. Configure redis.conf

Go back to the/usr/local/redis directory and configure:

Cd.. /redisvim redis.conf

There are two places to change, a bind and a daemonize on the line.
Bind here to note that the default is only one 127.0.0.1, this time can only connect themselves, the other LAN is not connected. Therefore, multiple IPs need to be configured so that they can be connected within the LAN.

Daemonize is setting whether Redis is started in the background, default no, and normally requires Redis to be started as a service, so this is set to Yes.

When you are finished modifying, save the exit.

4. Start

CD/USR/LOCAL/BIN/REDIS-SERVER/USR/LOCAL/REDIS/REDIS.CONFNETSTAT-ANP | grep 6379

5. Test
Here, use the command line mode to connect to Redis for a simple setup, to get the cache test.

Redis-cli    #连接 Redis, which is native by default. Keys *       #查看现在所有 keyset name mafly    #设置一个key为 ' name ', value is ' mafly ' of the cached object. Get name     #获取key为 ' name ' of the cache

6. Turn off Redis

REDIS-CLI shutdown

By netstat you can see that the port is already in time_wait state.

Summarize

After this installation of the Redis process, but also let me know more about the Memcached, but also understand the two most popular Key-value cache service advantages and disadvantages, of course, most of them are obtained through the network, in the actual use of how also in monitoring.

  • 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.