123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #!/bin/bash
- #####################################################################
- # {{ ansible_managed }}
- #####################################################################
- {% set primary_node = cpredis_node_ips.split(',')[0]%}
- {% set other_nodes = cpredis_node_ips.split(',')[1:]%}
- #####################################################################
- # Data Information:
- #####################################################################
- # Primary Node: {{ primary_node }}
- # Other Nodes: {{ other_nodes | join(",") }}
- # Raft Instance Ports:
- {% for p in redis_ports -%}
- # - {{ p.port }}
- {% endfor %}
- #####################################################################
- # Raft Group Setups!!
- {% for p in redis_ports %}
- echo "Setting up Raft Groups - port {{ p.port }}"
- /usr/local/bin/redis-cli -h {{ primary_node }} -p {{ p.port }} raft.cluster init
- {% for node in other_nodes %}
- /usr/local/bin/redis-cli -h {{ node }} -p {{ p.port }} raft.cluster join {{ primary_node }}:{{ p.port }}
- {% endfor %}
- {% endfor %}
- #####################################################################
- # Sleep until raft cluster is created
- echo "Waiting for Raft to stabilize"
- sleep 10
- #####################################################################
- # Set up Shard Clusters
- {% for p in redis_ports %}
- echo "Setting up Shard Clusters - port {{ p.port }}"
- SHARDGROUP_CONFIG=$(/usr/local/bin/redis-cli -h {{ primary_node }} -p {{ p.port }} --raw RAFT.SHARDGROUP GET)
- # echo $SHARDGROUP_CONFIG
- {% for t in redis_ports %}
- {% if t.port != p.port %}
- /usr/local/bin/redis-cli -h {{ primary_node }} -p {{ t.port }} RAFT.SHARDGROUP ADD $SHARDGROUP_CONFIG
- {% endif %}
- {% endfor %}
- {% endfor %}
|