Skip to content

Instantly share code, notes, and snippets.

@tyagiakhilesh
Last active March 27, 2022 11:53
Show Gist options
  • Select an option

  • Save tyagiakhilesh/9c11b4fe3295d3e1dd40d78b40047ee9 to your computer and use it in GitHub Desktop.

Select an option

Save tyagiakhilesh/9c11b4fe3295d3e1dd40d78b40047ee9 to your computer and use it in GitHub Desktop.

Revisions

  1. tyagiakhilesh revised this gist Mar 27, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions redis-cluster.md
    Original file line number Diff line number Diff line change
    @@ -59,6 +59,8 @@ Modify create-cluster scrip to provide proper hostname.
    /opt/redis-6.0.6/src/redis-cli --cluster call localhost:30006 CONFIG SET protected-mode no
    ```

    And if you want to avoid above 6 commands, then you can acutally set `PROTECTED_MODE=no` in `create-cluster` script. :D

    `./create-cluster create`

    That is all.
  2. tyagiakhilesh revised this gist Mar 22, 2022. 1 changed file with 32 additions and 1 deletion.
    33 changes: 32 additions & 1 deletion redis-cluster.md
    Original file line number Diff line number Diff line change
    @@ -32,4 +32,35 @@ Then finally join each instance to make a cluster.
    In cases where at times the cluster needs to be created again using these nodes and you see error like
    ```[ERR] Node 127.0.0.1:30078 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.```

    Then get inside each node and `flushall` and `cluster reset`. Do this. And try to create cluster again. See [this](https://stackoverflow.com/a/38872895/1229355) link.
    Then get inside each node and `flushall` and `cluster reset`. Do this. And try to create cluster again. See [this](https://stackoverflow.com/a/38872895/1229355) link.

    # One more way to do it

    Download the source code

    `curl -O http://download.redis.io/redis-stable.tar.gz`

    `make`

    `make install` ### Optional

    `cd utils/create-cluster`

    Modify create-cluster scrip to provide proper hostname.

    `./create-cluster start`

    ```
    /opt/redis-6.0.6/src/redis-cli --cluster call localhost:30001 CONFIG SET protected-mode no
    /opt/redis-6.0.6/src/redis-cli --cluster call localhost:30002 CONFIG SET protected-mode no
    /opt/redis-6.0.6/src/redis-cli --cluster call localhost:30003 CONFIG SET protected-mode no
    /opt/redis-6.0.6/src/redis-cli --cluster call localhost:30004 CONFIG SET protected-mode no
    /opt/redis-6.0.6/src/redis-cli --cluster call localhost:30005 CONFIG SET protected-mode no
    /opt/redis-6.0.6/src/redis-cli --cluster call localhost:30006 CONFIG SET protected-mode no
    ```

    `./create-cluster create`

    That is all.

    Redis doesn't support hostname. So be aware: https://github.com/redis/redis/issues/2410
  3. tyagiakhilesh created this gist Apr 8, 2020.
    35 changes: 35 additions & 0 deletions redis-cluster.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    To Create a redis cluster with redis5:
    - Download source code.
    - Compile it. `make`
    - cd <working/dir>
    - mkdir 7003 7004 7005
    - cp <redis/root/src/redis-server 7003/
    - cp <redis/root/src/redis-server 7004/
    - cp <redis/root/src/redis-server 7005/
    - cp <redis/root/src/redis-conf 7003/
    - cp <redis/root/src/redis-conf 7004/
    - cp <redis/root/src/redis-conf 7005/

    cd 7003

    Change content of redis.conf file; change port to match the directory name. For instance
    ```
    port 30078
    cluster-enabled yes
    cluster-config-file nodes.conf
    cluster-node-timeout 5000
    appendonly yes
    ```

    Then start each instance.

    `./redis-server ./redis-conf`

    Then finally join each instance to make a cluster.

    `<redit-root>/src/redis-cli --cluster create 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 --cluster-replicas 0`

    In cases where at times the cluster needs to be created again using these nodes and you see error like
    ```[ERR] Node 127.0.0.1:30078 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.```

    Then get inside each node and `flushall` and `cluster reset`. Do this. And try to create cluster again. See [this](https://stackoverflow.com/a/38872895/1229355) link.