Easy building redis cluster

Time:2020-2-13

Outline:

  • Redis3.0 cluster introduction

  • Redis3.0 cluster building

Redis cluster introduction

Well, it’s not bullshit. It’s very clear.

Redis cluster building

Download and unzip the redis installation package:

  • wget http://download.redis.io/rele…

  • tar zxf redis-3.2.9.tar.gz && cd redis-3.2.9

  • make
    Note: the following errors may be reported when making:
    make #error "Newer version of jemalloc required"
    Solution

  • make INSTALL PREFIX=/path/redis

Create redis cluster instance
Note: this time, the redis cluster is built on a single machine, so 7001-7006 continuous ports are used

  1. Copy redis.conf from the source package to / path / redis / bin/

  2. Move the / path / redis / bin directory to the home directory, and copy six new directories with the names of redis7001 – > redis7006

  3. Edit the following configuration items in the redis.conf file in the redis7001 – > redis7006 directory:

    ’61 lines’: bind 127.0.0.1//If it is a multi machine deployment, it can be bound to the specified machine IP address

    ’84 lines’: Port 7001//Change the listening port in the corresponding directory

    ‘721 line’: cluster enabled yes//Open redis cluster mode

  4. To facilitate maintenance, we write a redis startup script in the home directory, start.sh (don’t forget Chmod + X start. SH):

    cd ./redis7001
    ./redis-sever redis.conf
    cd ..
    cd ./redis7002
    ./redis-sever redis.conf
    cd ..
    cd ./redis7003
    ./redis-sever redis.conf
    cd ..
    cd ./redis7004
    ./redis-sever redis.conf
    cd ..
    cd ./redis7005
    ./redis-sever redis.conf
    cd ..
    cd ./redis7006
    ./redis-sever redis.conf
    cd ..

    Directory structure:
    Easy building redis cluster

  5. Execute start.sh

    Easy building redis cluster

  6. Create a cluster (we need to use the redis tool to help us implement it)
    Note: redis-trib.rb can be found in the SRC directory of the ‘make’ redis source code. CP it to the home directory

    ./redis-trib.rb create --replicas 1 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 127.0.0.1:7006

    Because the tool is written in ruby, components such as the ruby runtime environment are required as follows

    List of cluster dependent software:

    1. ruby

    2. ruby-devel

    3. rubygems

    4. rpm-build

    yum -y install ruby ruby-devel rubygems rpm-build
    
    gem install  redis --version 3.0.0
    

    Be careful:

    Gem install redis -- if version 3.0.0 fails, you need to modify the source of gem
         
    gem sources --remove https://rubygems.org/
    
    gem sources -a https://ruby.taobao.org/
  7. Next, you should see the figure below. Redis has divided the master-slave relationship of each node for us. Redis is asking us’ can we configure this? ‘Enter’ yes’

    Easy building redis cluster

  8. Final,jsut take a test.

    Easy building redis cluster

    Perfect!!

Recommended Today

[reading notes] calculation advertising (Part 3)

By logm This article was originally published at https://segmentfault.com/u/logm/articles and is not allowed to be reproduced~ If the mathematical formula in the article cannot be displayed correctly, please refer to: Tips for displaying the mathematical formula correctly This article isComputing advertising (Second Edition)Reading notes. This part introduces the key technology of online advertising, which is […]