-
Notifications
You must be signed in to change notification settings - Fork 36
Home
Welcome to the QPush wiki!
1.创建运行用户(如jetty), 得到运行目录(记为 $RUN_FOLDER )/home/jetty
2.配置参数(/etc/security/limits.conf)
* soft nofile 65535
* hard nofile 65535
3.配置参数(/etc/sysctl.conf)
vm.swappiness = 0
vm.overcommit_memory = 1
net.ipv4.neigh.default.gc_stale_time=120
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.all.arp_announce=2
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_synack_retries = 2
net.ipv4.conf.lo.arp_announce=2
fs.file-max = 1048576
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_mem = 786432 2097152 3145728
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000
4.安装Redis
https://github.com/antirez/redis
5.安装MySQL
http://www.cnblogs.com/shanyou/p/3278692.html
http://www.tuicool.com/articles/m6r6Bjj
1.下载并准备好源码
su - jetty
mkdir -p source
cd source
git clone https://github.com/yamingd/QPush.git
cp -f Deploy/qpush.zip ../
cp -f Deploy/deploy_qpush.sh ../
cd ../
unzip -o qpush.zip
chmod +x deploy_qpush.sh
2.若系统没有安装gradle (http://gradle.org/)
cd ~/source/QPush
./gradlew build
这个时候会看到下载gradle的进度,等待下载完成和上面的命令执行完成.
接下来需要配置gradle到.bash_profile,方便全局使用
PATH=$PATH:$HOME/bin:$HOME/gradle-2.5/bin
export PATH
当然上面也可以直接到 http://gradle.org/ 下载安装包到$HOME,然后解压出来,只要把正确的gradle目录配置到$PATH里即可
3.配置QPush参数
3.1 Redis参数($HOME/qpush/conf/jedis.properties)
host=127.0.0.1
port=63790
maxActive=50
maxIdle=10
maxWait=5000
根据自己的环境修改host, port, maxWait, MaxActive, maxIdel
3.2 MySQL参数($HOME/qpush/conf/jdbc.properties)
driverClass=com.mysql.jdbc.Driver
jdbcUrl=jdbc:mysql://127.0.0.1:33060/qpush?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false&rewriteBatchedStatements=true
username=qpush
password=qpush!
idleConnectionTestPeriod=60
idleMaxAge=240
maxConnectionsPerPartition=30
minConnectionsPerPartition=10
partitionCount=3
acquireIncrement=10
statementsCacheSize=100
releaseHelperThreads=3
根据自己的参数修改jdbcUrl, username, password。同时请参考jdbc组件的官网(http://www.jolbox.com/)来强化配置
3.3 QPush Gateway参数($HOME/qpush/conf/gateway.properties)
server.actors=10
server.workers=10
server.port=9080
dispatcher.interval=100
dispatcher.thread_min=10
dispatcher.thread_max=100
dispatcher.broadcast_limit=100
handler.executors=100
payloadQueue=payloadRedisQueue
apns.sandbox=true
jdbc.executors=100
上面server.port是使用在手机端的连接里 当设置apns.sandbox=true是使用Apple的开发者调试模式,设为fasle为生产模式,Apple证书路径在QPush的表product里配置(如下所示)
CREATE TABLE `product` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '产品id',
`title` varchar(255) DEFAULT NULL COMMENT '产品名称',
`appKey` varchar(255) DEFAULT NULL COMMENT '产品key',
`secret` varchar(255) DEFAULT NULL COMMENT '产品secret',
`clientTypeid` tinyint(2) DEFAULT NULL COMMENT '客户端类别id, 判断消息的投递方式,在离线状态下',
`certPass` varchar(255) DEFAULT NULL COMMENT 'iOS推送证书密码(正式)',
`certPath` varchar(255) DEFAULT NULL COMMENT 'iOS推送证书路径(正式)',
`devCertPass` varchar(255) DEFAULT NULL COMMENT 'iOS推送证书密码(开发)',
`devCertPath` varchar(255) DEFAULT NULL COMMENT 'iOS推送证书路径(开发)',
PRIMARY KEY (`id`),
UNIQUE KEY `ix_product_key` (`appKey`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='产品表';
3.4 QPush Publisher参数($HOME/qpush/conf/publisher.properties)
server.actors=10
server.workers=10
server.port=9180
payloadQueue=payloadRedisQueue
jdbc.executors=100
上面的server.port需要在业务服务端,结合qpush.client.jar一起使用
经过上面6步已经准备好参数、源码,接下来是安装数据库
4.安装MySQL数据库
cd ~/source/QPush
ls qpush.sql
登录MySql,创建数据库和初始化表结构
mysql -uroot -p
create database qpush;
grant all on qpush.* to qpush@'%' identified by 'qpush!';
flush privileges;
use qpush;
source qpush.sql
show tables;
5.配置qpush服务为开机起动
cd /etc/init.d/
ln -s /home/jetty/qpush/gateway/bin/start.sh qpush-gateway
ln -s /home/jetty/qpush/publisher/bin/start.sh qpush-publisher
chkconfig --add qpush-gateway
chkconfig --level 2345 qpush-gateway on
chkconfig --add qpush-publisher
chkconfig --level 2345 qpush-publisher on
cd $HOME
sh deploy-qpush.sh
启动publish
sudo service qpush-publisher stop
sudo service qpush-publisher start
启动gateway
sudo service qpush-gateway stop
sudo service qpush-gateway start
```