redis(二十二):Redis 集群(proxy 型)一
redis伪集群搭建
搭建环境是vmware虚拟机+ubuntu-14.04,以redis伪集群的方式搭建搭建,一共实现了6台机器集群的搭建,三个master节点和三个slave节点。
<pre name="code" class="cpp">#首先安装redis的集群管理需要ruby和zlib
sudo apt-get install zlib ruby
#以及安装和redis有关的ruby package
sudo gem install redis
#下载安装包,编译安装redis-3.0.
mkdir redis
wget http://download.redis.io/releases/redis-3.0.0.tar.gz
tar -zxvf redis-3.0..tar.gz
cd redis-3.0.
make & make test &make install
编译安装以后,运行redis-server如果打印出以下的结果就表示安装成功了。
<pre name="code" class="cpp">:C Oct ::12.324 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
:M Oct ::12.325 # You requested maxclients of requiring at least max file descriptors.
:M Oct ::12.325 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
:M Oct ::12.326 # Current maximum open files is . maxclients has been reduced to to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0. (/) bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port:
| `-._ `._ / _.-' | PID: 61702
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' :M Oct ::12.332 # Server started, Redis version 3.0.
:M Oct ::12.332 # WARNING overcommit_memory is set to ! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
:M Oct ::12.332 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
:M Oct ::12.333 # WARNING: The TCP backlog setting of cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of .
:M Oct ::12.333 * The server is now ready to accept connections on port
然后我们关闭掉已经打开的redis-server程序,开始伪集群的搭建。
首先在redis-3.0.0目录下创建cluster目录
<pre name="code" class="cpp">ubuntu@ubuntu-virtual-machine:~/redis-3.0.$ mkdir cluster
ubuntu@ubuntu-virtual-machine:~/redis-3.0.$ cd cluster
#创建node-.conf node-.conf node-.conf node-.conf node-.conf node-.conf
#这些分别是7000,,,,,7005六个节点的redis-server配置文件
#配置文件内容如下
ubuntu@ubuntu-virtual-machine:~/redis-3.0./cluster$ cat node-.conf
pidfile /home/ubuntu/redis-3.0./cluster/pid/node7000.pid
logfile "/home/ubuntu/redis-3.0.0/cluster/logs/node-7000.log"
dir /home/ubuntu/redis-3.0./cluster/data/node-
port
daemonize yes
cluster-enabled yes
cluster-config-file node-.conf
cluster-node-timeout
appendonly yes ubuntu@ubuntu-virtual-machine:~/redis-3.0./cluster$ cat node-.conf
pidfile /home/ubuntu/redis-3.0./cluster/pid/node7001.pid
logfile "/home/ubuntu/redis-3.0.0/cluster/logs/node-7001.log"
dir /home/ubuntu/redis-3.0./cluster/data/node-
port
daemonize yes
cluster-enabled yes
cluster-config-file node-.conf
cluster-node-timeout
appendonly yes ubuntu@ubuntu-virtual-machine:~/redis-3.0./cluster$ cat node-.conf
pidfile /home/ubuntu/redis-3.0./cluster/pid/node7002.pid
logfile "/home/ubuntu/redis-3.0.0/cluster/logs/node-7002.log"
dir /home/ubuntu/redis-3.0./cluster/data/node-
port
daemonize yes
cluster-enabled yes
cluster-config-file node-.conf
cluster-node-timeout
appendonly yes ubuntu@ubuntu-virtual-machine:~/redis-3.0./cluster$ cat node-.conf
pidfile /home/ubuntu/redis-3.0./cluster/pid/node7003.pid
logfile "/home/ubuntu/redis-3.0.0/cluster/logs/node-7003.log"
dir /home/ubuntu/redis-3.0./cluster/data/node-
port
daemonize yes
cluster-enabled yes
cluster-config-file node-.conf
cluster-node-timeout
appendonly yes ubuntu@ubuntu-virtual-machine:~/redis-3.0./cluster$ cat node-.conf
pidfile /home/ubuntu/redis-3.0./cluster/pid/node7004.pid
logfile "/home/ubuntu/redis-3.0.0/cluster/logs/node-7004.log"
dir /home/ubuntu/redis-3.0./cluster/data/node-
port
daemonize yes
cluster-enabled yes
cluster-config-file node-.conf
cluster-node-timeout
appendonly yes ubuntu@ubuntu-virtual-machine:~/redis-3.0./cluster$ cat node-.conf
pidfile /home/ubuntu/redis-3.0./cluster/pid/node7005.pid
logfile "/home/ubuntu/redis-3.0.0/cluster/logs/node-7005.log"
dir /home/ubuntu/redis-3.0./cluster/data/node-
port
daemonize yes
cluster-enabled yes
cluster-config-file node-.conf
cluster-node-timeout
appendonly yes
最后在cluster目录下创建log data文件夹,以及node-7000.log node-7001.log node-7002.log node-7003.log #node-7004.log node-7005.log等6哥log文件,最后cluster目录下的文件如下:
<pre name="code" class="cpp">ubuntu@ubuntu-virtual-machine:~/redis-3.0./cluster$ ls
data node-.conf node-.conf node-.conf node-.conf node-.conf node-.conf
logs node-.log node-.log node-.log node-.log node-.log node-.log
最后,配置文件都ok了,开始启动6个”单机”redis-server服务,启动命令如下:
<pre name="code" class="cpp">ubuntu@ubuntu-virtual-machine:~/redis-3.0.$ redis-server cluster/node-.conf
ubuntu@ubuntu-virtual-machine:~/redis-3.0.$ redis-server cluster/node-.conf
ubuntu@ubuntu-virtual-machine:~/redis-3.0.$ redis-server cluster/node-.conf
ubuntu@ubuntu-virtual-machine:~/redis-3.0.$ redis-server cluster/node-.conf
ubuntu@ubuntu-virtual-machine:~/redis-3.0.$ redis-server cluster/node-.conf
ubuntu@ubuntu-virtual-machine:~/redis-3.0.$ redis-server cluster/node-.conf
把每一台机器加入集群中
<pre name="code" class="cpp">ubuntu@ubuntu-virtual-machine:~/redis-3.0.$ ./src/redis-trib.rb create --replicas 192.168.39.153: 192.168.39.153: 192.168.39.153: 192.168.39.153: 192.168.39.153: 192.168.39.153:
打印出以下的结果,就代表集群启动成功了。
<pre name="code" class="cpp">: 192.168.39.153: 192.168.39.153:
>>> Creating cluster
Connecting to node 192.168.39.153:: OK
Connecting to node 192.168.39.153:: OK
Connecting to node 192.168.39.153:: OK
Connecting to node 192.168.39.153:: OK
Connecting to node 192.168.39.153:: OK
Connecting to node 192.168.39.153:: OK
>>> Performing hash slots allocation on nodes...
Using masters:
192.168.39.153:
192.168.39.153:
192.168.39.153:
Adding replica 192.168.39.153: to 192.168.39.153:
Adding replica 192.168.39.153: to 192.168.39.153:
Adding replica 192.168.39.153: to 192.168.39.153:
M: 57d0ccdc7dc98ab786c961e0979b8a8f135f60cd 192.168.39.153:
slots:- ( slots) master
M: adfbf48901b1e7e7e7e2fe0a1b87c86f57530ebd 192.168.39.153:
slots:- ( slots) master
M: 314cbd10bbc4c1339fb737575af41f04408c2087 192.168.39.153:
slots:- ( slots) master
S: fb2d1830a4b429fcb80da7edbbdacc50ed439d63 192.168.39.153:
replicates 57d0ccdc7dc98ab786c961e0979b8a8f135f60cd
S: 1384a16ccb208828d9634f49695556ae11ec57a7 192.168.39.153:
replicates adfbf48901b1e7e7e7e2fe0a1b87c86f57530ebd
S: 9d9350c96c50fe88621575047a6a07250a287b51 192.168.39.153:
replicates 314cbd10bbc4c1339fb737575af41f04408c2087
Can I set the above configuration? (type 'yes' to accept): yes#这里输入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.39.153:)
M: 57d0ccdc7dc98ab786c961e0979b8a8f135f60cd 192.168.39.153:
slots:- ( slots) master
M: adfbf48901b1e7e7e7e2fe0a1b87c86f57530ebd 192.168.39.153:
slots:- ( slots) master
M: 314cbd10bbc4c1339fb737575af41f04408c2087 192.168.39.153:
slots:- ( slots) master
M: fb2d1830a4b429fcb80da7edbbdacc50ed439d63 192.168.39.153:
slots: ( slots) master
replicates 57d0ccdc7dc98ab786c961e0979b8a8f135f60cd
M: 1384a16ccb208828d9634f49695556ae11ec57a7 192.168.39.153:
slots: ( slots) master
replicates adfbf48901b1e7e7e7e2fe0a1b87c86f57530ebd
M: 9d9350c96c50fe88621575047a6a07250a287b51 192.168.39.153:
slots: ( slots) master
replicates 314cbd10bbc4c1339fb737575af41f04408c2087
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All slots covered.
至此,一个集群就搭建起来了,从上边的信息我们也可以看出来,192.168.39.153:7000,192.168.39.153:7001,192.168.39.153:7002是master节点,另外三个是slave节点。
本文参考了http://lib.csdn.net/article/redis/35915
————————————————
版权声明:本文为CSDN博主「mindlesslcc」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/sanwenyublog/article/details/52946669
redis(二十二):Redis 集群(proxy 型)一的更多相关文章
- redis(二)redis的主从模式和集群模式
redis(二)redis的主从模式和集群模式 主从模式 集群模式 主从模式 redis的主从模式,指的是针对多台redis实例时候,只存在一台主服务器master,提供读写的功能,同时存在依附在这台 ...
- 关于redis主从|哨兵|集群模式
关于redis主从.哨兵.集群的介绍网上很多,这里就不赘述了. 一.主从 通过持久化功能,Redis保证了即使在服务器重启的情况下也不会损失(或少量损失)数据,因为持久化会把内存中数据保存到硬盘上,重 ...
- 深入学习Redis(5):集群
前言 在前面的文章中,已经介绍了Redis的几种高可用技术:持久化.主从复制和哨兵,但这些方案仍有不足,其中最主要的问题是存储能力受单机限制,以及无法实现写操作的负载均衡. Redis集群解决了上述问 ...
- Spring Boot+redis存储session,满足集群部署、分布式系统的session共享
本文讲述spring-boot工程中使用spring-session机制进行安全认证,并且通过redis存储session,满足集群部署.分布式系统的session共享. 原文链接:https://w ...
- redis主从|哨兵|集群模式
关于redis主从.哨兵.集群的介绍网上很多,这里就不赘述了. 一.主从 通过持久化功能,Redis保证了即使在服务器重启的情况下也不会损失(或少量损失)数据,因为持久化会把内存中数据保存到硬盘上,重 ...
- Redis哨兵、复制、集群的设计原理与区别
一 前言 谈到Redis服务器的高可用,如何保证备份的机器是原始服务器的完整备份呢?这时候就需要哨兵和复制. 哨兵(Sentinel):可以管理多个Redis服务器,它提供了监控,提醒以及自动的故障转 ...
- Redis之高可用、集群、云平台搭建
原文:Redis之高可用.集群.云平台搭建 文章大纲 一.基础知识学习二.Redis常见的几种架构及优缺点总结三.Redis之Redis Sentinel(哨兵)实战四.Redis之Redis Clu ...
- Redis运维实战之集群中的脑裂
1.对于分布式Redis主从集群来说,什么是脑裂? 所谓的脑裂,就是指在主从集群中,同时有两个主节点,它们都能接收写请求.而脑裂最直接的影响,就是客户端不知道应该往哪个主节点写入数据,结果就是不同的客 ...
- Redis 实战篇之搭建集群
Redis 集群简介# Redis Cluster 即 Redis 集群,是 Redis 官方在 3.0 版本推出的一套分布式存储方案.完全去中心化,由多个节点组成,所有节点彼此互联.Redis 客户 ...
- Redis.之.环境搭建(集群)
Redis.之.环境搭建(集群) 现有环境: /u01/app/ |- redis # 单机版 |- redis-3.2.12 # redis源件 所需软件:redis-3.0.0.gem -- ...
随机推荐
- EIGRP-13-弥散更新算法-停滞在活动状态
如果一台路由器参与到了针对某个目的地的弥散计算中(即将相应路由置为活动状态,并发送查询包),它必须首先等待所有邻居都返回响应包,之后它才能执行自已的弥散计算,接着选出新的最优路径,最后开始发送自已的响 ...
- Divisors (求解组合数因子个数)【唯一分解定理】
Divisors 题目链接(点击) Your task in this problem is to determine the number of divisors of Cnk. Just for ...
- 测试必备工具之最强抓包神器 Charles,你会了么?
前言 作为软件测试工程师,大家在工作中肯定经常会用到各种抓包工具来辅助测试,比如浏览器自带的抓包工具-F12,方便又快捷:比如时下特别流行的Fiddler工具,使用各种web和APP测试的各种场景 ...
- Java学习笔记7(IO)
IO(输入输出) IO流按照操作数据的不同,分为字节流和字符流,按照数据传输方向分为输入流和输出流. 字节流 计算机中,所有文件都是以二进制(字节)形式存在,IO流中针对字节的输入输出提供了一系列的流 ...
- 算法题解:最小的K个数(海量数据Top K问题)
[本文版权归微信公众号"代码艺术"(ID:onblog)所有,若是转载请务必保留本段原创声明,违者必究.若是文章有不足之处,欢迎关注微信公众号私信与我进行交流!] 题目 输入 n ...
- v-model指令的学习(双向绑定)
v-bind 只能实现数据的单项绑定,从data到view,无法实现双向绑定 v-model可以实现表单元素和model中数据的双向绑定 注意:model只能运用到表单元素中 如:input sele ...
- 阿里巴巴--java多线程的两种实现方式,以及二者的区别
阿里巴巴面试的时候,昨天问了我java面试的时候实现java多线程的两种方式,以及二者的区别当时只回答了实现线程的两种方式,但是没有回答上二者的区别: java实现多线程有两种方式: 1.继承Thre ...
- Django实现图片上传并前端页面显示
Django实现图片上传和图片显示 开始之前我们先确认环境中已经安装了Pillow,如果没有安装,可以通过pip install Pillow来安装,这个是python的图像处理库 数据库设置 我们创 ...
- github知名企业开源项目索引
亚马逊:https://github.com/amzn 饿了么 https://github.com/ElemeFEhttp://lrd.ele.me/腾讯 https://github.com/Te ...
- python+opencv切割细胞及细胞团(持续更新)
内容包括:游离细胞的切割,有效细胞的信息提取,找出非正常细胞,细胞团的切割,找出非正常细胞团 代码较多,请移步到我的github