linux redis-cluster ipv6方式

配置文件,具体字段的含义,可以参考其他文档。

1.单个文件的配置信息   redis_36380.conf

requirepass Paas_2024

port 36380

tcp-backlog 511

timeout 0

tcp-keepalive 300

daemonize yes

supervised no

pidfile /data/paas/apps/aicache-redis/redis_36380.pid

loglevel notice

logfile "/data/paas/apps/aicache-redis/logs/redis36380.log"

databases 16


dbfilename dump.rdb

dir /data/paas/apps/aicache-redis/data


appendonly no

appendfilename "appendonly36380.aof"

appendfsync everysec


cluster-enabled yes
cluster-config-file nodes36380.conf
cluster-node-timeout 20000
cluster-announce-ip 2409:806a:5af0:2000::f8ac
cluster-announce-port 36380
cluster-announce-bus-port 46380
masterauth Paas_2024

这会看配置,才发现,timeout的值设置错了,想设置成20000的,结果,设置为了0。

 2.其余配置文件

将redis_36380.conf 复制6份,将对应端口都sed修改成对应的端口。

redis_36380.conf   -->ip1/ redis_36381.conf

redis_36380.conf   --> ip2/redis_36380.conf

redis_36380.conf   --> ip2/redis_36381.conf

redis_36380.conf   --> ip3/redis_36380.conf

redis_36380.conf   --> ip3/redis_36381.conf

3.各个redis都要启动

 cat start_redis.sh 
cd  /data/paas/apps/aicache-redis; bin/redis-server redis_36380.conf
echo "36380 start done"

cd  /data/paas/apps/aicache-redis36381; bin/redis-server redis_36381.conf
echo "36381 start done"

4.集群启动

# bin/redis-cli -a Paas_2024 --cluster create 2409:806a:5af0:2000::f8ab:36380 2409:806a:5af0:2000::f8ab:36381 2409:806a:5af0:2000::f8ac:36380 2409:806a:5af0:2000::f8ac:36381 2409:806a:5af0:2000::f8ad:36380 2409:806a:5af0:2000::f8ad:36381 --cluster-replicas 1
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 2409:806a:5af0:2000::f8ac:36381 to 2409:806a:5af0:2000::f8ab:36380
Adding replica 2409:806a:5af0:2000::f8ad:36381 to 2409:806a:5af0:2000::f8ac:36380
Adding replica 2409:806a:5af0:2000::f8ab:36381 to 2409:806a:5af0:2000::f8ad:36380
M: 1097bc8e8953c143a199aee52b337958ebad5e0f 2409:806a:5af0:2000::f8ab:36380
   slots:[0-5460] (5461 slots) master
S: cced91f4c571c5f104bec2031713b912fd47b27a 2409:806a:5af0:2000::f8ab:36381
   replicates 10009e5750acfb4fdfea12fa4a5237119715129a
M: be9bef007066c620a158666c15d10403d9435a9a 2409:806a:5af0:2000::f8ac:36380
   slots:[5461-10922] (5462 slots) master
S: 4576bd5d5ab4815a73b4efbe9dd4a3db19fcca79 2409:806a:5af0:2000::f8ac:36381
   replicates 1097bc8e8953c143a199aee52b337958ebad5e0f
M: 10009e5750acfb4fdfea12fa4a5237119715129a 2409:806a:5af0:2000::f8ad:36380
   slots:[10923-16383] (5461 slots) master
S: d2d28e829fc2813988e43ac263c51b6e0d238270 2409:806a:5af0:2000::f8ad:36381
   replicates be9bef007066c620a158666c15d10403d9435a9a
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join
......
>>> Performing Cluster Check (using node 2409:806a:5af0:2000::f8ab:36380)
M: 1097bc8e8953c143a199aee52b337958ebad5e0f 2409:806a:5af0:2000::f8ab:36380
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
M: 10009e5750acfb4fdfea12fa4a5237119715129a 2409:806a:5af0:2000::f8ad:36380
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
M: be9bef007066c620a158666c15d10403d9435a9a 2409:806a:5af0:2000::f8ac:36380
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
S: 4576bd5d5ab4815a73b4efbe9dd4a3db19fcca79 2409:806a:5af0:2000::f8ac:36381
   slots: (0 slots) slave
   replicates 1097bc8e8953c143a199aee52b337958ebad5e0f
S: cced91f4c571c5f104bec2031713b912fd47b27a 2409:806a:5af0:2000::f8ab:36381
   slots: (0 slots) slave
   replicates 10009e5750acfb4fdfea12fa4a5237119715129a
