redis 4.0.9 cluster + startup stop
os: centos7.4
redis:4.0.9
ruby:2.3.4
ip 规划
redis1 192.168.56.101
redis2 192.168.56.102
用两台虚拟机模拟6个redis节点。
分别为
192.168.56.101 的 9001、9002、9003 端口,
192.168.56.102 的 9001、9002、9003 端口。
start redis cluster
# redis-server --help
Usage: ./redis-server [/path/to/redis.conf] [options]
./redis-server - (read config from stdin)
./redis-server -v or --version
./redis-server -h or --help
./redis-server --test-memory <megabytes>
Examples:
./redis-server (run the server with default conf)
./redis-server /etc/redis/6379.conf
./redis-server --port 7777
./redis-server --port 7777 --slaveof 127.0.0.1 8888
./redis-server /etc/myredis.conf --loglevel verbose
Sentinel mode:
./redis-server /etc/sentinel.conf --sentinel
# cd /usr/redis/redis-cluster-data/9001
# redis-server /usr/redis/redis-cluster-data/9001/redis.conf
# cd /usr/redis/redis-cluster-data/9002
# redis-server /usr/redis/redis-cluster-data/9002/redis.conf
# cd /usr/redis/redis-cluster-data/9003
# redis-server /usr/redis/redis-cluster-data/9003/redis.conf
或者写成一个shell脚本
stop redis cluster
# redis-cli -h 192.168.56.101 -p 9001 -c
192.168.56.101:9001> SHUTDOWN
或者 kill 进程
# ps -ef|grep -i redis
root 4059 1851 0 05:49 pts/0 00:00:00 grep --color=auto -i redis
root 11330 1 0 May18 ? 00:00:24 redis-server 192.168.56.101:9002 [cluster]
root 11340 1 0 May18 ? 00:00:24 redis-server 192.168.56.101:9003 [cluster]
root 11738 1 0 May18 ? 00:00:22 redis-server 192.168.56.101:9001 [cluster]
# kill 11330