关于消息推送服务器

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

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

  • 项目内部消息提醒

  • 移动设备接受消息

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

  • 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. 【mysql】 load local data infield 报错 ERROR 1148 (42000): The used command is not allowed with this MySQL version

    mysql> load data local infile '/Users/flint/learn/mysql/pet' into table bx_pet; 执行报错 ERROR 1148 ( ...

  2. (转)Objective-C语法之动态类型(isKindOfClass, isMemberOfClass,id)等

    本文转自http://blog.csdn.net/totogo2010/article/details/7714960 对象在运行时获取其类型的能力称为内省.内省可以有多种方法实现. 判断对象类型 - ...

  3. LeetCode(3)Longest Substring Without Repeating Characters

    题目: Given a string, find the length of the longest substring without repeating characters. For examp ...

  4. JQuery中xxx is not a function或者can not find $

    在项目中,遇到以上两个错误,反复折腾了好久,js代码写得没有问题,jquery的文件也引入了,就是反复的报告错误,xxx is not a function.如图: 就是这样的错误,shake is ...

  5. python基础学习笔记——闭包

    闭包这个概念好难理解,身边朋友们好多都稀里糊涂的,稀里糊涂的林老冷希望写下这篇文章能够对稀里糊涂的伙伴们有一些帮助~ 请大家跟我理解一下,如果在一个函数的内部定义了另一个函数,外部的我们叫他外函数,内 ...

  6. angular controller与directive相互引用

    /** * Created by Administrator on 2017/8/28. */ var app =angular.module('app',[]); app.directive('fo ...

  7. 大数据学习——sql练习

    1. 现有如下的建表语句和数据: 建表语句 create table student(Sno int,Sname string,Sex string,Sage int,Sdept string)row ...

  8. Android自制rom,为update.zip签名

    确认已经安装好openssl openssl genrsa -out key.pem openssl req -new -key key.pem -out request.pem openssl x5 ...

  9. spring之scope作用域

    spring中,bean的作用域有五种类型:默认是单例模式,         singleton         prototype         request         session   ...

  10. 送外卖(codevs 2800)

    题目描述 Description 有一个送外卖的,他手上有n份订单,他要把n份东西,分别送达n个不同的客户的手上.n个不同的客户分别在1~n个编号的城市中.送外卖的从0号城市出发,然后n个城市都要走一 ...