centos7搭建redis集群
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7搭建redis集群相关的知识,希望对你有一定的参考价值。
- 下载:
https://redis.io/
- 解压:
tar -xzf redis-5.0.3.tar.gz
- 进入目录:
cd redis-5.0.3
- 编译安装:
make
- 创建配置文件夹:
mkdir -p /usr/local/redis/redis_1 mkdir -p /usr/local/redis/redis_2 mkdir -p /usr/local/redis/redis_3 mkdir -p /usr/local/redis/redis_4 mkdir -p /usr/local/redis/redis_5 mkdir -p /usr/local/redis/redis_6
- 创建配置文件:
vim /usr/local/redis/redis_1/redis.confport 7001 bind 172.20.10.12 requirepass 123456 daemonize yes pidfile /var/run/redis_1.pid cluster-enabled yes cluster-config-file nodes_1.conf cluster-node-timeout 10100 appendonly no
- 启动:
src/redis-server /usr/local/redis/redis_1/redis.conf src/redis-server /usr/local/redis/redis_2/redis.conf src/redis-server /usr/local/redis/redis_3/redis.conf src/redis-server /usr/local/redis/redis_4/redis.conf src/redis-server /usr/local/redis/redis_5/redis.conf src/redis-server /usr/local/redis/redis_6/redis.conf
- 初始化:
src/redis-cli --cluster create 172.20.10.12:7001 172.20.10.12:7002 172.20.10.12:7003 172.20.10.12:7004 172.20.10.12:7005 172.20.10.12:7006 -a 123456 --cluster-replicas 1
- 检测状态:
src/redis-cli --cluster check 172.20.10.12:7001 -a 123456
- 连接:
src/redis-cli -c -h 172.20.10.12 -p 7001 -a 123456
- 停止:
pkill redis
以上是关于centos7搭建redis集群的主要内容,如果未能解决你的问题,请参考以下文章