S: d2d28e829fc2813988e43ac263c51b6e0d238270 2409:806a:5af0:2000::f8ad:36381
   slots: (0 slots) slave
   replicates be9bef007066c620a158666c15d10403d9435a9a
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
[paas@vga2prdfootk8snew73 aicache-redis]$ bin/redis-cli -c -p 36380
127.0.0.1:36380> cluster info
NOAUTH Authentication required.
127.0.0.1:36380> auth Paas_2024
OK
127.0.0.1:36380> cluster info
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:5
cluster_stats_messages_ping_sent:62
cluster_stats_messages_pong_sent:75
cluster_stats_messages_meet_sent:4
cluster_stats_messages_sent:141
cluster_stats_messages_ping_received:73
cluster_stats_messages_pong_received:66
cluster_stats_messages_meet_received:2
cluster_stats_messages_received:141
127.0.0.1:36380> cluster nodes
be9bef007066c620a158666c15d10403d9435a9a 2409:806a:5af0:2000::f8ac:36380@46380 master - 0 1702190517490 3 connected 5461-10922
10009e5750acfb4fdfea12fa4a5237119715129a 2409:806a:5af0:2000::f8ad:36380@46380 myself,master - 0 1702190510000 5 connected 10923-16383
4576bd5d5ab4815a73b4efbe9dd4a3db19fcca79 2409:806a:5af0:2000::f8ac:36381@46381 slave 1097bc8e8953c143a199aee52b337958ebad5e0f 0 1702190513000 4 connected
d2d28e829fc2813988e43ac263c51b6e0d238270 2409:806a:5af0:2000::f8ad:36381@46381 slave be9bef007066c620a158666c15d10403d9435a9a 0 1702190514482 6 connected
cced91f4c571c5f104bec2031713b912fd47b27a 2409:806a:5af0:2000::f8ab:36381@46381 slave 10009e5750acfb4fdfea12fa4a5237119715129a 0 1702190516488 5 connected
1097bc8e8953c143a199aee52b337958ebad5e0f 2409:806a:5af0:2000::f8ab:36380@46380 master - 0 1702190515485 1 connected 0-5460
127.0.0.1:36380> 

正常情况下,redis的三主三从,在资源不足的情况下,每个主机上装2个节点。

# bin/redis-cli -p 36381 cluster info
NOAUTH Authentication required.
[paas@vga2prdfootk8snew73 aicache-redis]$ bin/redis-cli -a Paas_2024 -p 36381 cluster info
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:3
cluster_stats_messages_ping_sent:215
cluster_stats_messages_pong_sent:218
cluster_stats_messages_meet_sent:4
cluster_stats_messages_sent:437
cluster_stats_messages_ping_received:216
cluster_stats_messages_pong_received:219
cluster_stats_messages_meet_received:2
cluster_stats_messages_received:437

5.验证集群

bin/redis-cli -a Paas_2024 -p 36381 --cluster check 2409:806a:5af0:2000::f8ac:36380

# bin/redis-cli -a Paas_2024 -p 36381 --cluster check 2409:806a:5af0:2000::f8ac:36380
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
2409:806a:5af0:2000::f8ac:36380 (be9bef00...) -> 0 keys | 5462 slots | 1 slaves.
2409:806a:5af0:2000::f8ab:36380 (1097bc8e...) -> 0 keys | 5461 slots | 1 slaves.
2409:806a:5af0:2000::f8ad:36380 (10009e57...) -> 0 keys | 5461 slots | 1 slaves.
[OK] 0 keys in 3 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 2409:806a:5af0:2000::f8ac:36380)
M: be9bef007066c620a158666c15d10403d9435a9a 2409:806a:5af0:2000::f8ac:36380
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
M: 1097bc8e8953c143a199aee52b337958ebad5e0f 2409:806a:5af0:2000::f8ab:36380
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
S: 4576bd5d5ab4815a73b4efbe9dd4a3db19fcca79 2409:806a:5af0:2000::f8ac:36381
   slots: (0 slots) slave
   replicates 1097bc8e8953c143a199aee52b337958ebad5e0f
S: d2d28e829fc2813988e43ac263c51b6e0d238270 2409:806a:5af0:2000::f8ad:36381
   slots: (0 slots) slave
   replicates be9bef007066c620a158666c15d10403d9435a9a
M: 10009e5750acfb4fdfea12fa4a5237119715129a 2409:806a:5af0:2000::f8ad:36380
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
S: cced91f4c571c5f104bec2031713b912fd47b27a 2409:806a:5af0:2000::f8ab:36381
   slots: (0 slots) slave
   replicates 10009e5750acfb4fdfea12fa4a5237119715129a
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

 6.高可用测试

6.1此时,若f8ac:36380主节点宕机,看master是否会漂移

linux redis-cluster ipv6方式_第1张图片

6.2集群信息变更为

linux redis-cluster ipv6方式_第2张图片

6.3重新将节点启动

linux redis-cluster ipv6方式_第3张图片

6.4检查集群状态 

linux redis-cluster ipv6方式_第4张图片 

你可能感兴趣的:(Linux,bigData,linux,redis,运维)