Redis cluster construction and redislive monitoring deployment

Source: Internet
Author: User
Tags benchmark mkdir redis redis cluster install redis redis server

Redis cluster construction and monitoring environment

Realization of 3 Master 3 slave virtual machine standalone ip:

Cluster Basic building

Simple download

    • Passwget

    • Unziptar zxvf redis-4.0.10.tar.gz

    • Specify the installation path, switch root user execution make && make PREFIX=/usr/local/redis install , may appear insufficient permissions problem, sudo will also error, directly using ROOT to operate.

Installing the Build Tool

    • sudo apt-get update

    • sudo apt-get install gcc

    • sudo apt-get install make

    • sudo apt-get install tcl

Create a Redis Cluster folder

    • Because it is/usr, it is always done under root privileges

    • cd /usr/local/redis

    • mkdir cluster

    • cd cluster

    • mkdir 7000 7001 7002 7003 7004 7005

Modifying a configuration file

Copy the config file in Redis conf to six folders, and modify the following

# port number Port  7000  # background boot  daemonize Yes  # turn on cluster  cluster-enabled Yes  #集群节点配置文件  Cluster-config-file nodes-7000.conf  # Cluster Connection timeout time  cluster-node-timeout  # process PID file location  pidfile/ home/ubuntu/redis-4.0.10/pid/ working folder Dir "/home/ubuntu/redis-4.0.10/working" # Open aof  appendonly Yes  # aof file path  appendfilename "appendonly-7005.aof"  # rdb file path  dbfilename Dump-7000.rdb

The bind in the Redis configuration file specifies the NIC IP of the Redis server, which is the IP of the Redis server

Startup scripts

    • cd /home/ubuntu/redis-4.0.10/

    • touch easy operation, create scripts

    • Modify the startup script to

#!/bin/bashexport base_flod= "/usr/local/redis" {base_flod}/bin/redis-server/usr/local/redis/cluster/7000/ redis.conf/usr/local/redis/bin/redis-server/usr/local/redis/cluster/7001/redis.conf/usr/local/redis/bin/ redis-server/usr/local/redis/cluster/7002/redis.conf/usr/local/redis/bin/redis-server/usr/local/redis/cluster/ 7003/redis.conf/usr/local/redis/bin/redis-server/usr/local/redis/cluster/7004/redis.conf/usr/local/redis/bin/ REDIS-SERVER/USR/LOCAL/REDIS/CLUSTER/7005/REDIS.CONF#CD src#./redis-trib.rb Create--replicas 1

It is noted that in order to simplify the initial start-up, IP needs to be consistent with the bind attribute binding in the redis.conf configured by each node, and can be started by Ps-ef | grep redis command queries whether the corresponding thread is started

Cluster boot

    • The Affiliate program uses Ruby written, so to build the Rudy Environment, you need to install Rudbygem

    • sudo apt-get install ruby rubygems -y

    • Gem install Redis, run here will feel very slow, need to wait patiently, in the Redis installation directory, src folder redis-trib.rb

    • Run redis-trib.rb create --replicas 1 , check the configured information for errors, no direct Yes is available. [OK] All 16384 slots covered. Represents the success of the cluster start-up.

Node view, restart

View cluster Run Status: Use the command ./redis-trib.rb check to check the status of the cluster

Performance testing

Bring your own test tool Redis-benchmark

    • redis-benchmark -h -p 6379 -c 100 -n 100000100 concurrent connections, 100,000 requests, detects Redis server performance with host localhost port 6379.

    • redis-benchmark -h -p 6379 -q -d 100Test the performance of a packet that accesses a size of 100 bytes.

    • redis-benchmark -t set,lpush -n 100000 -qTest only the performance of certain operations.

    • redis-benchmark -n 100000 -q script load "‘set’,’foo’,’bar’)"Test only the performance of certain numeric accesses.

Cluster password settings

Cluster construction initially does not require a password, after the start of the completion, the first look at each node's configuration file has read and write permissions, if there is no read and write permissions, need to chmod modify read and write permissions, through

./redis-cli-c-P portconfig set Masterauth passwordconfig set Requirepass passwordconfig rewrite

Connect each node individually to set up
To restart the discovery connection is not on, modify the startup script 99 line, configure the startup script password to start
@r = => @info[:host], :port => @info[:port], :timeout => 60,:password => "yangfan@1995")

Code testing

/* Cluster Connection Test */@Testpublic void Testjediscluster () {    set

The relationship between master-slave mode, Sentinel, and cluster

    1. Master-Slave mode specifies a replication and persistence relationship, specifying the relationship between master and slave backups

    2. Sentinel: When the primary database encounters an exception interrupt service, developers can manually select a database to be upgraded to the primary database, so that the system can continue to provide services. Mainly in order to solve the master-slave replication manual Switch master-slave relationship detection Tool, can automatically switch master and slave.

    3. With Sentinels, each instance of Redis is also a full-volume storage, and each Redis storage is full of data, wasting memory and having a cask effect. In order to maximize the use of memory, you can use a cluster, which is distributed storage. That is, each Redis stores a different content, with a total of 16,384 slots. Each redis has some slot,hash_slot = CRC16 (key) mod 16384 find the corresponding slot, the key is the available key, if there is {} then take {} as the available key, or the entire key is available key cluster requires at least 3 master 3 from, and each instance uses a different configuration file , the master and slave configuration, the cluster will choose their own.

Monitoring deployment

Redislive Build Deployment

Run Environment deployment

    1. git clone
      Download Redislive, unzipunzip -o -d /home/ubuntu/

    2. Go to the SRC folder, copy the example file, edit

      "Redisservers": [    {    "server": "",    "port": 7000,    "password": "yangfan@1995"    },    //... Multiple listening], "Datastoretype": "Redis", "redisstatsserver"://Storage of Redis Listener interface {    "server": "",    "port": 6379}, " Sqlitestatsstore ": {    " path ":  "/home/ubuntu/redis-4.0.10/working/redislive.db "//file to be stored}}
    3. ubuntu@ubuntu:~/redis-4.0.10$ mkdir pid
      ubuntu@ubuntu:~/redis-4.0.10$ mkdir log
      ubuntu@ubuntu:~/redis-4.0.10$ mkdir working
      Save the Aof,rdb,node-config file.

    4. Redislive is divided into two parts, one of which is the monitoring script and the other part is the Web service, so it needs to be started separately. './


    1. Redis.clients.jedis.exceptions.JedisNoReachableClusterNodeException:No Reachable node in cluster Redis node's redis.conf bound IP is set to the specified Redis nodes IP, starts the cluster with the specified IP only, does not use

    2. Connect refuse turn off firewall

    3. No module named Redis

      • View Python location which Python

      • First backup sudo cp/usr/bin/python/usr/bin/python_cp

      • Remove sudo rm/usr/bin/python

      • is set to python3.5 by default, creating a link sudo ln-s/usr/bin/python3.5/usr/bin/python

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