用 centrifugo 搭建 消息推送服务器 docker + rancher 搭建
关于消息推送服务器
目前有很多第三方的开放成熟的推送服务。鉴于项目需要 我们项目需要自己搭建 自己的推送服务。
我们的推送应用场景
聊天消息
项目内部消息提醒
移动设备接受消息
应用到的相关软件工具知识点
redis 数据库 用于 centrifugo 启用分布式 集群做数据支撑(如果单节点 可以不用数据库 默认以内存作为缓存)
docker
centrifugo 消息推送服务软件 https://github.com/centrifugal/centrifugo
rancher 编排工具
redis 集群
- http://ystyle.top/2015/10/20/Docker-搭建redis-集群/ redis + docker 集群
mkdir /home/www/redis/
wget https://raw.githubusercontent.com/antirez/redis/3.0/redis.conf -O /home/www/redis/redis.conf
cd /home/www/redis/
docker run --name redis-master -p 6379:6379 -d redis # 在rancher 中就不必这么原始来运行docker 镜像了!!!
# 配置 redis.conf 设置主redis 容器的的名称
sed -i 's/# slaveof <masterip> <masterport>/slaveof redis-master 6379/g' redis.conf # redis-master 为redis 主 容器名称
启动一批 redis 重节点
完整 配置 参考 下面 rancher 配置
docker rancher 编排参考
下面的配置运行后 redis 主从 集群 会运行起来不过 centrifugo 如果要启用 redis 作为引擎 必须指定 redis 哨兵模式的地址 ;我的方法是在 已经运行的集群redis从 容器中 同时启用哨兵模式
哨兵模式配置
在 /home/www/redis/sentinel.conf 中添加如下配置内容; 并在开启redis从容器的时候 把这个路劲映射进去
/home/www/redis/sentinel.conf:/sentinel.conf 哨兵模式配置文件
/home/www/redis/redis.conf:/usr/local/etc/redis/redis.conf 集群配置文件
# /home/www/redis/sentinel.conf:/sentinel.conf
sentinel monitor redis-master 10.42.81.33 6379 2
启动哨兵模式 (目前为手动启动哨兵 后面尽量优化为自动刚启动哨兵)
# 容器启动后进容器内执行
redis-sentinel /sentinel.conf
启动容器
redis-sentinel-26379-1:
tty: true
command:
- redis-server
- /usr/local/etc/redis/redis.conf
image: redis:latest
links:
- redis-master:redis-master
volumes:
- /home/www/redis/sentinel-26379.conf:/sentinel.conf
- /home/www/redis/redis.conf:/usr/local/etc/redis/redis.conf
stdin_open: true
centtrifogo6:
tty: true
command:
- centrifugo
- -c
- config.json
- --web
- --engine=redis
- --redis_master_name=redis-master
- --redis_sentinels=redis-slave3:26379
image: hub.03in.com:5002/ranmufei/centrifugo:v1
volumes:
- /host/dir/with/config/file:/centrifugo
stdin_open: true
redis-slave5:
tty: true
command:
- redis-server
- /usr/local/etc/redis/redis.conf
image: redis:latest
links:
- 'redis-master:'
volumes:
- /home/www/redis/redis.conf:/usr/local/etc/redis/redis.conf
- /home/www/redis/sentinel.conf:/sentinel.conf
stdin_open: true
redis-slave1:
tty: true
command:
- redis-server
- /usr/local/etc/redis/redis.conf
image: redis:latest
links:
- redis-master:redis-master
volumes:
- /home/www/redis/redis.conf:/usr/local/etc/redis/redis.conf
- /home/www/redis/sentinel.conf:/sentinel.conf
stdin_open: true
redis-slave2:
tty: true
command:
- redis-server
- /usr/local/etc/redis/redis.conf
image: redis:latest
links:
- redis-master:redis-master
volumes:
- /home/www/redis/redis.conf:/usr/local/etc/redis/redis.conf
- /home/www/redis/sentinel.conf:/sentinel.conf
stdin_open: true
aaabbb:
ports:
- 8182:8000
labels:
io.rancher.loadbalancer.target.centtrifogo6: push.03in.com
tty: true
image: rancher/load-balancer-service
links:
- centtrifogo6:centtrifogo6
stdin_open: true
redis-slave3:
tty: true
command:
- redis-server
- /usr/local/etc/redis/redis.conf
image: redis:latest
links:
- redis-master:redis-master
volumes:
- /home/www/redis/redis.conf:/usr/local/etc/redis/redis.conf
- /home/www/redis/sentinel.conf:/sentinel.conf
stdin_open: true
redis-master:
ports:
- 6379:6379/tcp
tty: true
image: redis:latest
stdin_open: true
参考资料
高可用 搭建集群配置 https://fzambia.gitbooks.io/centrifugal/content/deploy/sentinel.html
https://segmentfault.com/a/1190000010131816 http://ystyle.top/2015/10/20/Docker-搭建redis-集群/ docker 搭建redis 集群
作者:鹊桥仙
出处:http://www.cnblogs.com/freefei/
关于作者:专注于Linux平台项目架构、管理和企业解决方案。基于linux 容器技术 微服务架构 云计算领域有一点点经验。如有问题或建议,请多多赐教!
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。如有问题,可以邮件:ranmufei@qq.com 微博:鹊桥仙 联系我,非常感谢。
</p>
</div>
用 centrifugo 搭建 消息推送服务器 docker + rancher 搭建的更多相关文章
- C# BS消息推送 SignalR Hubs环境搭建与开发(二)
1. 前言 本文是根据网上前人的总结得出的. 环境: SignalR2.x,VS2015,Win10 2. 开始开发 1)新建一个MVC项目,叫做SignalRDemo 2)安装SignalR包 In ...
- 微信小程序【消息推送服务器认证C# WebAPI】
参考微信开发文档: https://developers.weixin.qq.com/miniprogram/dev/api/custommsg/callback_help.html 代码可用 /// ...
- cordova 消息推送,告别,消息推送服务器,和 苹果推送证书
cordova plugin add org.apache.cordova.vibration cordova plugin add https://github.com/katzer/cordova ...
- (转)苹果消息推送服务器 php 证书生成
1.准备好 aps_developer_identity.cer , push.p12这两个证书文件 2. 生成证书如下: openssl x509 -in aps_developer_identit ...
- C# BS消息推送 SignalR介绍(一)
1. 前言 本文是根据网上前人的总结得出的. 环境: SignalR2.x,VS2015,Win10 介绍 1)SignalR能用来持久客户端与服务端的连接,让我们便于开发一些实时的应用,例如聊天室在 ...
- Android消息推送完美方案[转]
转自 Android消息推送完美方案 推送功能在手机应用开发中越来越重要,已经成为手机开发的必须.在Android应用开发中,由于众所周知的原因,Android消息推送我们不得不大费周折.本文就是用来 ...
- Android消息推送完美方案
转自:http://bbs.hiapk.com/thread-4652657-1-1.html 推送功能在手机应用开发中越来越重要,已经成为手机开发的必须.在Android应用开发中,由于众所周知的原 ...
- Android消息推送完美解决方案全析
推送功能在手机应用开发中越来越重要,已经成为手机开发的必须.在Android应用开发中,由于众所周知的原因,Android消息推送我们不得不大费周折.本文就是用来和大家共同探讨一种Android消息推 ...
- android系统下消息推送机制
一.推送方式简介: 当前随着移动互联网的不断加速,消息推送的功能越来越普遍,不仅仅是应用在邮件推送上了,更多的体现在手机的APP上.当我们开发需要和服务器交互的应用程序时,基本上都需要获取服务器端的数 ...
随机推荐
- Pandas中loc,iloc与直接切片的区别
最近使用pandas,一直搞不清楚其中几种切片方法的区别,今天专门看了一下. 0. 把Series的行index或Dataframe的列名直接当做属性来索引. 如: s.index_name df.c ...
- HDU 6447
YJJ's Salesman Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- 合肥工业大学数据结构上机实验代码与实验报告(全)github地址
我已经将这个学期的所有数据结构上机实验的代码与报告上传到github上了,一直都有这个想法,但没抽出时间来学习git.经过上周简单的练习后,我已经基本学会运营自己的代码仓库了.所有代码都是C++写的类 ...
- HttpServlet RequestDispatcher sendredirect和forward
Servlet的框架是由两个Java包组成:javax.servlet和javax.servlet.http. 在javax.servlet包中定义了所有的Servlet类都必须实现或扩展的的通用接口 ...
- FFT-hdu题目练习
网上FFT的讲解和板子有很多,所以直接放题目 hdu1402 http://acm.hdu.edu.cn/showproblem.php?pid=1402 /* problem:大整数乘法 solut ...
- 对比使用Charles和Fiddler两个工具及利用Charles抓取https数据(App)
对比使用Charles和Fiddler两个工具及利用Charles抓取https数据(App) 实验目的:对比使用Charles和Fiddler两个工具 实验对象:车易通App,易销通App 实验结果 ...
- 图论trainning-part-2 C. The Largest Clique
C. The Largest Clique Time Limit: 3000ms Memory Limit: 131072KB 64-bit integer IO format: %lld ...
- A Survey of Model Compression and Acceleration for Deep Neural Network时s
A Survey of Model Compression and Acceleration for Deep Neural Network时s 本文全面概述了深度神经网络的压缩方法,主要可分为参数修 ...
- 性能测试之五--webservices接口测试
下面我们进行webservices接口的讲解,包括脚本生成,参数化和关联. 以天气预报的接口为例,接口地址为: http://ws.webxml.com.cn/WebServices/WeatherW ...
- 【单调队列优化dp】uestc 594 我要长高
http://acm.uestc.edu.cn/#/problem/show/594 [AC] #include<bits/stdc++.h> using namespace std; t ...