Redis cluster installation and configuration steps

Source: Internet
Author: User
Tags redis version redis cluster install redis

Operating Environment: CentOS 7 (Version number: 1503)

Redis version: 3.0.5

Reference Document: ①http://www.redis.cn/topics/cluster-tutorial.html

②http://www.linuxidc.com/linux/2015-08/121845.htm

Note: A Redis cluster requires at least 6 nodes, or six servers. If the number of servers is insufficient to establish multiple nodes on each server, such as 2 servers, 3 nodes are established on each server

First, to install Redis for all servers

1. Use the SSH tool to connect to the server and download and unzip the package.

cd/usr/local/

wget http://download.redis.io/releases/redis-3.0.5.tar.gz

TAR-ZXVF redis-3.0.5.tar.gz

2. Renaming a folder

MV redis-3.0.5 Redis

3. Compiling the installation

CD Redis

Make && make install

There may be an error in this case that results in compilation but (below)

MAKE[1]: Entering directory '/REDIS/SRC '
CC ADLIST.O
In file included from adlist.c:34:
Zmalloc.h:50:31:error:jemalloc/jemalloc.h:no such file or directory
Zmalloc.h:55:2: Error: #error "Newer version of Jemalloc required"
MAKE[1]: * * * [ADLIST.O] Error 1
MAKE[1]: Leaving directory '/REDIS/SRC '
Make: * * * [ALL] Error 2

Because the Jemalloc memory allocator is not installed, you can install Jemalloc or direct input makemalloc=libc && make install

Second, Configuration Node

Note: The following methods are per server single node configuration, if you need to configure multiple nodes on each server, you can create multiple folders under the cluster directory, folder name arbitrary, preferably using the node port number: 7000 7001 7002 Copy the redis.conf to each folder, with the same configuration steps as the single node, and note that 6379 needs to be replaced with the port number of the current node directory

1. Create a cluster folder

mkdir Cluster

2. Copy the configuration file

cp./redis.conf./cluster/

3. Modify the configuration file

cd./cluster/

Vim./redis.conf

Modify the following

Daemonize Yes//redis background run
Pidfile/var/run/redis_6379.pid//pidfile file corresponds to 6379
Port 6379//Ports 6379
cluster-enabled Yes//turn on cluster to remove comment #
Cluster-config-file nodes.conf//cluster configuration profile first start auto-generated
Cluster-node-timeout 5000//Request Timeout setting 5 seconds enough.
AppendOnly Yes//aof log on when needed to open, it will log each write operation logs

Bind native IP address//Do not use 127.0.0.1

Save exit

4. Modify firewall rules, open 6379 port, due to Redis's own mechanism, need to open the 10000+6379 port, or the final cluster communication error

Firewall-cmd--zone=public--add-port=6379/tcp–permanent

Firewall-cmd--zone=public--add-port=16379/tcp--permanent

Firewall-cmd--reload

5. Start the node

Redis-server./redis.conf

6. Test whether it is running properly

Ps–ef |grep Redis

The following can be displayed

If multi-node configuration, multiple processes are displayed

Third, Start the cluster function (only one server is configured)

Run/USR/LOCAL/REDIS/SRC/REDIS-TRIB.RB because this is a program written in Ruby, you need to install Ruby first.

Yum-yinstall Ruby Ruby-devel RubyGems rpm-build

Installing Redis from Ruby's GEM toolkit

Geminstall Redis

This command may cause a download error because of a link error, using the HTTP protocol instead of the HTTPS protocol, first modify the following command:

Gem Sources-r https://rubygems.org

Gem Sources-a http://rubygems.org

Then execute the Gem install Redis command.

Now it's time to execute redis-trib.rb.

Cd.. /src

./redis-trib.rbcreate--replicas 1 Native IP: Node port number ... (appended with all nodes on all servers, in the format IP address: node port number)

--replicas 1 means that each master node is automatically assigned a slave node if there are 6 nodes, the program will elect to generate 3 master (Master) 3 Slave (from) in accordance with a certain rule.

After execution Redis-trib will print out a desired configuration, no problem, you can enter Yes, Redis-trib will apply this configuration to the cluster, so that each node began to communicate with each other, and finally can get the following information:

[OK] All 16384 Slots Covered

This means that 16,384 slots in the cluster have at least one master node in process and the cluster is functioning normally.

If the waiting for the cluster to join appears .... Waited for no response, indicating a problem with the configuration process,

Redis cluster installation and configuration steps

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.