该文档主要是针对RedisGraph高可用方案设计的功能测试,来说明方案是可实施是可行的。具体方案设计看前面的高可用方案设计文章
- 功能测试准备条件
- master、slave 两台服务器
- 172.25.0.3&主、172.25.0.4&从、172.168.1.250&VIP
- Keepalived v2.0.7
- 部署RedisGraph一主一从模式
- 测试目标
- 主节点宕机从节点接管
- 主节点回复作为新的从节点
- VIP在主从间切换
- 服务器资源规划
主要分享低代码、微服务、容器化、SAAS、系统架构方面的的内容,希望大家点赞,评论,关注。
- 主从模式设置
#从库设置
slaveof 172.25.0.3 6379
- 执行查看主节点信息
redis-cli -h 127.0.0.1 info replication
- 查看从节点信息
docker exec 543df118730d redis-cli -h 127.0.0.1 info replication
- keepalived设置
global_defs {
router_id redis-master
}
vrrp_script chk_redis {
script "/usr/local/keepalived/scripts/redis_check_0.sh 172.25.0.3 6379" #监控脚本
interval 2 #监控时间
timeout 2 #超时时间
fall 3
}
vrrp_instance redis {
state BACKUP
interface ens192
lvs_sync_daemon_interface ens192
virtual_router_id 202
priority 150 #权重值
nopreempt #nopreempt:设置不抢占,这里只能设置在state为backup的节点上,而且这个节点的优先级必须比另外节点的高
advert_int 1
virtual_ipaddress {
172.168.1.250 #VIP地址
}
track_script {
chk_redis
}
notify_master "/usr/local/keepalived/scripts/redis_master_0.sh 172.25.0.3 172.25.0.4 6379 6380"
notify_backup "/usr/local/keepalived/scripts/redis_backup_0.sh 172.25.0.3 172.25.0.4 6379 6380"
notify_fault /usr/local/keepalived/scripts/redis_fault_0.sh
notify_stop /usr/local/keepalived/scripts/redis_stop_0.sh
}
- 查看VIP信息
ip addr
- 模拟RedisGraph主节点宕机
docker-compose stop redisgraph-master
- 查看主节点IP信息,可以看到vip已经转移
- 查看从节点IP信息,已经接管vip
- 恢复RedisGraph主节点
docker-compose start redisgraph-master
- 查看RedisGraph主节点主从信息
- 模拟RedisGraph从节点宕机
docker-compose stop redisgraph-slave-one
- 查看从节点IP信息,可以看到VIP已经释放
- 查看主节点IP信息,已经接管VIP
- 模拟主节点keepalived宕机
systemctl stop keepalived.service
- 查看主节点IP信息,VIP已经释放
- 查看从节点IP信息,已经接管VIP
- 功能测试
- 添加
172.168.1.250:6379> GRAPH.QUERY MotoGP_0000001 "CREATE (:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}), (:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}), (:Rider {name:'Andrea Dovizioso'})-[:rides]->(:Team {name:'Ducati'})"
- 查询
172.168.1.250:6379> GRAPH.QUERY MotoGP "MATCH (r:Rider)-[:rides]->(t:Team {name:'Ducati'}) RETURN count(r)"
- 数据同步
- 查看主库数据
[root@bocloudv01 container]# docker exec -it 543df118730d redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> keys *
1) "MotoGP_0000007"
2) "MotoGP_0000002"
3) "MotoGP_0000003"
4) "MotoGP_0000008"
5) "MotoGP_0000005"
6) "MotoGP_0000004"
7) "MotoGP_0000001"
- 查看从库数据库
[root@bocloudv01 container]# docker exec -it 2a89ff201ace redis-cli -h 127.0.0.1 -p 6380
127.0.0.1:6380> keys *
1) "MotoGP_0000007"
2) "MotoGP_0000002"
3) "MotoGP_0000003"
4) "MotoGP_0000008"
5) "MotoGP_0000005"
6) "MotoGP_0000004"
7) "MotoGP_0000001"
主要分享低代码、微服务、容器化、SAAS、系统架构方面的的内容,希望大家点赞,评论,关注。
喜欢的朋友记得给个关注~
标签:MotoGP,查看,Redis,redis,keepalived,设计方案,172.25,节点 From: https://blog.51cto.com/sharepointchina/5785759