Skip to content

Commit 68e2da1

Browse files
committed
redis 集群配置
1 parent 7d1ce36 commit 68e2da1

File tree

10 files changed

+184
-3
lines changed

10 files changed

+184
-3
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
port 6381
2+
bind 0.0.0.0
3+
daemonize yes
4+
5+
cluster-enabled yes
6+
cluster-config-file /opt/redis/redis-5.0.4/cluster/6381/6381.conf
7+
cluster-node-timeout 10000
8+
9+
appendonly yes
10+
dir /opt/redis/redis-5.0.4/cluster/6381
11+
pidfile /var/run/redis-cluster/redis-6381.pid
12+
logfile /opt/redis/redis-5.0.4/cluster/6381/6381.log
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
port 6382
2+
bind 0.0.0.0
3+
daemonize yes
4+
5+
cluster-enabled yes
6+
cluster-config-file /opt/redis/redis-5.0.4/cluster/6382/6382.conf
7+
cluster-node-timeout 10000
8+
9+
appendonly yes
10+
dir /opt/redis/redis-5.0.4/cluster/6382
11+
pidfile /var/run/redis-cluster/redis-6382.pid
12+
logfile /opt/redis/redis-5.0.4/cluster/6382/6382.log
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
port 6383
2+
bind 0.0.0.0
3+
daemonize yes
4+
5+
cluster-enabled yes
6+
cluster-config-file /opt/redis/redis-5.0.4/cluster/6383/6383.conf
7+
cluster-node-timeout 10000
8+
9+
appendonly yes
10+
dir /opt/redis/redis-5.0.4/cluster/6383
11+
pidfile /var/run/redis-cluster/redis-6383.pid
12+
logfile /opt/redis/redis-5.0.4/cluster/6383/6383.log
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
port 6384
2+
bind 0.0.0.0
3+
daemonize yes
4+
5+
cluster-enabled yes
6+
cluster-config-file /opt/redis/redis-5.0.4/cluster/6384/6384.conf
7+
cluster-node-timeout 10000
8+
9+
appendonly yes
10+
dir /opt/redis/redis-5.0.4/cluster/6384
11+
pidfile /var/run/redis-cluster/redis-6384.pid
12+
logfile /opt/redis/redis-5.0.4/cluster/6384/6384.log
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
port 6385
2+
bind 0.0.0.0
3+
daemonize yes
4+
5+
cluster-enabled yes
6+
cluster-config-file /opt/redis/redis-5.0.4/cluster/6385/6385.conf
7+
cluster-node-timeout 10000
8+
9+
appendonly yes
10+
dir /opt/redis/redis-5.0.4/cluster/6385
11+
pidfile /var/run/redis-cluster/redis-6385.pid
12+
logfile /opt/redis/redis-5.0.4/cluster/6385/6385.log
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
port 6386
2+
bind 0.0.0.0
3+
daemonize yes
4+
5+
cluster-enabled yes
6+
cluster-config-file /opt/redis/redis-5.0.4/cluster/6386/6386.conf
7+
cluster-node-timeout 10000
8+
9+
appendonly yes
10+
dir /opt/redis/redis-5.0.4/cluster/6386
11+
pidfile /var/run/redis-cluster/redis-6386.pid
12+
logfile /opt/redis/redis-5.0.4/cluster/6386/6386.log
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
/opt/redis/redis-5.0.4/src/redis-server /opt/redis/redis-5.0.4/cluster/6381/redis.conf
3+
/opt/redis/redis-5.0.4/src/redis-server /opt/redis/redis-5.0.4/cluster/6382/redis.conf
4+
/opt/redis/redis-5.0.4/src/redis-server /opt/redis/redis-5.0.4/cluster/6383/redis.conf
5+
/opt/redis/redis-5.0.4/src/redis-server /opt/redis/redis-5.0.4/cluster/6384/redis.conf
6+
/opt/redis/redis-5.0.4/src/redis-server /opt/redis/redis-5.0.4/cluster/6385/redis.conf
7+
/opt/redis/redis-5.0.4/src/redis-server /opt/redis/redis-5.0.4/cluster/6386/redis.conf
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/bash
2+
3+
# Settings
4+
PORT=6380
5+
TIMEOUT=2000
6+
NODES=6
7+
REPLICAS=1
8+
9+
# You may want to put the above config parameters into config.sh in order to
10+
# override the defaults without modifying this script.
11+
12+
if [ -a config.sh ]
13+
then
14+
source "config.sh"
15+
fi
16+
17+
# Computed vars
18+
ENDPORT=$((PORT+NODES))
19+
20+
if [ "$1" == "start" ]
21+
then
22+
while [ $((PORT < ENDPORT)) != "0" ]; do
23+
PORT=$((PORT+1))
24+
echo "Starting $PORT"
25+
/opt/redis/redis-5.0.4/src/redis-server /opt/redis/redis-5.0.4/cluster/${PORT}/redis.conf
26+
done
27+
exit 0
28+
fi
29+
30+
if [ "$1" == "create" ]
31+
then
32+
HOSTS=""
33+
while [ $((PORT < ENDPORT)) != "0" ]; do
34+
PORT=$((PORT+1))
35+
HOSTS="$HOSTS 127.0.0.1:$PORT"
36+
done
37+
/opt/redis/redis-5.0.4/src/redis-cli --cluster create $HOSTS --cluster-replicas $REPLICAS
38+
exit 0
39+
fi
40+
41+
if [ "$1" == "stop" ]
42+
then
43+
while [ $((PORT < ENDPORT)) != "0" ]; do
44+
PORT=$((PORT+1))
45+
echo "Stopping $PORT"
46+
/opt/redis/redis-5.0.4/src/redis-cli -p $PORT shutdown nosave
47+
done
48+
exit 0
49+
fi
50+
51+
if [ "$1" == "watch" ]
52+
then
53+
PORT=$((PORT+1))
54+
while [ 1 ]; do
55+
clear
56+
date
57+
/opt/redis/redis-5.0.4/src/redis-cli -p $PORT cluster nodes | head -30
58+
sleep 1
59+
done
60+
exit 0
61+
fi
62+
63+
if [ "$1" == "tail" ]
64+
then
65+
INSTANCE=$2
66+
PORT=$((PORT+INSTANCE))
67+
tail -f ${PORT}.log
68+
exit 0
69+
fi
70+
71+
if [ "$1" == "call" ]
72+
then
73+
while [ $((PORT < ENDPORT)) != "0" ]; do
74+
PORT=$((PORT+1))
75+
/opt/redis/redis-5.0.4/src/redis-cli -p $PORT $2 $3 $4 $5 $6 $7 $8 $9
76+
done
77+
exit 0
78+
fi
79+
80+
if [ "$1" == "clean" ]
81+
then
82+
rm -rf *.log
83+
rm -rf appendonly*.aof
84+
rm -rf dump*.rdb
85+
rm -rf nodes*.conf
86+
exit 0
87+
fi
88+
89+
if [ "$1" == "clean-logs" ]
90+
then
91+
rm -rf *.log
92+
exit 0
93+
fi
94+
95+
echo "Usage: $0 [start|create|stop|watch|tail|clean]"
96+
echo "start -- Launch Redis Cluster instances."
97+
echo "create -- Create a cluster using redis-cli --cluster create."
98+
echo "stop -- Stop Redis Cluster instances."
99+
echo "watch -- Show CLUSTER NODES output (first 30 lines) of first node."
100+
echo "tail <id> -- Run tail -f of instance at base port + ID."
101+
echo "clean -- Remove all instances data, logs, configs."
102+
echo "clean-logs -- Remove just instances logs."

docs/coverpage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div align="center"><img width="100px" src="http://dunwu.test.upcdn.net/cs/others/zp.png"/></div>
1+
<div align="center"><img width="100px" src="http://dunwu.test.upcdn.net/common/logo/zp.png"/></div>
22

33
# Linux Tutorial
44

docs/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
name="viewport"
1010
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
1111
/>
12-
<link rel="icon" href="http://dunwu.test.upcdn.net/images/others/zp_50_50.png" type="image/x-icon" />
12+
<link rel="icon" href="http://dunwu.test.upcdn.net/common/logo/zp_50_50.png" type="image/x-icon" />
1313
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css" title="vue" />
1414
<style>
1515
h1 + ul {
@@ -216,7 +216,7 @@
216216
window.$docsify = {
217217
name: "Linux Tutorial",
218218
repo: "https://github.com/dunwu/linux-tutorial",
219-
logo: "http://dunwu.test.upcdn.net/images/others/zp_100_100.png",
219+
logo: "http://dunwu.test.upcdn.net/common/logo/zp_100_100.png",
220220
auto2top: true,
221221
coverpage: "coverpage.md",
222222
maxLevel: 4,

0 commit comments

Comments
 (0)