Redis 集群可用性测试

Redis 集群可用性测试

脚本内容

#!/bin/bash

redisHost=192.168.8.119
redisPorts="7001 7002 7003 7004 7005 7006"
redisPass="123456"

	echo "### Set Key Test All Node"
	echo ""
for port in ${redisPorts}
do
	set_info=$(redis-cli -a ${redisPass} -h ${redisHost} -p ${port} -c set test_key${port} test_value${port} 2>/dev/null)
	
	if [[ ${set_info} == 'OK' ]]; then
		echo "node ${port} set OK"
	else
		
		echo "node ${port} set ERROR !!!"
		echo ${set_info}
	fi
done
	echo ""
	echo "### Set Key Test All Node"
	echo ""
for port in ${redisPorts}
do
        get_info=$(redis-cli -a ${redisPass} -h ${redisHost} -p ${port} -c get test_key${port} 2>/dev/null)
	if [[ ${get_info} == test_value${port} ]]; then
                echo "node ${port} get OK"
        else
                echo "node ${port} get ERROR !!!"
                echo ${get_info}
        fi
done
	echo ""
	echo "### Get Keys Count"
	echo ""
	get_keys_count=$(redis-cli -a ${redisPass} -h ${redisHost} -p ${port} -c dbsize 2>/dev/null | awk -F ' ' '{print $1}')
	echo "Keys Count is: ${get_keys_count}"

查看 119 redis 状态

手动关闭 node1 7001

[dev@hessian02 ~]$ ps -ef | grep redis
dev       4478     1  1 9月10 ?       02:06:15 ../src/redis-server *:7002 [cluster]
dev       4480     1  1 9月10 ?       02:02:41 ../src/redis-server *:7003 [cluster]
dev       4482     1  1 9月10 ?       01:31:04 ../src/redis-server *:7004 [cluster]
dev       4484     1  1 9月10 ?       01:34:17 ../src/redis-server *:7005 [cluster]
dev       4486     1  1 9月10 ?       01:31:47 ../src/redis-server *:7006 [cluster]

通过脚本检查 119 redis 状态

set 值失败 ++ get 值失败

[root@node1 ~]# sh get_redis_status.sh 
### Set Key Test All Node

node 7001 set ERROR !!!

node 7002 set OK
node 7003 set OK
node 7004 set OK
node 7005 set OK
node 7006 set OK

### Set Key Test All Node

node 7001 get ERROR !!!

node 7002 get OK
node 7003 get OK
node 7004 get OK
node 7005 get OK
node 7006 get OK

### Get Keys Count

Keys Count is: 316944

恢复 119 node 节点

[dev@hessian02 ~]$ ps -ef | grep redis | grep -v grep
dev       3088     1  0 19:28 ?        00:00:00 /home/data/v1.6/redis/src/redis-server *:7001 [cluster]
dev       4478     1  1 9月10 ?       02:06:18 ../src/redis-server *:7002 [cluster]
dev       4480     1  1 9月10 ?       02:02:44 ../src/redis-server *:7003 [cluster]
dev       4482     1  1 9月10 ?       01:31:07 ../src/redis-server *:7004 [cluster]
dev       4484     1  1 9月10 ?       01:34:20 ../src/redis-server *:7005 [cluster]
dev       4486     1  1 9月10 ?       01:31:51 ../src/redis-server *:7006 [cluster]

再次查看集群状态

[root@node1 ~]# sh get_redis_status.sh 
### Set Key Test All Node

node 7001 set OK
node 7002 set OK
node 7003 set OK
node 7004 set OK
node 7005 set OK
node 7006 set OK

### Set Key Test All Node

node 7001 get OK
node 7002 get OK
node 7003 get OK
node 7004 get OK
node 7005 get OK
node 7006 get OK

### Get Keys Count

Keys Count is: 316944
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值