Redis Installation and configuration process

Source: Internet
Author: User
Tags memory usage redis

Redis Introduction

Redis essentially a key/value database, similar to the memcached NoSQL database, but his data can be persisted on disk, solve the service restart after the data is not lost, his value can be string (string), Lists (list), sets (set), or ordered sets (sorted collection), all data types have Push/pop, Add/remove, execute service-side sets, intersections, two-sets sets of differences, and so on, all of which are atomic , Redis also supports a variety of different sorting capabilities

Redis 2.0 Adds a number of new features, such as improved performance, new data types, and less memory usage (AOF and VM)

Redis supports most mainstream development languages, such as C, Java, C #, PHP, Perl, Python, Lua, Erlang, Ruby, etc.

Official website: http://code.google.com/p/redis/

 

installation Process

the latest stable version, Redis 2.0.4 stable

wgethttp://redis.googlecode.com/files/redis-2.0.4.tar.gz

tar zxf redis-2.0.4.tar.gz

CD redis-2.0.4

Unlike other software, configure is not required.

Make

finished.

 

Create a directory

Mkdir/usr/local/redis2

CP redis-server Redis-benchmark redis-cli Redis.conf/usr/local/redis2

 

Start:

./redis-server >/dev/null &

 

Test:

stored value:

./REDIS-CLI Set HX Value

Take value:

./REDIS-CLI Get HX

 

Installing the Phpredis module

 

Https://github.com/owlient/phpredis

 

Download Phpredis

Decompression

shell> CD Phpredis

shell>/usr/local/php/bin/phpize This phpize is the installation of the PHP module

shell>./configure–with-php-config=/usr/local/php/bin/php-config

shell> Make

shell> make install

Next in php.ini add extension=redis.so first to see if there is extension_dir=/ ....

Restart Apache or Nginx

 

PHP Code Test

$redis = new Redis ();

$redis->connect (' 127.0.0.1′,6379);

$redis->set (' Test ', ' Hello world! ');

echo $redis->get (' test ');

?>

Output Hello world!

http://code.google.com/p/php-redis/

 

Redis master and slave configuration

Redis Master and subordinate configuration is quite simple, some articles wordy wrote a large article, in fact, two words:

Open the redis.conf from the machine

Port 6381 (Note: cannot be the same as the host)

Sleverof10.0.0.149 6383 (Note: IP for host ip,6383 for host Redis port number)

Reboot the host before restarting the machine

run./redis-server redis.conf

if present:

 

, indicating that the configuration was successful.

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.