当前位置:网站首页>Redis cluster installation

Redis cluster installation

2022-07-07 22:37:00 51CTO

Here we are Centos7 Operating system redis Take as an example to install

Environmental preparation

Download address  http://download.redis.io/releases/redis-3.2.1.tar.gz

Redis The cluster is required to at least 6 Nodes , And it has to be 3 Above version
If it is a lower version, it may appear ruby In the case of low version

Redis Cluster installation _redis

Operation user

root

Start installation

  1. Pass the installation package through sftp Or client tools or rz Command and other methods to upload to /root Under the table of contents

  2. Execute the decompression command and extract to /usr/local Under the table of contents

    tar -zxvf redis-3.2.1.tar.gz -C /usr/local
    
           
    • 1.
  3. Enter the decompression directory and execute the compilation command ( The installation of the compilation environment will not be repeated here )

    make
    
           
    • 1.
  4. stay redis Execute the command to create 6 individual Redis The configuration file

    mkdir {6379,6380,6381,6382,6383,6384}
    
    touch {6379/redis.conf,6380/redis.conf,6381/redis.conf,6382/redis.conf,6383/redis.conf,6384/redis.conf}
    
           
    • 1.
    • 2.
    • 3.
  5. Configure the contents of the configuration file separately as ( The configuration files of different ports configure different ports )

    daemonize    yes                          //redis Background operation 
    pidfile  /var/run/redis_6379.pid
    port  6379
    cluster-enabled  yes                      // Open clusters    Put the notes # Get rid of 
    cluster-config-file  nodes_6379.conf      // Configuration of cluster    The configuration file is automatically generated for the first time 
    cluster-node-timeout  5000                // request timeout    Set up 5 Seconds is enough 
    appendonly  yes                           //aof Log on    Turn it on if you need it ,
    
           
    • 1.
    • 2.
    • 3.
    • 4.
    • 5.
    • 6.
    • 7.

    It will record a log every time it writes port and pidfile Need to follow Different increments of folders .

  6. Enter into redis Unzip directory , Execute the command to start each node

    ./src/redis-server /usr/local/redis-5.0.0/6379/redis.conf
    ./src/redis-server /usr/local/redis-5.0.0/6380/redis.conf
    ./src/redis-server /usr/local/redis-5.0.0/6381/redis.conf
    ./src/redis-server /usr/local/redis-5.0.0/6382/redis.conf
    ./src/redis-server /usr/local/redis-5.0.0/6383/redis.conf
    ./src/redis-server /usr/local/redis-5.0.0/6384/redis.conf
    
           
    • 1.
    • 2.
    • 3.
    • 4.
    • 5.
    • 6.
  7. Check each node redis process

    Redis Cluster installation _ client _02

  8. Create a cluster client

    ./src/redis-cli --cluster create 192.168.5.57:6379 192.168.5.57:6380 192.168.5.57:6381 192.168.5.57:6382 192.168.5.57:6383 192.168.5.57:6384 --cluster-replicas 1
    
           
    • 1.

    Redis Cluster installation _ The configuration file _03
    Redis Cluster installation _ client _04

    The above figure shows that the startup is successful , You can see three master Three stations slave !

  9. Shutting down the cluster is not repeated here , A little violence directly kills the process , For other ways, please refer to the link  https://my.oschina.net/ruoli/blog/2252393

原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207072135076403.html