98b7222a48c1c3b1a5eb89ff4efebb45b3c11f74
\346\234\211\350\276\271\350\275\246\345\215\207\347\272\247\344\270\272\346\227\240\350\276\271\350\275\246\346\214\207\345\274\225.md
| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | |
| 2 | - |
|
| 3 | 2 | # 分布式系统升级技术指引文档 |
| 4 | 3 | --- |
| 5 | 4 | |
| ... | ... | @@ -9,89 +8,156 @@ |
| 9 | 8 | ```bash |
| 10 | 9 | kubectl -n {namespace} get svc redis-stack # 确认NodePort端口(默认8001) |
| 11 | 10 | ``` |
| 11 | + 在服务里面找到 redis-stack,访问8001对应的NodePort,打开redisInsight,查询 *statestore||app_key |
|
| 12 | + |
|
| 13 | + [[http://iidp.chinasie.com:9999/iidpminio/distributed-v2/1.png]] |
|
| 12 | 14 | 2. **数据查询** |
| 13 | 15 | 通过RedisInsight执行查询指令: |
| 14 | 16 | ```redis |
| 15 | 17 | SCAN 0 MATCH *statestore||app_key* # 获取全量路由键 |
| 16 | 18 | ``` |
| 19 | + [[http://iidp.chinasie.com:9999/iidpminio/distributed-v2/2.png]] |
|
| 17 | 20 | 3. **格式转换** |
| 18 | - 使用平台提供的`route-converter`工具进行数据迁移: |
|
| 19 | - ```bash |
|
| 20 | - ./converter --input=redis_export.json --output=new_arch_routes.yaml |
|
| 21 | - ``` |
|
| 21 | + 使用平台提供的`route-converter.exe` [[下载|http://iidp.chinasie.com:9999/iidpminio/distributed-v2/2.png]] 转换工具进行数据迁移: |
|
| 22 | + 将复制的value使用平台提供的工具来转换出新架构需要的路由信息。 |
|
| 23 | + |
|
| 24 | + [[http://iidp.chinasie.com:9999/iidpminio/distributed-v2/3.png]] |
|
| 22 | 25 | |
| 23 | 26 | --- |
| 24 | 27 | |
| 25 | 28 | ## 二、配置管理标准化 |
| 29 | + |
|
| 26 | 30 | ### 2.1 命名规范重构 |
| 27 | -| 原配置项 | 新标准配置项 | 变更类型 | |
|
| 28 | -|-------------------|------------------|----------------| |
|
| 29 | -| snest-nginx | iidp-nginx | 强制重建 | |
|
| 30 | -| snest-app | iidp-app | 配置迁移 | |
|
| 31 | + |
|
| 32 | + |
|
| 33 | +| 原配置项 | 新标准配置项 | 变更类型 | |
|
| 34 | +|-------------------|------------------|----------------| |
|
| 35 | +| snest-nginx | iidp-nginx | 重建 | |
|
| 36 | +| snest-app | iidp-app | 配置迁移 | |
|
| 37 | + |
|
| 38 | +如下图,重点关注app和nginx配置,比如snest-ngxin和sneset-app,其他项目可能是iidp-nginx和iidp-app。由于平台后面统一调整成了iidp,所以所有的配置一律都使用 iidp-nginx 和 iidp-app 命名,不是这个配置名称的也统一需要修改或者重建。 |
|
| 39 | + |
|
| 40 | +[[http://iidp.chinasie.com:9999/iidpminio/distributed-v2/4.png]] |
|
| 41 | + |
|
| 42 | +[[http://iidp.chinasie.com:9999/iidpminio/distributed-v2/5.png]] |
|
| 43 | + |
|
| 44 | +[[http://iidp.chinasie.com:9999/iidpminio/distributed-v2/6.png]] |
|
| 45 | + |
|
| 46 | + |
|
| 47 | +[[http://iidp.chinasie.com:9999/iidpminio/distributed-v2/7.png]] |
|
| 48 | + |
|
| 31 | 49 | |
| 32 | 50 | ### 2.2 网关配置新增(gw.yaml) |
| 51 | + |
|
| 52 | +由于新的模式增加了网关,所以需要新增一个gw.yaml配置,注意调整命名空间。 |
|
| 53 | + |
|
| 54 | +[[http://iidp.chinasie.com:9999/iidpminio/distributed-v2/8.png]] |
|
| 55 | + |
|
| 33 | 56 | ```yaml |
| 34 | -apiVersion: v1 |
|
| 35 | -kind: ConfigMap |
|
| 36 | -metadata: |
|
| 37 | - name: iidp-gw-config |
|
| 38 | - namespace: {target_namespace} |
|
| 39 | -data: |
|
| 40 | - routing-policy: | |
|
| 41 | - # 核心路由策略 |
|
| 42 | - engine.store.meta.mode=CLOUD |
|
| 43 | - engine.run.mode=DISTRIBUTED_V2 |
|
| 44 | - image-config: | |
|
| 45 | - app.install.image=registry.iidp.cn/core/gateway:v3.2.1 |
|
| 57 | +#gw 网关 配置文件 |
|
| 58 | + |
|
| 59 | +model: "release" # debug release test |
|
| 60 | + |
|
| 61 | +port: "8060" |
|
| 62 | + |
|
| 63 | +namespace: "mijiuye" |
|
| 64 | +labelSelector: "iidp=iidp" |
|
| 65 | + |
|
| 66 | +apiServerHost: "" |
|
| 67 | +kubeConfigFile: "" |
|
| 68 | +resyncPeriod: 0 # 重新同步的时间间隔,单位为秒 |
|
| 69 | + |
|
| 70 | +syncRateLimit: 0 # 速率限制 |
|
| 71 | + |
|
| 72 | +shutdownGracePeriod: 30 # 关闭服务时的宽限期,单位为秒 |
|
| 73 | + |
|
| 74 | +useUnixDomainSocket: true |
|
| 75 | +unixDomainSocketPath: "/socket/gw-iidp.socket" |
|
| 76 | + |
|
| 77 | + |
|
| 78 | +rateLimiter: |
|
| 79 | + enable: false # 是否启用速率限制 |
|
| 80 | + rate: 2000 # 速率限制,单位为 次/秒 |
|
| 81 | + per: 1s # 速率限制的时间窗口,默认是1s |
|
| 82 | + slack: 10 # 速率限制的松弛度 |
|
| 83 | + |
|
| 84 | +hystrixSettings: |
|
| 85 | + enable: false |
|
| 86 | + defaultTimeout: 10000 # DefaultTimeout is how long to wait for command to complete, in milliseconds |
|
| 87 | + defaultMaxConcurrent: 1000 # DefaultMaxConcurrent is how many commands of the same type can run at the same time |
|
| 88 | + defaultVolumeThreshold: 20 # DefaultVolumeThreshold is the minimum number of requests needed before a circuit can be tripped due to health |
|
| 89 | + defaultSleepWindow: 5000 # DefaultSleepWindow is how long, in milliseconds, to wait after a circuit opens before testing for recovery |
|
| 90 | + defaultErrorPercentThreshold: 50 # DefaultErrorPercentThreshold causes circuits to open once the rolling measure of errors exceeds this percent of requests |
|
| 91 | + |
|
| 92 | +buildInApps: |
|
| 93 | + handler: "mijiuye/iidp-app" # * 代表全部,或者指定handler来处理,比如 meta-test/iidp-app |
|
| 94 | + apps: [ |
|
| 95 | + "base.master", |
|
| 96 | + "user-prefer.master", |
|
| 97 | + "file.master", |
|
| 98 | + "dict.master", |
|
| 99 | + "base_log.master", |
|
| 100 | + "config.master", |
|
| 101 | + "cache.master", |
|
| 102 | + "sie-iidp-appmarket.master", |
|
| 103 | + "sie-snest-tenant.master", |
|
| 104 | + "sie-snest-interface.master", |
|
| 105 | + "sie-snest-workflow.master", |
|
| 106 | + "sie-snest-workflow-extend.master", |
|
| 107 | + "sie-snest-mail.master", |
|
| 108 | + "sie-snest-i18n.master", |
|
| 109 | + "sie-snest-datasource.master" |
|
| 110 | +] |
|
| 111 | + |
|
| 46 | 112 | ``` |
| 47 | 113 | |
| 48 | 114 | ### 2.3 应用配置迁移 |
| 49 | -1. **配置文件继承** |
|
| 50 | - ```bash |
|
| 51 | - kubectl get cm snest-app -o yaml > iidp-app.yaml |
|
| 52 | - sed -i 's/snest-app/iidp-app/g' iidp-app.yaml |
|
| 53 | - ``` |
|
| 54 | -2. **关键参数注入** |
|
| 55 | - 在`application-dev.properties`追加: |
|
| 56 | - ```properties |
|
| 57 | - # 分布式模式配置 |
|
| 58 | - cluster.node.ttl=300s |
|
| 59 | - service.discovery.interval=30s |
|
| 60 | - ``` |
|
| 115 | + |
|
| 116 | +继续新增iidp-app配置文件,可以直接复制原来的,但是注意metadata.name |
|
| 117 | + |
|
| 118 | +[[http://iidp.chinasie.com:9999/iidpminio/distributed-v2/9.png]] |
|
| 119 | + |
|
| 120 | +编辑配置,添加下面的配置项 |
|
| 121 | + |
|
| 122 | +``` properties |
|
| 123 | +# 安装镜像版本 |
|
| 124 | +app.install.image=xxxx |
|
| 125 | +engine.store.meta.mode=CLOUD |
|
| 126 | +# DISTRIBUTED_V2 模式 |
|
| 127 | +engine.run.mode=DISTRIBUTED_V2 |
|
| 128 | +``` |
|
| 129 | + |
|
| 130 | +[[http://iidp.chinasie.com:9999/iidpminio/distributed-v2/10.png]] |
|
| 61 | 131 | |
| 62 | 132 | --- |
| 63 | 133 | |
| 64 | -## 三、服务声明更新流程 |
|
| 65 | -### 3.1 服务依赖声明 |
|
| 134 | +至此整个配置完毕。 |
|
| 135 | + |
|
| 136 | +## 三、service更新流程 |
|
| 137 | + |
|
| 138 | +前已经获取了sidecar的路由信息,现在需要将这些路由信息重新写入到新模式的分布式架构中,也就是service的yaml文件中 |
|
| 139 | + |
|
| 140 | +[[http://iidp.chinasie.com:9999/iidpminio/distributed-v2/3.png]] |
|
| 141 | + |
|
| 142 | +根据生成的yaml,我们依次修改对应 service 的yaml,这里举例路由yaml如下: |
|
| 66 | 143 | ```yaml |
| 67 | -# iidp-core-services.yaml |
|
| 68 | -apiVersion: iidp.io/v1beta1 |
|
| 69 | -kind: ServiceDefinition |
|
| 70 | -spec: |
|
| 71 | - components: |
|
| 72 | - - name: iidp |
|
| 73 | - dependencies: "" |
|
| 74 | - installedApps: |
|
| 75 | - - newSdkApp.master |
|
| 76 | - - oppmApp.master |
|
| 77 | - - sf-auto-interface-app.master |
|
| 78 | - - name: iiot |
|
| 79 | - dependencies: |
|
| 80 | - - iiot_apiAdapter.master |
|
| 81 | - - iiot_base.master |
|
| 82 | - installedApps: |
|
| 83 | - - iiot_project.master |
|
| 84 | - - iiot_access.master |
|
| 144 | + |
|
| 145 | +iidp: |
|
| 146 | + iidp.com/dependencies: "" |
|
| 147 | + iidp.com/installedApps: newSdkApp.master,oppmApp.master,sf-auto-interface-app.master,logo.master,i18n-frontend.master,interface-frontend.master |
|
| 148 | +iiot: |
|
| 149 | + iidp.com/dependencies: iiot_apiAdapter.master,iiot_base.master,iiot_thing.master,iiot_task_scheduler.master,net.master,iiot_db_management.master,iiot_store_management.master,iiot_messagepush.master,iiot_messagepolicy.master,iiot_alarm.master,iiot_ruleengine.master |
|
| 150 | + iidp.com/installedApps: iiot_base.master,iiot_project.master,iiot_access.master,iiot_alarm.master,iiot_device_scheduler.master,iiot_keylog.master,iiot_messagepolicy.master,iiot_messagepolicy_alarm.master,iiot_messagepolicy_ruleengine.master,iiot_messagepolicy_store_management.master,iiot_messagepush.master,iiot_messagetransfer.master,iiot_program.master,iiot_store.master,iiot_store_management.master,iiot_task_scheduler.master,iiot_thing.master,iiot_apiAdapter.master,iiot_db_management.master |
|
| 151 | +mbm: |
|
| 152 | + iidp.com/dependencies: mbm-center-aps-ms.master,mbm-component.master,mbm-main.master,mbm-site-wms-strategy.master,mbm-site-wms-stock.master,mbm-common-base.master |
|
| 153 | + iidp.com/installedApps: mbm-center-aps-mrp.master,mbm-center-aps-ms.master,mbm-component.master,mbm-main.master,mbm-site-aps-as.master,mbm-site-wms.master,mbm-site-wms-io.master,mbm-site-wms-stock.master,mbm-site-wms-strategy.master,mbm-site-wms-wh.master,mbm-common-base.master,mbm-edo.master,sie-iidp-wizard.master,filepreview.master,sie-iidp-file.master |
|
| 154 | +smi: |
|
| 155 | + iidp.com/dependencies: smi-base-common.master,smi-base-datasource.master,smi-base-asset.master,smi-ida-base.master |
|
| 156 | + iidp.com/installedApps: smi-base-asset.master,smi-base-common.master,smi-base-data-permission.master,smi-base-datasource.master,smi-base-dispatch.master,smi-base-license.master,smi-base-monitor.master,smi-base-notice.master,smi-base-testpoint.master,smi-ida-alarm.master,smi-ida-base.master,smi-ida-broadcast.master,smi-ida-chart.master,smi-ida-comcanvas.master,smi-ida-common.master,smi-ida-design.master,smi-ida-newscene.master,smi-ida-problem.master,smi-ida-report.master |
|
| 157 | + |
|
| 85 | 158 | ``` |
| 86 | 159 | |
| 87 | -### 3.2 版本控制策略 |
|
| 88 | -1. 使用GitOps进行配置版本管理 |
|
| 89 | -2. 每次变更需生成新的`configVersion`标签 |
|
| 90 | - ```yaml |
|
| 91 | - metadata: |
|
| 92 | - annotations: |
|
| 93 | - iidp.com/configVersion: 20250318-01 |
|
| 94 | - ``` |
|
| 160 | +[[http://iidp.chinasie.com:9999/iidpminio/distributed-v2/10.png]] |
|
| 95 | 161 | |
| 96 | 162 | --- |
| 97 | 163 |