用 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上.当我们开发需要和服务器交互的应用程序时,基本上都需要获取服务器端的数 ...
随机推荐
- Python解释器镜像源修改
目录 Windows Mac 这篇文章将解除你使用python的pip install xxx受到的网速限制,如果只是下载较小的第三方库,可以尝试pip --default-timeout=100 i ...
- 前端Web框架的实现过程
一.Web框架的本质: 我们可以这样理解:所有的Web应用本质上就是一个socket服务端,而用户的浏览器就是一个socket客户端. 这样我们就可以自己实现Web框架了. 半成品自定义web框架 i ...
- (转)WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
[root@bak1 bak]# scp gwsyj.sql.gz root@192.168.21.65:/data/dbdata/ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ...
- 修改JVM的参数、Jstat、Jstack、gclog
---恢复内容开始--- 1. jetty 修改JVM的参数 deploy/bin/env.sh 在上面的环境变量脚本中进行修改:如果分配给JVM的内存是4g 这个里面的JAVA_OPTS 的配置项就 ...
- ython——杂货铺
三目运算: >>> 1 if 5>3 else 0 1 >>> 1 if 5<3 else 0 0 深浅拷贝: 一.数字和字符串 对于 数字 和 字符串 ...
- 【Ts 5】Httpclient的应用和封装
一.基本概述 1.1,什么是Httpclient HttpClient 是 Apache Jakarta Common 下的子项目,可以用来提供高效的.最新的.功能丰富的支持 HTTP 协议的客户端编 ...
- js的undefined怎么判断
window.undefined=window.undefined 如何理解呢?百度搜索:window.undefined=window.undefined 博客说是为了兼容老浏览器. 技巧: 调试时 ...
- POJ 2409 Let it Bead ——Burnside引理
[题目分析] 裸题直接做. 一个长度为n,颜色为m的环,本质不同的染色方案是多少. 数据范围比较小,直接做就好了. [代码] #include <cstdio> #include < ...
- NCCloud 指令示例
http://ansrlab.cse.cuhk.edu.hk/software/nccloud/ Implementation of NCCloud in C++ (updated: August 2 ...
- Chapter 4-5
1.切片对象 sequence[起始索引:结束索引:步进值] 对象身份的比较 is /is not 2.eval()参数是一个字符串, 可以把这个字符串当成表达式来求值. >>>x ...