Installation and configuration of Redis

Source: Internet
Author: User
Tags benchmark download redis

first, what is Redis

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 disk or writes the modified operation to the appended record file, and Master-slave (Master-Slave) synchronization is implemented on this basis. Redis is a high-performance Key-value database. The emergence of Redis, to a large extent, compensates for the lack of memcached such keyvalue storage, in some cases can be a good complement to the relational database.

second, the installation of Redis

1. Pre-installation environment instructions

The landlord uses the CentOS 6.5 version of the Linux system, the IP is 192.168.0.100. The virtual machine tool is using VirtualBox.

2. Download Redis

Redis can go to the official website to download: Http://www.redis.io/download, now the latest stable version has reached 2.8.

The redis-2.8.8.tar.gz is used here.

3. Installation Steps

Download redis-2.8.8.tar.gz use FTP to upload to the/opt directory of the Linux system.

1) Unzip

Enter the Linux system/opt directory, perform the following command to extract: TAR-ZXVF redis-2.8.8.tar.gz.

After decompression will be in the current directory more than redis-2.8.8 folder, for convenience, we renamed it: MV redis-2.8.8 Redis.

The directory structure of Redis after decompression is as follows:

2) Compiling and installing

Into the SRC directory under the Redis directory, execute the make command to compile Redis. When the landlord to execute the compile command, the compilation failed, reported "/bin/sh:cc:command not found" error. Originally is the landlord of Linux system Wood installed GCC, and Redis is C implementation, so need GCC to compile. After online search, found a post, according to the steps above to solve the landlord problem, here to express my thanks! The link to this post is attached below: http://xueliang1yi.blog.163.com/blog/static/1145570162012102114635764/, a friend who has encountered this problem can refer to it.

After you install GCC, perform the following command to complete the installation of Redis:

Make

Make test//check to see if there is a problem

Make install

After installation, several executables are generated in the SRC directory, respectively, mkreleasehdr.sh Redis-benchmark redis-check-aof redis-check-dump redis-cli Redis-sentinel Redis-server. Where Redis-server is the start of the Redis service, REDIS-CLI enters the Redis client.

3) configuration

There is a profile redis.conf below the root of the Redis, which allows basic configuration of Redis and configuration parameters to view the Redis configuration parameter description. The landlord at the beginning is simply to set the Daemonize parameter to Yes, the purpose is to set up the Redis service to open the background, so that the service will not occupy the current session.

4. Testing

  After the installation, we will test it.

First, for the sake of convenience, we move the executable command under SRC to the/usr/local/redis/bin/directory and execute the command: MV mkreleasehdr.sh Redis-benchmark redis-check-aof Redis-check-dump redis-cli Redis-sentinel Redis-server/usr/local/redis/bin, and then move the configuration file to the/usr/local/redis/etc/directory, Execute the command: MV redis.conf/usr/local/redis/etc/.

Enter the/usr/local/redis/bin/directory to execute the./redis-server/usr/local/redis/etc/redis.conf command to open the Redis service. Note: You need to specify a configuration file to enable the Redis service, or load the default profile if you do not specify a configuration file.

After opening we execute NETSTAT-TUNPL | The grep 6379 command to view 6379 port usage, if present, indicates that port 6379 has been redis-server occupied, indicating that the Redis service has successfully started.

Then execute the./redis-cli into the Redis client and perform a simple set, get operation to test it.

Well, this Redis has been successfully installed.

Third, Redis master-slave configuration

Redis's master-slave replication feature is very powerful, a master can have multiple slave, and a slave can have more than slave, so continue to form a powerful multi-level server cluster architecture. Below the landlord simple to do a bit of configuration.

1, the above installed a redis as master, and then use the VirtualBox virtual machine cloning function will just that Linux system clone a copy as slave, and modify its IP to 192.168.0.110.

2. Modify the Redis configuration file for slave:

slaveof 192.168.0.100 6379 (mapped to the primary server)

If Master sets the authentication password, you also need to configure Masterauth. Landlord's master Set the authentication password for admin, so configure Masterauth admin.

After configuring the Redis service to start slave, OK, master and slave configuration is complete. Test it below:

Execute the info command in master and slave to see the results as follows:

Master

Slave

Then execute set age 24 in master

Perform get age on slave to see if you can get 24 and if you can get the value then the configuration is successful.

Installation and configuration of Redis

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.