关于消息推送服务器

目前有很多第三方的开放成熟的推送服务。鉴于项目需要 我们项目需要自己搭建 自己的推送服务。

我们的推送应用场景
  • 聊天消息

  • 项目内部消息提醒

  • 移动设备接受消息

应用到的相关软件工具知识点

  • redis 数据库 用于 centrifugo 启用分布式 集群做数据支撑(如果单节点 可以不用数据库 默认以内存作为缓存)

  • docker

  • centrifugo 消息推送服务软件 https://github.com/centrifugal/centrifugo

  • rancher 编排工具

redis 集群

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

参考资料

作者:鹊桥仙


出处:http://www.cnblogs.com/freefei/


关于作者:专注于Linux平台项目架构、管理和企业解决方案。基于linux 容器技术 微服务架构 云计算领域有一点点经验。如有问题或建议,请多多赐教!


本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。如有问题,可以邮件:ranmufei@qq.com  微博:鹊桥仙  联系我,非常感谢。

        </p>
</div>

用 centrifugo 搭建 消息推送服务器 docker + rancher 搭建的更多相关文章

  1. C# BS消息推送 SignalR Hubs环境搭建与开发(二)

    1. 前言 本文是根据网上前人的总结得出的. 环境: SignalR2.x,VS2015,Win10 2. 开始开发 1)新建一个MVC项目,叫做SignalRDemo 2)安装SignalR包 In ...

  2. 微信小程序【消息推送服务器认证C# WebAPI】

    参考微信开发文档: https://developers.weixin.qq.com/miniprogram/dev/api/custommsg/callback_help.html 代码可用 /// ...

  3. cordova 消息推送,告别,消息推送服务器,和 苹果推送证书

    cordova plugin add org.apache.cordova.vibration cordova plugin add https://github.com/katzer/cordova ...

  4. (转)苹果消息推送服务器 php 证书生成

    1.准备好 aps_developer_identity.cer , push.p12这两个证书文件 2. 生成证书如下: openssl x509 -in aps_developer_identit ...

  5. C# BS消息推送 SignalR介绍(一)

    1. 前言 本文是根据网上前人的总结得出的. 环境: SignalR2.x,VS2015,Win10 介绍 1)SignalR能用来持久客户端与服务端的连接,让我们便于开发一些实时的应用,例如聊天室在 ...

  6. Android消息推送完美方案[转]

    转自 Android消息推送完美方案 推送功能在手机应用开发中越来越重要,已经成为手机开发的必须.在Android应用开发中,由于众所周知的原因,Android消息推送我们不得不大费周折.本文就是用来 ...

  7. Android消息推送完美方案

    转自:http://bbs.hiapk.com/thread-4652657-1-1.html 推送功能在手机应用开发中越来越重要,已经成为手机开发的必须.在Android应用开发中,由于众所周知的原 ...

  8. Android消息推送完美解决方案全析

    推送功能在手机应用开发中越来越重要,已经成为手机开发的必须.在Android应用开发中,由于众所周知的原因,Android消息推送我们不得不大费周折.本文就是用来和大家共同探讨一种Android消息推 ...

  9. android系统下消息推送机制

    一.推送方式简介: 当前随着移动互联网的不断加速,消息推送的功能越来越普遍,不仅仅是应用在邮件推送上了,更多的体现在手机的APP上.当我们开发需要和服务器交互的应用程序时,基本上都需要获取服务器端的数 ...

随机推荐

  1. Lex与Yacc学习(三)之符号表

    符号表 列举单词表的方式虽然简单但是不全面,如果在词法分析程序运行时可以构建一个单词表,那么就可以在添加新的单词时不用修改词法分析程序. 下面示例便利用符号表实现,即在词法分析程序运行时从输入文件中读 ...

  2. 关于priority_queue的一些说明

    参考GGBeng 相关定义 优先队列容器与队列一样,只能从队尾插入元素,从队首删除元素.但是它有一个特性,就是队列中最大的元素总是位于队首,所以出队时,并非按照先进先出的原则进行,而是将当前队列中最大 ...

  3. nw335 debian sid x86-64 -- 4 realtek 提供的官方驱动

    realtek 提供的官方驱动   1 查看无线网卡的驱动芯片: $ sudo lsusb Bus 001 Device 003: ID 0bda:8176 Realtek Semiconductor ...

  4. django的rest framework框架——版本、解析器、序列化

    一.rest framework的版本使用 1.版本可以写在URL中,通过GET传参,如 http://127.0.0.1:8082/api/users/?version=v1 (1)自定义类获取版本 ...

  5. python红包随机生成(隔板法)

    #红包生成思路#200 块钱 10个红包#0-200 的一个轴,随机取9个点,分成10段, 每一段的值表示一个红包的大小 #把输入的 money值 * 100 拿到的数值就是分, 不用再考虑单位是元的 ...

  6. DOM tiny-demo

    <script type="text/javascript" language="javascript">var i = 4; function a ...

  7. 正负无穷float('inf')的一些用法

    Python中可以用如下方式表示正负无穷: float("inf"), float("-inf") 利用 inf 做简单加.乘算术运算仍会得到 inf > ...

  8. Java异常架构图及面试题---https://www.cnblogs.com/gaoweixiao99/p/4905860.html

    https://www.cnblogs.com/gaoweixiao99/p/4905860.html 红色为检查异常,就是eclipse要提示你是try catch 还是throws. 非检查异常, ...

  9. Relay Race (DP)

    Furik and Rubik take part in a relay race. The race will be set up on a large square with the side o ...

  10. RAC+单节点搭建DG

    primary RAC to single standby 参考文献:RAC+单实例DATAGUARD 配置   http://blog.csdn.net/miyatang/article/detai ...