redis|Linux搭建多机Redis集群
三主三从
192.168.200.140:6379 | 192.168.200.170 :6310 |
192.168.200.150:6379 | 192.168.200.170 :6310 |
192.168.200.170:6379 | 192.168.200.170 :6310 |
二、修改主文件配置redis.conf一、首先自行安装搭建redis环境
# bind 127.0.0.1 -::1#注释掉指定访问的IP 修改为 bind 0.0.0.0
bind 0.0.0.0#表示任何机器都可以访问
protected-mode no#关闭本机保护(不需配置了bind ip)
daemonize yes #开启守护进程(后台启动)
appendonly yes#aof持久化
cluster-enabled yes#开启集群
cluster-config-file nodes-6379.conf#配置文件
cluster-node-timeout 15000#集群超时时间
三、创建从文件配置redis6380.conf(mkdir redis6380.conf )
include /usr/myredis/redis.conf#引入redis.conf文件
pidfile /var/run/redis_6380.pid#启动pid
port 6380#端口号
dbfilename dump6380.rdb#rdb持久化保存文件名
cluster-enabled yes#开启集群
cluster-config-file nodes-6380.conf#配置文件
cluster-node-timeout 15000#集群超时时间
【redis|Linux搭建多机Redis集群】四、启动redis服务
redis-server redis.conf
redis-server redis6379.conf
注:同上启动剩下两台服务器
五、启动集群
cd /usr/software/redis-6.2.1/src
redis-cli --cluster create --cluster-replicas 1 192.168.200.150:6379 192.168.200.150:6310 192.168.200.140:6379 192.168.200.140:6310 192.168.200.170:6379 192.168.200.170:6310
六、普通方式登录测试
1. redis-cli -c-p 6379#-c 采用集群策略连接,设置数据会自动切换到相应的写主机
2. cluster nodes#通过 cluster nodes 命令查看集群信息
测试成功
![redis|Linux搭建多机Redis集群](https://img.it610.com/image/info8/0d8d41b98c684cfcb3e9132d48685171.jpg)
文章图片
推荐阅读
- 六步搭建ES6语法环境
- Linux下面如何查看tomcat已经使用多少线程
- Beego打包部署到Linux
- Linux|109 个实用 shell 脚本
- springboot使用redis缓存
- linux定时任务contab
- 芯灵思SinlinxA33开发板Linux内核定时器编程
- (1)redis集群原理及搭建与使用(1)
- 桁架搭建有什么价值()
- VM|VM ware 的 harbor 私有仓库搭建 (Ubuntu16.04)