From 68e2da182071b3bdc922961bf49860275fc77c51 Mon Sep 17 00:00:00 2001 From: Zhang Peng Date: Thu, 17 Oct 2019 17:32:13 +0800 Subject: [PATCH] =?UTF-8?q?redis=20=E9=9B=86=E7=BE=A4=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../soft/config/redis-cluster/6381/redis.conf | 12 +++ .../soft/config/redis-cluster/6382/redis.conf | 12 +++ .../soft/config/redis-cluster/6383/redis.conf | 12 +++ .../soft/config/redis-cluster/6384/redis.conf | 12 +++ .../soft/config/redis-cluster/6385/redis.conf | 12 +++ .../soft/config/redis-cluster/6386/redis.conf | 12 +++ codes/linux/soft/config/redis-cluster/boot.sh | 7 ++ .../soft/config/redis-cluster/create-cluster | 102 ++++++++++++++++++ docs/coverpage.md | 2 +- docs/index.html | 4 +- 10 files changed, 184 insertions(+), 3 deletions(-) create mode 100644 codes/linux/soft/config/redis-cluster/6381/redis.conf create mode 100644 codes/linux/soft/config/redis-cluster/6382/redis.conf create mode 100644 codes/linux/soft/config/redis-cluster/6383/redis.conf create mode 100644 codes/linux/soft/config/redis-cluster/6384/redis.conf create mode 100644 codes/linux/soft/config/redis-cluster/6385/redis.conf create mode 100644 codes/linux/soft/config/redis-cluster/6386/redis.conf create mode 100644 codes/linux/soft/config/redis-cluster/boot.sh create mode 100644 codes/linux/soft/config/redis-cluster/create-cluster diff --git a/codes/linux/soft/config/redis-cluster/6381/redis.conf b/codes/linux/soft/config/redis-cluster/6381/redis.conf new file mode 100644 index 0000000..f0315be --- /dev/null +++ b/codes/linux/soft/config/redis-cluster/6381/redis.conf @@ -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 \ No newline at end of file diff --git a/codes/linux/soft/config/redis-cluster/6382/redis.conf b/codes/linux/soft/config/redis-cluster/6382/redis.conf new file mode 100644 index 0000000..6ca21ea --- /dev/null +++ b/codes/linux/soft/config/redis-cluster/6382/redis.conf @@ -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 \ No newline at end of file diff --git a/codes/linux/soft/config/redis-cluster/6383/redis.conf b/codes/linux/soft/config/redis-cluster/6383/redis.conf new file mode 100644 index 0000000..509f9d3 --- /dev/null +++ b/codes/linux/soft/config/redis-cluster/6383/redis.conf @@ -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 diff --git a/codes/linux/soft/config/redis-cluster/6384/redis.conf b/codes/linux/soft/config/redis-cluster/6384/redis.conf new file mode 100644 index 0000000..10a64db --- /dev/null +++ b/codes/linux/soft/config/redis-cluster/6384/redis.conf @@ -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 diff --git a/codes/linux/soft/config/redis-cluster/6385/redis.conf b/codes/linux/soft/config/redis-cluster/6385/redis.conf new file mode 100644 index 0000000..33b66a6 --- /dev/null +++ b/codes/linux/soft/config/redis-cluster/6385/redis.conf @@ -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 diff --git a/codes/linux/soft/config/redis-cluster/6386/redis.conf b/codes/linux/soft/config/redis-cluster/6386/redis.conf new file mode 100644 index 0000000..21af861 --- /dev/null +++ b/codes/linux/soft/config/redis-cluster/6386/redis.conf @@ -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 diff --git a/codes/linux/soft/config/redis-cluster/boot.sh b/codes/linux/soft/config/redis-cluster/boot.sh new file mode 100644 index 0000000..731bd46 --- /dev/null +++ b/codes/linux/soft/config/redis-cluster/boot.sh @@ -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 diff --git a/codes/linux/soft/config/redis-cluster/create-cluster b/codes/linux/soft/config/redis-cluster/create-cluster new file mode 100644 index 0000000..3de8152 --- /dev/null +++ b/codes/linux/soft/config/redis-cluster/create-cluster @@ -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 -- Run tail -f of instance at base port + ID." +echo "clean -- Remove all instances data, logs, configs." +echo "clean-logs -- Remove just instances logs." diff --git a/docs/coverpage.md b/docs/coverpage.md index 8f6b1e3..881c708 100644 --- a/docs/coverpage.md +++ b/docs/coverpage.md @@ -1,4 +1,4 @@ -
+
# Linux Tutorial diff --git a/docs/index.html b/docs/index.html index b72a9db..c50503e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -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" /> - +