## redis 5.0集群部署步骤
## 1. 下载源码编译
```
# wget http://download.redis.io/releases/redis-5.0.0.tar.gz
# tar xzf redis-5.0.0.tar.gz
# cd redis-5.0.0/
# make
```
编译源码报以下失败信息
```
cc: error: ../deps/hiredis/libhiredis.a: No such file or directory
cc: error: ../deps/lua/src/liblua.a: No such file or directory
cc: error: ../deps/jemalloc/lib/libjemalloc.a: No such file or directory
```
先进入deps目录编译依赖库
```
# cd deps/
# make hiredis jemalloc linenoise lua
# cd ..
# make
```
编译成功
## 2. 创建六个集群的配置文件
```
# mkdir cluster && cd cluster
# mkdir 7001 7002 7003 7004 7005 7006
```
分别将项目根目录的redis.conf的配置文件复制到上面六个目录下。
修改配置文件以下内容(其中 port 和 pidfile 需要随着 文件夹的不同调增):
```
port 7001 #端口
# bind 127.0.0.1
cluster-enabled yes #启用集群模式
cluster-config-file nodes-7001.conf
cluster-node-timeout 5000 #超时时间
appendonly yes
daemonize yes #后台运行
protected-mode no #非保护模式
pidfile /var/run/redis_7001.pid
```
## 3. 启动节点
```
./src/redis-server cluster/7001/redis.conf
./src/redis-server cluster/7002/redis.conf
./src/redis-server cluster/7003/redis.conf
./src/redis-server cluster/7004/redis.conf
./src/redis-server cluster/7005/redis.conf
./src/redis-server cluster/7006/redis.conf
```
## 启动集群
```
./src/redis-cli --cluster create 192.168.4.64:7001 192.168.4.64:7002 192.168.4.64:7003 192.168.4.64:7004 192.168.4.64:7005 192.168.4.64:7006 --cluster-replicas 1
```
输出:
```
>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 192.168.4.64:7004 to 192.168.4.64:7001
Adding replica 192.168.4.64:7005 to 192.168.4.64:7002
Adding replica 192.168.4.64:7006 to 192.168.4.64:7003
>>> Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: 18593987417ba8e6fc259bfd06f07b06f9a35cde 192.168.4.64:7001
slots:[0-5460] (5461 slots) master
M: 2d07d29e4dfc55148e52030365daf0f42def9aae 192.168.4.64:7002
slots:[5461-10922] (5462 slots) master
M: 29b9b7b226555116475027599e22b285503afe42 192.168.4.64:7003
slots:[10923-16383] (5461 slots) master
S: 4286d9bef7c523fd822340e1c265afe2a31bd804 192.168.4.64:7004
replicates 2d07d29e4dfc55148e52030365daf0f42def9aae
S: 64b9ddb34174ed8a17ee44b640c046f56a70bdca 192.168.4.64:7005
replicates 29b9b7b226555116475027599e22b285503afe42
S: 05defa184e44d771143a3272f57da38d4b06df03 192.168.4.64:7006
replicates 18593987417ba8e6fc259bfd06f07b06f9a35cde
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 192.168.4.64:7001)
M: 18593987417ba8e6fc259bfd06f07b06f9a35cde 192.168.4.64:7001
slots:[0-5460] (5461 slots) master
1 additional replica(s)
S: 05defa184e44d771143a3272f57da38d4b06df03 192.168.4.64:7006
slots: (0 slots) slave
replicates 18593987417ba8e6fc259bfd06f07b06f9a35cde
M: 2d07d29e4dfc55148e52030365daf0f42def9aae 192.168.4.64:7002
slots:[5461-10922] (5462 slots) master
1 additional replica(s)
M: 29b9b7b226555116475027599e22b285503afe42 192.168.4.64:7003
slots:[10923-16383] (5461 slots) master
1 additional replica(s)
S: 64b9ddb34174ed8a17ee44b640c046f56a70bdca 192.168.4.64:7005
slots: (0 slots) slave
replicates 29b9b7b226555116475027599e22b285503afe42
S: 4286d9bef7c523fd822340e1c265afe2a31bd804 192.168.4.64:7004
slots: (0 slots) slave
replicates 2d07d29e4dfc55148e52030365daf0f42def9aae
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
```
至此,redis集群部署成功
- 空白目录
- 算法
- 排序
- 冒泡排序
- 选择排序
- 插入排序
- 归并排序
- 快速排序
- 计数排序
- 桶排序
- 基数排序
- 希尔排序
- 堆排序
- 二分查找
- 最小堆
- 最小索引堆
- 平衡二叉树(AVL tree)
- bitmap位图
- 布隆过滤器
- hashmap
- topK
- 跳表
- LRU Cache
- kmp
- 最小堆和堆排序
- 最短路径
- C++
- 运行时类型判断RTTI
- C++反射
- 手动实现智能指针
- 序列化实现
- rpc实现
- std::forward
- 函数指针的妙用
- C/C++
- std::function
- 同步队列
- 线程池实现
- std::promise
- 深入理解虚函数
- extern "C" 关键字讲解
- 大端小端的区别
- 简历
- 简历1
- redis
- 数据结构和对象
- sds
- list
- zskiplist
- 腾讯云redis面试题总结
- redis集群部署
- LeetCode
- 目标
- go基础
- 算法快速入门
- 数据结构篇
- 二叉树
- 链表
- 栈和队列
- 二进制
- 基础算法篇
- 二分搜索
- 排序算法
- 动态规划
- 算法思维
- 递归思维
- 滑动窗口思想
- 二叉搜索树
- 回溯法
- 其他
- 剑指offer
- 笔记
- git代理加速
- Linux
- vim大法
- vscode远程不能跳转
- cmake
- 设计模式
- 单例模式
- 简单工厂模式
- 外观模式
- 适配器模式
- 工厂方法模式
- 抽象工厂模式
- 生成器模式
- 原型模式
- 中介者模式
- 观察者模式
- 访问者模式
- 命令模式
- 网络编程
- epoll reactor模式
- linux timerfd系列函数总结
- IO
- mapreduce
- 反射器
- leo通信库
- Mutex
- Condition
- thread
- raft
- 协程
- hook
- 定时器
- 别人的面试经验
- 面试题
- vector崩溃问题
- JAVA
- Linux java环境配置
- ucore
- lab1
- FreeNOS
- leveldb
- 刷题笔记
- 回文串
- 前缀树
- 字符串查找
- 查找两个字符串a,b中的最长公共子串
- 动态规划
- golang
- 顺序循环打印实现
- 数据结构
- rpc运用
- python
- 单例
- 深拷贝浅拷贝
- 链表
- python基础题
- mysql
- 事务
- Linux
- 共享内存
- 刷题记录
- 贪心算法
- 动态规划
- 面试
- 腾讯C++面试
- 微众面试JD
- 迅雷网络面试
- 学习网址
- rabbitMq
