acl/app/redis_tools/redis_builder
2022-01-28 12:28:21 +08:00
..
changes.txt Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
cluster.xml add a redis tool for redis cluster 2015-04-19 07:15:30 -07:00
main.cpp Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
Makefile add a redis tool for redis cluster 2015-04-19 07:15:30 -07:00
Makefile.in build samples ok on WSL ubuntu 2022-01-28 12:28:21 +08:00
nodes1.xml add some useful function to redis_builder tool 2015-04-25 09:11:10 -07:00
nodes2.xml add some useful function to redis_builder tool 2015-04-25 09:11:10 -07:00
nodes3.xml add some useful function to redis_builder tool 2015-04-25 09:11:10 -07:00
nodes4.xml add some useful function to redis_builder tool 2015-04-25 09:11:10 -07:00
ReadMe.md modify Readme.md for redis_builder 2015-04-25 09:47:37 -07:00
redis_builder_vc2012.sln add a redis tool for redis cluster 2015-04-19 07:15:30 -07:00
redis_builder_vc2012.vcxproj use MD compiling options for all vc projects 2020-08-06 15:42:37 +08:00
redis_builder_vc2012.vcxproj.filters make redis_builder more powerful; replace polarssl with new version 2016-04-12 20:11:15 +08:00
redis_builder_vc2015.sln compile acl on vc2015 successfully 2016-04-30 11:49:41 +08:00
redis_builder_vc2015.vcxproj use MD compiling options for all vc projects 2020-08-06 15:42:37 +08:00
redis_builder_vc2015.vcxproj.filters compile acl on vc2015 successfully 2016-04-30 11:49:41 +08:00
redis_builder.cpp Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_builder.h Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_cmdump.cpp Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_cmdump.h Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_commands.cpp Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_commands.h Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_commands.txt Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_migrate.cpp Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_migrate.h Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_monitor.cpp Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_monitor.h Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_reshard.cpp Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_reshard.h Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_status.cpp Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_status.h Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_util.cpp Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
redis_util.h Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
stdafx.cpp Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
stdafx.h Revert "All source code have been changed to use utf8 charset with BOM header!" 2019-07-28 10:31:56 +08:00
valgrind.sh add some useful function to redis_builder tool 2015-04-25 09:11:10 -07:00

A redis tool for redis cluster, which can help to build a new redis cluster, add one new redis node to the existing one or cluster, show the information of the redis cluster about nodes and slots. Below are the using method of the tool:

1) show help information:

./redis_build -h
usage: redis_builder.exe -h[help]
-s redis_addr[ip:port]
-a cmd[nodes|slots|create|add_node|del_node|node_id|reshard]
-N new_node[ip:port]
-S [add node as slave]
-f configure_file

for samples:
./redis_builder -s 127.0.0.1:6379 -a create -f cluster.xml
./redis_builder -s 127.0.0.1:6379 -a nodes
./redis_builder -s 127.0.0.1:6379 -a slots
./redis_builder -s 127.0.0.1:6379 -a del_node -I node_id
./redis_builder -s 127.0.0.1:6379 -a node_id
./redis_builder -s 127.0.0.1:6379 -a add_node -N 127.0.0.1:6380 -S
./redis_builder -s 127.0.0.1:6379 -a reshard

2) build a new redis cluster after all of the redis nodes started:

2.1) build cluster and the relationship between master and slave

was specified by the configuer file. ./redis_builder -a create -f cluster.xml the cluster.xml's content just like:

<?xml version="1.0"?>
<xml>
    <node addr = "192.168.136.172:16380">
        <node addr = "192.168.136.172:16381" />
        <node addr = "192.168.136.172:16382" />
    </node>
    <node addr = "192.168.136.172:16383">
        <node addr = "192.168.136.172:16384" />
        <node addr = "192.168.136.172:16385" />
    </node>
    <node addr = "192.168.136.172:16386">
        <node addr = "192.168.136.172:16387" />
        <node addr = "192.168.136.172:16388" />
    </node>
</xml>

The result maybe like as:

master: 192.168.136.172:16380
        slave: 192.168.136.172:16381
        slave: 192.168.136.172:16382
master: 192.168.136.172:16383
        slave: 192.168.136.172:16384
        slave: 192.168.136.172:16385
master: 192.168.136.172:16386
        slave: 192.168.136.172:16387
        slave: 192.168.136.172:16388

2.2) build cluster and the relationship between master and slave was specified

by the command args. ./redis_builder -a create -r 2 -f cluster.xml the cluster.xml's content just like:

<?xml version="1.0"?>
<xml>
    <node addr = "192.168.136.171:16380" />
    <node addr = "192.168.136.171:16381" />
    <node addr = "192.168.136.171:16382" />
    <node addr = "192.168.136.172:16383" />
    <node addr = "192.168.136.172:16384" />
    <node addr = "192.168.136.172:16385" />
    <node addr = "192.168.136.173:16386" />
    <node addr = "192.168.136.173:16387" />
    <node addr = "192.168.136.173:16388" />
</xml>

The redis_builder will create three master nodes that each master will have two slave nodes. The three master will be in different hosts, and each master's slave nodes will be in other host than its master. The redis nodes of the cluster maybe like as:

master: 192.168.136.171:16380
        slave: 192.168.136.172:16383
        slave: 192.168.136.173:16386
master: 192.168.136.172:16384
        slave: 192.168.136.173:16388
        slave: 192.168.136.171:16382
master: 192.168.136.173:16387
        slave: 192.168.136.172:16385
        slave: 192.168.136.171:16381

3) add a new slave redis node to the master node:

./redis_builder -s 127.0.0.1:6379 -a add_node -S -N 127.0.0.1:6380
'-s' specifys the existing master node,
'-S' specifys the new redis node added was as a slave node,
'-N' specify the new redis addr to be added
'-a' specify the cmd of this tool

4) compile this redis_builder tool

4.1) build the base three libs for redis_builder:

because redis_builder depends on lib_acl/lib_protocol/lib_acl_cpp, so you need to compile the lib_acl/lib_protocol/lib_acl_cpp first

$cd lib_acl; make
$cd lib_protocol; make
$cd lib_acl_cpp; make

4.2) compile redis_builder

$cd app/redis_tools/redis_builder; make

5) reference