-
Notifications
You must be signed in to change notification settings - Fork 219
/
install-redis-cluster.sh
executable file
·95 lines (72 loc) · 1.94 KB
/
install-redis-cluster.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
curuser=`whoami`
# 检测root用户
if [ "$curuser" = "root" ]; then
echo "OK! current user is: $curuser"
else
echo "Error: Please Use Super User, current user is : $curuser"
echo "Error: Exit with Err Code: 1"
exit 1;
fi
# 创建并进入相应目录
mkdir -p redis_all
cd redis_all/
# 下载; 如果下载不了可以采用其他方式
if [ ! -e ./redis-stable.tar.gz ] ; then
wget http://download.redis.io/redis-stable.tar.gz
else
echo "OK! No download required! File Exists: redis-stable.tar.gz"
fi
sleep 1;
# 解压前检查
if [ ! -e ./redis-stable.tar.gz ] ; then
echo "Error: File Download Fail: redis-stable.tar.gz"
echo "Error: Exit with Err Code: 2"
exit 2;
else
echo "OK! Download success! File exists: redis-stable.tar.gz"
fi
# 解压
if [ ! -e ./redis-stable/utils/create-cluster ] ; then
tar xzf redis-stable.tar.gz
else
echo "OK! No need to decompress! Dir exists: redis-stable"
fi
sleep 1;
# 编译前检查
if [ ! -e ./redis-stable/utils/create-cluster ] ; then
echo "Error: Dir Not exists: redis-stable"
echo "Error: Exit with Err Code: 3"
exit 3;
else
echo "OK! decompress success: redis-stable"
fi
# 编译; 要求gcc, 没有请先安装
echo "OK! Prepare To compile: make"
sleep 1;
cd redis-stable
# 编译
if [ ! -e ./src/redis-server ] ; then
make
else
echo "OK! No need to compile, File Exists: ./src/redis-server"
fi
# 编译后检查
if [ ! -e ./src/redis-server ] ; then
echo "Error: File Not exists: ./src/redis-server"
echo "Error: Exit with Err Code: 4"
exit 4;
else
echo "OK! compile success: ./src/redis-server"
fi
# 搭建集群
cd utils/create-cluster
# 查看帮助
./create-cluster
# 如果要修改端口号, 直接修改脚本 create-cluster 即可
# 注意: 如果需要内网其他机器访问, 需要关闭保护模式;
# 启动实例
./create-cluster start
# 创建集群, -f
./create-cluster create -f
# Linux 下查看端口号监听
lsof -iTCP -sTCP:LISTEN -n -P | grep TCP