Redis - Master Node Cluster 구성하기

     

     

     

    이번 포스팅에서는 Cluster Master Node 구성 방법에 대해서 알아보도록 하겠습니다.

     

     

     

     

       Redis 이전글

     

     

     

     

    https://server-talk.tistory.com/471 - Redis - In-Memory - 알아보기​

     

     

    https://server-talk.tistory.com/472 - Redis - 서버 설치 및 기본설정 알아보기

     

     

    https://server-talk.tistory.com/473 - Redis - Redis-cli 기본 사용법

     

     

    https://server-talk.tistory.com/474 - Redis - Redis Desktop Manager Tool

     

     

    https://server-talk.tistory.com/475 - phpredis 설치 알아보기

     

     

    https://server-talk.tistory.com/502 - Cluster 알아보기

     

     

     

     

       Redis - Cluster Master Node 구성정보

     

     

     

     

     

     

     

     

       Redis - Cluster Master Node 설정하기

     

     

     

     

    1. Redis - Clustering 폴더 생성

     

    mkdir redis-cluster
    cd redis-cluster

     

     

     

     

    2. Redis - Cluster Master Node 설정파일 생성

     

    # cp /etc/redis/redis.conf 7000-cluster.conf
    
    # cp /etc/redis/redis.conf 7100-cluster.conf
    
    # cp /etc/redis/redis.conf 7200-cluster.conf

     

     

     

     

    3. Redis - Cluster Master Node1, Node2, Node3 설정파일 수정

     

    3-1) Cluster - Master Node1

     

    vi 7000-cluster.conf
    
    port 7000
    daemonize yes
    cluster-enabled yes 
    cluster-config-file nodes-7000.conf 
    cluster-node-timeout 3000 
    appendonly yes 
    appendfilename appendonly_7000.aof 
    pidfile /var/run/redis_7000.pid
    logfile logs/redis_7000.log

     

     

     

    3-2) Cluster - Master Node2

     

    vi 7100-cluster.conf
    
    port 7100
    daemonize yes
    cluster-enabled yes 
    cluster-config-file nodes-7100.conf 
    cluster-node-timeout 3000 
    appendonly yes 
    appendfilename appendonly_7100.aof 
    pidfile /var/run/redis_7100.pid
    logfile logs/redis_7100.log

     

     

     

    3-3) Cluster - Master Node3

     

    vi 7200-cluster.conf
    
    port 7200
    daemonize yes
    cluster-enabled yes 
    cluster-config-file nodes-7200.conf 
    cluster-node-timeout 3000 
    appendonly yes 
    appendfilename appendonly_7200.aof 
    pidfile /var/run/redis_7200.pid
    logfile logs/redis_7200.log

     

     

     

     

    4. Redis - Master Node1, Node2, Node3  - Cluster 실행

     

    # redis-server 7000-cluster.conf
    
    # redis-server 7100-cluster.conf
    
    # redis-server 7200-cluster.conf

     

     

     

     

    5. Redis - Cluster 프로세스 확인

     

    # ps -ef | grep redis
    root      197823       1  0 18:20 ?        00:00:05 redis-server 0.0.0.0:7000 [cluster]
    root      197830       1  0 18:21 ?        00:00:05 redis-server 0.0.0.0:7100 [cluster]
    root      197837       1  0 18:21 ?        00:00:05 redis-server 0.0.0.0:7200 [cluster]
    root      197902  197296  0 19:01 pts/1    00:00:00 grep --color=auto redis

     

     

     

     

    6. Redis - Cluster Master Node 생성하기

     

    사용법 : redis-cli --cluster create [Master Node1 IP]:[Master Node1 Port] [Master Node1 IP]:[Master Node2 Port] [Master Node1 IP]:[Master Node3 Port]

     

    # redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7100 127.0.0.1:7200

     

    Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
    >>> Performing hash slots allocation on 3 nodes...
    Master[0] -> Slots 0 - 5460
    Master[1] -> Slots 5461 - 10922
    Master[2] -> Slots 10923 - 16383
    M: 5c31b49ad1e4f561c0f371e1c59754da0d018e01 127.0.0.1:7000
       slots:[0-5460] (5461 slots) master
    M: 83250ff969fd5a00a950d826257f03f438aec567 127.0.0.1:7100
       slots:[5461-10922] (5462 slots) master
    M: 95078d7e470c125676dcdddc485bc5a6680286c2 127.0.0.1:7200
       slots:[10923-16383] (5461 slots) master
    Can I set the above configuration? (type 'yes' to accept): yes
    >>> Nodes configuration updated
    >>> Assign a different config epoch to each node
    >>> Sending CLUSTER MEET messages to join the cluster
    Waiting for the cluster to join
    ..
    >>> Performing Cluster Check (using node 127.0.0.1:7000)
    M: 5c31b49ad1e4f561c0f371e1c59754da0d018e01 127.0.0.1:7000
       slots:[0-5460] (5461 slots) master
    M: 83250ff969fd5a00a950d826257f03f438aec567 127.0.0.1:7100
       slots:[5461-10922] (5462 slots) master
    M: 95078d7e470c125676dcdddc485bc5a6680286c2 127.0.0.1:7200
       slots:[10923-16383] (5461 slots) master
    [OK] All nodes agree about slots configuration.
    >>> Check for open slots...
    >>> Check slots coverage...
    [OK] All 16384 slots covered.

     

    Cluster 생성시 위 내용이 출력이 됩니다.

    Posted by 서버이야기