智控-价签系统
集群部署操作说明
(仅供内部和特定客户使用)
更新时间:2021年-07月-09日
杭州智控网络有限公司
版权所有 不得复制
前言
编写目的
本文档描述了智控价签系统的集群部署。用于指导相应人员进行系统部署。部署人员有一定的运维基础,且对高可用负载均衡、阿里云产品及容器有相关的了解。
读者对象
修订记录
版本 | 发布日期 | 发布说明 |
---|---|---|
1.0 | 2020-07-03 | 首次发布 |
1.1 | 2020-07-19 | 组件安装顺序调整,补充基础环境安装说明 |
1.2 | 2020-07-20 | 修改一个命令书写错误 |
1.3 | 2020-07-21 | 新增邮件模板说明 提醒主备my.cnf的配置位置 |
1.4 | 2020-07-26 | redis配置优化(关闭持久化,增加内存和内存淘汰策略配置) Esl-app,增加jvm参数修改说明 |
1.5 | 2020-07-27 | 增加监控脚本部署说明 |
1.6 | 2020-07-13 | 部署架构采用公有云部分组件部署 |
名词解释
名称 | 描述 |
---|---|
docker | 应用容器引擎 |
keepalived | 基于vrrp协议的一款高可用软件 |
MySQL | 关系型数据库 |
Nginx | 高性能的HTTP和方向代理web服务器 |
XXL-JOB | 分布式任务调度组件 |
Redis | 基于key-value结构存储的内存数据库 |
IoT MQ | 物联网消息服务组件 |
Fastdfs | 分布式文件系统 |
ZK-ESL | 智控的价签系统 |
云数据库RDS版 | 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务 |
阿里云负载均衡 | **SLB分为两类:传统型负载均衡CLB和应用型负载均衡ALB。 |
传统型负载均衡CLB | 支持TCP、UDP、HTTP和HTTPS协议,具备强大的四层处理能力,以及基础的七层处理能力。 |
应用型负载均衡ALB | 专门面向七层,提供超强的业务处理性能,如HTTPS卸载能力。单实例每秒查询数QPS(Query Per Second)可达100万次。 |
云数据库Redis版 | 云数据库Redis版(ApsaraDB for Redis)是兼容开源Redis协议标准、提供混合存储的数据库服务,基于双机热备架构及集群架构,可满足高吞吐、低延迟及弹性变配等业务需求。 |
部署架构
安装注意事项
文档中所有提到的配置文件(包括但不限于keepalived.conf, *.sh等),如果有在windows上编辑过,先执行dos2unix转义命令(安装使用见本文档章节Dos2unix安装使用);
文档中所有提到的执行文件(.sh后缀),均需要授予执行权限(linux命令:chmod +x 文件名);
文档中提到的IP、端口、账号、密码、邮箱等,根据实际部署进行设置;
文档中提到的容器名,如esl_tracker_n,其中n代表序号,根据需要设置,如设置为1或者2;
文档中提到的镜像文档、组件安装包等,在软件安装包中提供 (ZK-ESL除外,根据最终版本确定)。
服务器信息
部署服务 | 服务器配置 |
---|---|
服务器一:主服务:MySQL、Redis、Nginx 集群结点1:ZK-ESL、IoT MQ、XXL-JOB、FastDFS |
CPU:4 Core;RAM:16G;SSD:500G。 |
服务器二:备服务:MySQL、Redis、Nginx 集群结点2:ZK-ESL、IoT MQ、XXL-JOB、FastDFS |
CPU:4 Core;RAM:16G;SSD:500G。 |
组件部署说明
本文档中,以/usr/local/esl为安装根目录,如无特殊说明,esl目录均为/usr/local/esl这个根目录。
基础环境安装
使用一键安装包部署基础环境esl-3.5.3-Zkong-online。
SLB负载均衡配置
EMQtt集群配置
master配置
[root@master etc]# cat emqx.conf |grep cluster.
cluster.discovery = static
cluster.static.seeds = emqx1@172.16.9.171,emqx2@172.16.9.170
node.name = emqx1@172.16.9.171
slave配置
[root@slave etc]# cat emqx.conf |grep cluster.
cluster.discovery = static
cluster.static.seeds = emqx1@172.16.9.170,emqx2@172.16.9.171
node.name = emqx2@172.16.9.171
emqtt数据库配置
[root@slave plugins]# pwd
/usr/local/esl/emqtt/etc/plugins
[root@slave plugins]# cat emqx_auth_mysql.conf |grep auth.mysql
auth.mysql.server = rm-bp127b1q9fif332g6.mysql.rds.aliyuncs.com:3306
auth.mysql.pool = 8
auth.mysql.username = root
auth.mysql.password = Zkong_1234
auth.mysql.database = demo
SLB代理两台机器1883端口
Fastdfs集群配置
mkdir -p /usr/local/esl/fastdfs/tracker
mkdir -p /usr/local/esl/fastdfs/storage
先在2台服务器启动tracker:
docker run -dti -e TZ="Asia/Shanghai" --network=host --name esl_tracker_n --restart=always -v /usr/local/esl/fastdfs/tracker/:/export/fastdfs/tracker -e TRACKER_BASE_PATH=/export/fastdfs/tracker -e TRACKER_PORT=8300 gzlj2018/fastdfs:5.11 sh /usr/local/src/tracker.sh
Tip: esl_tracker_n中的n,修改为数字。第一台为1,第二台为2,...;下面esl_storage_n同样处理。ip,修改为机器ip
分别在2台服务器再启动storage:
docker run -dti -e TZ="Asia/Shanghai" --network=host --name esl_storage_n --restart=always -v /usr/local/esl/fastdfs/storage/:/export/fastdfs/storage -e STORAGE_PORT=8400 -e STORAGE_BASE_PATH=/export/fastdfs/storage -e STORAGE_PATH0=/export/fastdfs/storage -e TRACKER_SERVER=ip_1:8300,ip_2:8300 -e GROUP_COUNT=1 -e HTTP_SERVER_PORT=8410 -e GROUP_NAME=group1 gzlj2018/fastdfs:5.11 sh /usr/local/src/storage.sh
RDS高可用选型
1.常规实例 高可用版、申请内外网地址、使用按量付费即可,通用型配置,数据库类型Mysql 5.7,设置安全组便于公网连接。
Redis缓存配置选型
服务连接复制详解
[root@master app]# cat application.yml
MYSQL_WRITE_IP: rm-bp127b1q9fif332g6.mysql.rds.aliyuncs.com //阿里云rds内网地址
MYSQL_WRITE_PORT: 3306
MYSQL_WRITE_USERNAME: root
MYSQL_WRITE_PASSWORD: Zkong_1234
MYSQL_READ_IP: rm-bp127b1q9fif332g6.mysql.rds.aliyuncs.com //阿里云rds内网地址
MYSQL_READ_PORT: 3306
MYSQL_READ_USERNAME: root
MYSQL_READ_PASSWORD: Zkong_1234
REDIS_IP: r-bp1yjmvoc4or6zxyf1pd.redis.rds.aliyuncs.com //阿里云Redis缓存地址
REDIS_PORT: 6379
XXL_JOB_IP: 121.196.206.204 //弹性EIP、SLB负载均衡地址
XXL_JOB_PORT: 8085
FASTDFS_TRACKER_IP_1: 172.16.9.171 //ecs内网地址
FASTDFS_TRACKER_IP_2: 172.16.9.170 //ecs内网地址
FASTDFS_TRACKER_PORT: 8300
MQTT_IP: 121.196.206.204 //基站连接地址SLB或EIP地址
MQTT_HOST: tcp://121.196.206.204:1884
MQTT_USER_NAME_PUB: unique_pub
MQTT_USER_NAME_SUB: unique_sub
MQTT_PASSWORD_PUB: abc
MQTT_PASSWORD_SUB: abcd
MQTT_TIMEOUT: 3000
MQTT_KEEP_ALIVE: 20
FIRMWARE_PATH: /usr/local/esl/files/apstation/
ESL_FIRMWARE_PATH: /usr/local/esl/files/esl_firmwares/
AP_FIRMWARE_PATH: /usr/local/esl/files/ap_firmwares/
EXCEL_PATH: /usr/local/esl/files/excel/
LICENSE_PATH: /usr/local/esl/files/license/
IMAGE_PATH: /usr/local/esl/files/image/
PART_MIN_VERSION: 2.1.19
LOG_RETENTION_DAYS: 14
server:
port: 9999
spring:
main:
allow-bean-definition-overriding: true
messages:
basename: i18n/messages
encoding: UTF-8
jpa:
database-platform: org.hibernate.dialect.MySQLDialect
hibernate:
use-new-id-generator-mappings: false
naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
# datasource:
# url: jdbc:mysql://${MYSQL_IP}:${MYSQL_PORT}/demo?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true&allowMultiQueries=true
# username: root
# password: Zkong_1234
# driver-class-name: com.mysql.cj.jdbc.Driver
redis:
host: ${REDIS_IP}
port: ${REDIS_PORT}
password: Zkong_1234 //Redis密码
shardingsphere:
datasource:
names:
master,slave
# 主数据源
master:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${MYSQL_WRITE_IP}:${MYSQL_WRITE_PORT}/demo?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true&allowMultiQueries=true&useSSL=false
username: ${MYSQL_WRITE_USERNAME}
password: ${MYSQL_WRITE_PASSWORD}
# 从数据源
slave:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${MYSQL_READ_IP}:${MYSQL_READ_PORT}/demo?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true&allowMultiQueries=true&useSSL=false
username: ${MYSQL_READ_USERNAME}
password: ${MYSQL_READ_PASSWORD}
masterslave:
# 读写分离配置
load-balance-algorithm-type: round_robin
# 最终的数据源名称
name: dataSource
# 主库数据源名称
master-data-source-name: master
# 从库数据源名称列表,多个逗号分隔
slave-data-source-names: slave
props:
# 开启SQL显示,默认false
sql:
show: false
mybatis:
typeAliasesPackage: com.zk.model
mapperLocations: classpath:mapper/**/*.xml
jwt:
key: "saaa-ihrm"
ttl: "3600000"
fdfs:
soTimeout: 1501
connectTimeout: 601
thumb-image: #缩略图生成参数
width: 150
height: 150
tracker-list: ${FASTDFS_TRACKER_IP_1}:${FASTDFS_TRACKER_PORT},${FASTDFS_TRACKER_IP_2}:${FASTDFS_TRACKER_PORT}
swagger:
show: true
multipart:
enabled: true
async:
executor:
thread:
core_pool_size: 20
max_pool_size: 50
queue_capacity: 99999
name:
prefix: zk-async-service-
xxl:
job:
admin:
addresses: http://${XXL_JOB_IP}:${XXL_JOB_PORT}/xxl-job-admin
executor:
appname: xxl-job-executor-strategy
port: 9988
logpath: /data/applogs/xxl-job/jobhandler
logretentiondays: 1
ip:
custom:
url: http://${XXL_JOB_IP}:${XXL_JOB_PORT}/xxl-job-admin/jobinfo
accessToken:
strategy:
job:
add:
url: http://${XXL_JOB_IP}:${XXL_JOB_PORT}/xxl-job-admin/jobinfo/add
addAll:
url: http://${XXL_JOB_IP}:${XXL_JOB_PORT}/xxl-job-admin/jobinfo/addStrategyJobs
updateAll:
url: http://${XXL_JOB_IP}:${XXL_JOB_PORT}/xxl-job-admin/jobinfo/updateStrategyJobs
removeAll:
url: http://${XXL_JOB_IP}:${XXL_JOB_PORT}/xxl-job-admin/jobinfo/removeAll
update:
url: http://${XXL_JOB_IP}:${XXL_JOB_PORT}/xxl-job-admin/jobinfo/update
remove:
url: http://${XXL_JOB_IP}:${XXL_JOB_PORT}/xxl-job-admin/jobinfo/remove
enable:
url: http://${XXL_JOB_IP}:${XXL_JOB_PORT}/xxl-job-admin/jobinfo/start
enableAll:
url: http://${XXL_JOB_IP}:${XXL_JOB_PORT}/xxl-job-admin/jobinfo/startAll
disable:
url: http://${XXL_JOB_IP}:${XXL_JOB_PORT}/xxl-job-admin/jobinfo/stop
disableAll:
url: http://${XXL_JOB_IP}:${XXL_JOB_PORT}/xxl-job-admin/jobinfo/stopAll
apply:
job:
group: 2
handler: strategyApplyJobHandler
restore:
job:
group: 2
handler: strategyRestoreJobHandler
light:
start:
job:
group: 3
handler: strategyLightStartJobHandler
alarm:
job:
group: 5
handler: alarmEmailJobHandler
draw:
job:
group: 6
publish:
handler: publishMsgHandler
scan:
handler: scanTimeOutHandler
log:
handler: saveLogHandler
append:
send:
job:
group: 7
handler: appendSendHandler
system:
current:
version: v-3.1.0
font:
relative:
path: /usr/local/esl/myfonts/
lcd:
server:
url: http://192.168.100.93:8066
admin: admin
apiKey: cfb5c774d360b40fe39493c5f9c26be3
flag: false
wz: