redis-分片集群-docker部署

主从介绍

分片集群介绍

部署集群

redis-cluster.yaml

1
2
3
4
5
6
7
8
9
10
# 运行容器
docker run --restart=always --name redis-node1 --net=host -v /data/reids-node1:/data -d redis:5.0.5 --cluster-enabled yes --cluster-config-file nodes-node-1.conf --appendonly yes --port 7001
docker run --restart=always --name redis-node2 --net=host -v /data/reids-node2:/data -d redis:5.0.5 --cluster-enabled yes --cluster-config-file nodes-node-2.conf --appendonly yes --port 7002
docker run --restart=always --name redis-node3 --net=host -v /data/reids-node3:/data -d redis:5.0.5 --cluster-enabled yes --cluster-config-file nodes-node-3.conf --appendonly yes --port 7003
docker run --restart=always --name redis-node4 --net=host -v /data/reids-node4:/data -d redis:5.0.5 --cluster-enabled yes --cluster-config-file nodes-node-4.conf --appendonly yes --port 7004
docker run --restart=always --name redis-node5 --net=host -v /data/reids-node5:/data -d redis:5.0.5 --cluster-enabled yes --cluster-config-file nodes-node-5.conf --appendonly yes --port 7005
docker run --restart=always --name redis-node6 --net=host -v /data/reids-node6:/data -d redis:5.0.5 --cluster-enabled yes --cluster-config-file nodes-node-6.conf --appendonly yes --port 7006

# 创建集群
redis-cli --cluster create 10.0.6.115:7001 10.0.6.115:7002 10.0.6.115:7003 10.0.6.115:7004 10.0.6.115:7005 10.0.6.115:7006 --cluster-replicas 1 --cluster-yes

predixy代理配置

predixy.conf

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
## Specify a name for this predixy service
## redis command INFO can get this
Name Predixy_001

## Default is 0.0.0.0:7617
Bind 0.0.0.0:6379

## Worker threads
WorkerThreads 4

## Memory limit, 0 means unlimited
## MaxMemory can change online by CONFIG SET MaxMemory xxx
MaxMemory 0

## Close the connection after a client is idle for N seconds (0 to disable)
## ClientTimeout can change online by CONFIG SET ClientTimeout N
## Default is 0
ClientTimeout 300

BufSize 2048

## Log file path
Log /data/predixy/logs/predixy.log
## LogRotate LogLevelSample
LogVerbSample 0
LogDebugSample 0
LogInfoSample 1000
LogNoticeSample 1
LogWarnSample 1
LogErrorSample 1

## SERVERS
Include auth.conf
Include cluster.conf

cluster.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
ClusterServerPool {
Password moxigame
MasterReadPriority 60
StaticSlaveReadPriority 50
DynamicSlaveReadPriority 50
RefreshInterval 1
ServerTimeout 1
ServerFailureLimit 10
ServerRetryTimeout 1
KeepAlive 120
Servers {
+ 192.168.40.100:7001
+ 192.168.40.100:7002
+ 192.168.40.100:7003
+ 192.168.40.100:7004
+ 192.168.40.100:7005
+ 192.168.40.100:7006
}
}

auth.conf

1
2
3
4
5
Authority {
Auth "moxigame" {
Mode admin
}
}

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!