相关链接:http://git.oschina.net/mpush/mpush
1、安装redis
2、安装zookeeper
3、安装mpush
4、下载mpush server
最新的正式包https://github.com/mpusher/mpush/releases (也可以自己根据源码构建:mvn clean package -Pzip,pub
)
解压下载的tar包tar -zvxf mpush-release-x.y.z.tar.gz
到 mpush 目录
1)修改 conf 目录下的 vi mpush.conf
文件
mp.log.level=debug
mp.core.min-heartbeat=10s
mp.core.max-heartbeat=10s
mp.core.compress-threshold=10k //启用压缩阀值
mp.zk.server-address="127.0.0.1:2181" //zookeeper地址
mp.redis {// redis 集群配置
nodes:["127.0.0.1:6379"]//格式是ip:port,密码可以没有ip:port
cluster-model:single //single, cluster
password: ""
}
mp.http.proxy-enabled=true //启用http代理
mp.net.gateway-server-net=udp //网关服务使用的网络类型tcp/udp
如果要修改其他配置请参照reference.conf
文件
2)给bin目录下的脚本增加执行权限chmod u+x *.sh
3)执行./mp.sh start
启动服务, 查看帮助./mp.sh
目前支持的命令:
Usage: ./mp.sh {start|start-foreground|stop|restart|status|upgrade|print-cmd}
set-env.sh
用于增加和修改jvm启动参数,比如堆内存、开启远程调试端口、开启jmx等
4)cd logs
目录,cat mpush.out
查看服务是否启动成功 conn-mpush.log显示链接信息
5、https://github.com/mpusher/mpush 下载mpush
application.conf配置文件
PushClientTestMain 推送测试类 (userId为标识)
ConnClientTestMain client测试类
修改userId
android
PushUtils 关于初始化配置,包括ip限制
MPushService 常驻服务,持有MpushClient,并把自身作为MpushClient的ClientListener,监听 MpushClient的变化事件
MPushReceiver主要负责监听网络变化和AlarmManager,以便暂停和恢复推送服务以及健康检查
若做负载可以通过alloc,初始化使用setAllotServer()