redis 集群配置

This commit is contained in:
Zhang Peng 2019-10-17 17:32:13 +08:00
parent 7d1ce36b6e
commit 68e2da1820
10 changed files with 184 additions and 3 deletions

View File

@ -0,0 +1,12 @@
port 6381
bind 0.0.0.0
daemonize yes
cluster-enabled yes
cluster-config-file /opt/redis/redis-5.0.4/cluster/6381/6381.conf
cluster-node-timeout 10000
appendonly yes
dir /opt/redis/redis-5.0.4/cluster/6381
pidfile /var/run/redis-cluster/redis-6381.pid
logfile /opt/redis/redis-5.0.4/cluster/6381/6381.log

View File

@ -0,0 +1,12 @@
port 6382
bind 0.0.0.0
daemonize yes
cluster-enabled yes
cluster-config-file /opt/redis/redis-5.0.4/cluster/6382/6382.conf
cluster-node-timeout 10000
appendonly yes
dir /opt/redis/redis-5.0.4/cluster/6382
pidfile /var/run/redis-cluster/redis-6382.pid
logfile /opt/redis/redis-5.0.4/cluster/6382/6382.log

View File

@ -0,0 +1,12 @@
port 6383
bind 0.0.0.0
daemonize yes
cluster-enabled yes
cluster-config-file /opt/redis/redis-5.0.4/cluster/6383/6383.conf
cluster-node-timeout 10000
appendonly yes
dir /opt/redis/redis-5.0.4/cluster/6383
pidfile /var/run/redis-cluster/redis-6383.pid
logfile /opt/redis/redis-5.0.4/cluster/6383/6383.log

View File

@ -0,0 +1,12 @@
port 6384
bind 0.0.0.0
daemonize yes
cluster-enabled yes
cluster-config-file /opt/redis/redis-5.0.4/cluster/6384/6384.conf
cluster-node-timeout 10000
appendonly yes
dir /opt/redis/redis-5.0.4/cluster/6384
pidfile /var/run/redis-cluster/redis-6384.pid
logfile /opt/redis/redis-5.0.4/cluster/6384/6384.log

View File

@ -0,0 +1,12 @@
port 6385
bind 0.0.0.0
daemonize yes
cluster-enabled yes
cluster-config-file /opt/redis/redis-5.0.4/cluster/6385/6385.conf
cluster-node-timeout 10000
appendonly yes
dir /opt/redis/redis-5.0.4/cluster/6385
pidfile /var/run/redis-cluster/redis-6385.pid
logfile /opt/redis/redis-5.0.4/cluster/6385/6385.log

View File

@ -0,0 +1,12 @@
port 6386
bind 0.0.0.0
daemonize yes
cluster-enabled yes
cluster-config-file /opt/redis/redis-5.0.4/cluster/6386/6386.conf
cluster-node-timeout 10000
appendonly yes
dir /opt/redis/redis-5.0.4/cluster/6386
pidfile /var/run/redis-cluster/redis-6386.pid
logfile /opt/redis/redis-5.0.4/cluster/6386/6386.log

View File

@ -0,0 +1,7 @@
/opt/redis/redis-5.0.4/src/redis-server /opt/redis/redis-5.0.4/cluster/6381/redis.conf
/opt/redis/redis-5.0.4/src/redis-server /opt/redis/redis-5.0.4/cluster/6382/redis.conf
/opt/redis/redis-5.0.4/src/redis-server /opt/redis/redis-5.0.4/cluster/6383/redis.conf
/opt/redis/redis-5.0.4/src/redis-server /opt/redis/redis-5.0.4/cluster/6384/redis.conf
/opt/redis/redis-5.0.4/src/redis-server /opt/redis/redis-5.0.4/cluster/6385/redis.conf
/opt/redis/redis-5.0.4/src/redis-server /opt/redis/redis-5.0.4/cluster/6386/redis.conf

View File

@ -0,0 +1,102 @@
#!/bin/bash
# Settings
PORT=6380
TIMEOUT=2000
NODES=6
REPLICAS=1
# You may want to put the above config parameters into config.sh in order to
# override the defaults without modifying this script.
if [ -a config.sh ]
then
source "config.sh"
fi
# Computed vars
ENDPORT=$((PORT+NODES))
if [ "$1" == "start" ]
then
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
echo "Starting $PORT"
/opt/redis/redis-5.0.4/src/redis-server /opt/redis/redis-5.0.4/cluster/${PORT}/redis.conf
done
exit 0
fi
if [ "$1" == "create" ]
then
HOSTS=""
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
HOSTS="$HOSTS 127.0.0.1:$PORT"
done
/opt/redis/redis-5.0.4/src/redis-cli --cluster create $HOSTS --cluster-replicas $REPLICAS
exit 0
fi
if [ "$1" == "stop" ]
then
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
echo "Stopping $PORT"
/opt/redis/redis-5.0.4/src/redis-cli -p $PORT shutdown nosave
done
exit 0
fi
if [ "$1" == "watch" ]
then
PORT=$((PORT+1))
while [ 1 ]; do
clear
date
/opt/redis/redis-5.0.4/src/redis-cli -p $PORT cluster nodes | head -30
sleep 1
done
exit 0
fi
if [ "$1" == "tail" ]
then
INSTANCE=$2
PORT=$((PORT+INSTANCE))
tail -f ${PORT}.log
exit 0
fi
if [ "$1" == "call" ]
then
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
/opt/redis/redis-5.0.4/src/redis-cli -p $PORT $2 $3 $4 $5 $6 $7 $8 $9
done
exit 0
fi
if [ "$1" == "clean" ]
then
rm -rf *.log
rm -rf appendonly*.aof
rm -rf dump*.rdb
rm -rf nodes*.conf
exit 0
fi
if [ "$1" == "clean-logs" ]
then
rm -rf *.log
exit 0
fi
echo "Usage: $0 [start|create|stop|watch|tail|clean]"
echo "start -- Launch Redis Cluster instances."
echo "create -- Create a cluster using redis-cli --cluster create."
echo "stop -- Stop Redis Cluster instances."
echo "watch -- Show CLUSTER NODES output (first 30 lines) of first node."
echo "tail <id> -- Run tail -f of instance at base port + ID."
echo "clean -- Remove all instances data, logs, configs."
echo "clean-logs -- Remove just instances logs."

View File

@ -1,4 +1,4 @@
<div align="center"><img width="100px" src="http://dunwu.test.upcdn.net/cs/others/zp.png"/></div>
<div align="center"><img width="100px" src="http://dunwu.test.upcdn.net/common/logo/zp.png"/></div>
# Linux Tutorial

View File

@ -9,7 +9,7 @@
name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<link rel="icon" href="http://dunwu.test.upcdn.net/images/others/zp_50_50.png" type="image/x-icon" />
<link rel="icon" href="http://dunwu.test.upcdn.net/common/logo/zp_50_50.png" type="image/x-icon" />
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css" title="vue" />
<style>
h1 + ul {
@ -216,7 +216,7 @@
window.$docsify = {
name: "Linux Tutorial",
repo: "https://github.com/dunwu/linux-tutorial",
logo: "http://dunwu.test.upcdn.net/images/others/zp_100_100.png",
logo: "http://dunwu.test.upcdn.net/common/logo/zp_100_100.png",
auto2top: true,
coverpage: "coverpage.md",
maxLevel: 4,