用 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上.当我们开发需要和服务器交互的应用程序时,基本上都需要获取服务器端的数 ...
随机推荐
- PAT Basic 1025
1025 反转链表 给定一个常数K以及一个单链表L,请编写程序将L中每K个结点反转.例如:给定L为1→2→3→4→5→6,K为3,则输出应该为3→2→1→6→5→4:如果K为4,则输出应该为4→3→2 ...
- PHP-redis命令之 散列(hashes)
二.散列(hashes) 1.hset:设置散列的值 $redis->hset('myhas','field1','hello'); $redis->hset('myhas','field ...
- 大数据学习——sql练习
1. 现有如下的建表语句和数据: 建表语句 create table student(Sno int,Sname string,Sex string,Sage int,Sdept string)row ...
- 新技术---- MongoDB
MongoDB 在 CentOS7 上安装 MongoDB-------https://www.linuxidc.com/Linux/2016-06/132675.htm Centos7 安装mong ...
- 高级java、C#、php、SQL、JavaScript......+n多编程语言学习分享
/*入园两周年纪念.在搬砖之路一去不返*/ //搬砖什么都好,就是有点伤Ctrl键. <div style="display:none;"> </div>
- Mac 文档阅读软件Dash软件破解版
1.Dash 破解版链接 Mac 上阅读开发文档的软件:支持java.spring.springBoot等.百度网盘下载链接和密码如下. 链接:https://pan.baidu.com/s/1RWM ...
- linux无人值守安装介绍(一)
一.术语解释 PXE(Pre-boot ExecutionEnvironment)是由Intel设计的协议,它可以使计算机通过网络而不是从本地硬盘.光驱等设备启动.现代的网卡,一般都内嵌支持PXE的R ...
- [android 开发篇] 易白教程网址
http://www.yiibai.com/android/android_bluetooth.html
- AFNetWorking出现code=-1016错误解决办法
报错类似: 2015-12-09 15:58:03.062 Carloans[14328:2300485] Error Domain=com.alamofire.error.serialization ...
- 【Luogu】P3800点收集(DP)
题目链接 原题解 代码 #include<iostream> #include<cstdio> #include<cstring> #include<ccty ...