{"id":3550,"date":"2026-04-01T07:34:47","date_gmt":"2026-03-31T23:34:47","guid":{"rendered":"https:\/\/199604.com\/?p=3550"},"modified":"2026-03-27T23:13:55","modified_gmt":"2026-03-27T15:13:55","slug":"3550","status":"publish","type":"post","link":"https:\/\/199604.com\/3550","title":{"rendered":"\u4e1c\u65b9\u901a TongWeb \u5bb9\u5668\u5316\u6388\u6743\u6587\u4ef6\u66f4\u65b0\u6307\u5357"},"content":{"rendered":"<h1>\u4e1c\u65b9\u901a TongWeb \u5bb9\u5668\u5316\u6388\u6743\u6587\u4ef6\u66f4\u65b0\u6307\u5357<\/h1>\n<h2>&#x1f31f; \u6982\u8ff0<\/h2>\n<p>\u5728 Kubernetes (K8s) \u73af\u5883\u4e2d\uff0c\u786e\u4fdd\u4e1c\u65b9\u901a (TongWeb) \u6388\u6743\u6587\u4ef6 (<code>license.dat<\/code>) \u7684\u6b63\u786e\u914d\u7f6e\u4e0e\u53ca\u65f6\u66f4\u65b0\u662f\u4fdd\u969c\u670d\u52a1\u9ad8\u53ef\u7528\u7684\u5173\u952e\u3002\u7531\u4e8e\u6d4b\u8bd5\u6388\u6743\u901a\u5e38\u6709\u6548\u671f\u8f83\u77ed\uff08 3 \u4e2a\u6708\uff09\uff0c\u82e5\u672a\u6b63\u786e\u914d\u7f6e\u81ea\u52a8\u52a0\u8f7d\u6216\u6301\u4e45\u5316\u6302\u8f7d\uff0cPod \u91cd\u542f\u540e\u53ef\u80fd\u56e0\u6388\u6743\u8fc7\u671f\u800c\u5bfc\u81f4\u5e94\u7528\u542f\u52a8\u5931\u8d25\u3002<\/p>\n<blockquote><p>\n  <strong>\u6838\u5fc3\u75db\u70b9<\/strong>\uff1a\u6388\u6743\u8fc7\u671f\u5bfc\u81f4\u5bb9\u5668\u5065\u5eb7\u68c0\u67e5\u5931\u8d25\uff0cPod \u8fdb\u5165 <code>CrashLoopBackOff<\/code> \u72b6\u6001\u3002<br \/>\n  <strong>\u89e3\u51b3\u65b9\u6848<\/strong>\uff1a\u5229\u7528 K8s <code>ConfigMap<\/code> \u5b9e\u73b0\u6388\u6743\u6587\u4ef6\u7684\u89e3\u8026\u7ba1\u7406\u4e0e\u52a8\u6001\u6302\u8f7d\u3002\n<\/p><\/blockquote>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/qn.199604.com\/typoraImg\/202603252349349.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/qn.199604.com\/typoraImg\/202603252349349.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\u6388\u6743\u8fc7\u671f\u9519\u8bef\u793a\u4f8b\" \/><\/div><\/p>\n<hr \/>\n<h2>&#x1f4e6; \u4e00\u3001JAR \u5305\u90e8\u7f72\u65b9\u5f0f (Spring Boot \u96c6\u6210)<\/h2>\n<p>\u5f53\u4f7f\u7528 TongWeb \u5d4c\u5165\u5f0f\u7248\uff08Spring Boot Starter\uff09\u65f6\uff0c\u9700\u5728\u5e94\u7528\u5c42\u6307\u5b9a\u6388\u6743\u8def\u5f84\u3002<\/p>\n<h3>1.1 \u5e94\u7528\u914d\u7f6e\u6587\u4ef6\u8bbe\u7f6e<\/h3>\n<p>\u63a8\u8350\u5728 <code>bootstrap.yaml<\/code> \u4e2d\u914d\u7f6e\uff0c\u4ee5\u786e\u4fdd\u5728\u5e94\u7528\u4e0a\u4e0b\u6587\u521d\u59cb\u5316\u6700\u65e9\u671f\u52a0\u8f7d\u6388\u6743\u3002<\/p>\n<p><strong>\u914d\u7f6e\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre><code class=\"language-yaml \">server:\n  tongweb:\n    license:\n      type: file                      # \u6388\u6743\u7c7b\u578b\uff1a\u6307\u5b9a\u4e3a\u6587\u4ef6\u65b9\u5f0f\n      path: \/AppHome\/license.dat      # \u5bb9\u5668\u5185\u90e8\u6388\u6743\u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84\n<\/code><\/pre>\n<p><strong>&#x1f4a1; \u4e13\u5bb6\u63d0\u793a\uff1a<\/strong><br \/>\n&#8211; <code>bootstrap.yaml<\/code> \u4f18\u5148\u7ea7\u9ad8\u4e8e <code>application.yaml<\/code>\uff0c\u9002\u5408\u5b58\u653e\u57fa\u7840\u8bbe\u65bd\u7c7b\u914d\u7f6e\u3002<br \/>\n&#8211; \u8def\u5f84\u5efa\u8bae\u7edf\u4e00\u4e3a <code>\/AppHome\/license.dat<\/code>\uff0c\u4fbf\u4e8e\u5728\u4e0d\u540c\u73af\u5883\u4e2d\u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/qn.199604.com\/typoraImg\/202603252329215.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/qn.199604.com\/typoraImg\/202603252329215.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\u914d\u7f6e\u793a\u4f8b\u622a\u56fe\" \/><\/div><\/p>\n<h3>1.2 Kubernetes \u8d44\u6e90\u5b9a\u4e49 (Deployment\/StatefulSet)<\/h3>\n<p>\u901a\u8fc7 <code>subPath<\/code> \u6302\u8f7d\u5355\u4e2a\u6388\u6743\u6587\u4ef6\uff0c\u907f\u514d\u8986\u76d6\u5bb9\u5668\u5185 <code>\/AppHome<\/code> \u76ee\u5f55\u4e0b\u7684\u5176\u4ed6\u5185\u5bb9\u3002<\/p>\n<pre><code class=\"language-yaml \">spec:\n  template:\n    spec:\n      containers:\n      - name: tongweb-app\n        volumeMounts:\n        # \u5173\u952e\u914d\u7f6e\uff1a\u5c06 ConfigMap \u4e2d\u7684\u6388\u6743\u6587\u4ef6\u6302\u8f7d\u5230\u6307\u5b9a\u8def\u5f84\n        - name: license-volume\n          mountPath: \/AppHome\/license.dat\n          subPath: jar-license.dat    # \u6307\u5b9a ConfigMap \u4e2d\u5bf9\u5e94\u7684 Key\n          readOnly: true              # \u751f\u4ea7\u73af\u5883\u5efa\u8bae\u8bbe\u4e3a\u53ea\u8bfb\n\n      volumes:\n      - name: license-volume\n        configMap:\n          name: tongweb-license-configmap  # \u5f15\u7528\u9884\u5148\u521b\u5efa\u7684 ConfigMap\n          items:\n          - key: jar-license.dat           # ConfigMap \u4e2d\u7684 Key\n            path: jar-license.dat          # \u6620\u5c04\u5230\u5377\u5185\u7684\u6587\u4ef6\u540d\n<\/code><\/pre>\n<hr \/>\n<h2>&#x1f6a2; \u4e8c\u3001WAR \u5305\u90e8\u7f72\u65b9\u5f0f (\u6807\u51c6\u5bb9\u5668\u7248)<\/h2>\n<p>WAR \u5305\u90e8\u7f72\u5728\u72ec\u7acb\u7684 TongWeb \u5bb9\u5668\u4e2d\uff0c\u6388\u6743\u6587\u4ef6\u5fc5\u987b\u653e\u7f6e\u5728 TongWeb \u5b89\u88c5\u6839\u76ee\u5f55\u4e0b\u3002<\/p>\n<h3>2.1 \u90e8\u7f72\u73af\u5883\u8bf4\u660e<\/h3>\n<p>\u6bd4\u5982\u5728\u4f7f\u7528 TongWeb \u6807\u51c6\u5bb9\u5668\u7248\u65f6\uff0c\u6388\u6743\u6587\u4ef6\u5fc5\u987b\u653e\u7f6e\u5728 <code>\/AppHome\/TongWeb8\/license.dat<\/code> \u8def\u5f84\u4e0b\u3002<\/p>\n<ul>\n<li><strong>\u9ed8\u8ba4\u5b89\u88c5\u8def\u5f84<\/strong>\uff1a<code>\/AppHome\/TongWeb8<\/code><\/li>\n<li><strong>\u6388\u6743\u76ee\u6807\u8def\u5f84<\/strong>\uff1a<code>\/AppHome\/TongWeb8\/license.dat<\/code><\/li>\n<\/ul>\n<h3>2.2 Kubernetes \u6302\u8f7d\u914d\u7f6e<\/h3>\n<pre><code class=\"language-yaml \">spec:\n  template:\n    spec:\n      containers:\n      - name: tongweb-server\n        volumeMounts:\n        # 1. \u6302\u8f7d\u6388\u6743\u6587\u4ef6 (\u5173\u952e)\n        - name: license-volume\n          mountPath: \/AppHome\/TongWeb8\/license.dat\n          subPath: docker-license.dat\n          readOnly: true\n\n        # 2. \u6302\u8f7d\u65f6\u533a\u6587\u4ef6 (\u63a8\u8350\uff1a\u786e\u4fdd\u6388\u6743\u6821\u9a8c\u65f6\u95f4\u6233\u6b63\u786e)\n        - name: localtime\n          mountPath: \/etc\/localtime\n          readOnly: true\n\n        # 3. \u6302\u8f7d\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6 (\u53ef\u9009)\n        - name: config-volume\n          mountPath: \/AppHome\/TongWeb8\/domains\/domain1\/conf\/tongweb.xml\n          subPath: tongweb.xml\n          readOnly: true\n\n      volumes:\n      - name: license-volume\n        configMap:\n          name: tongweb-license-configmap\n      - name: localtime\n        hostPath:\n          path: \/etc\/localtime\n      - name: config-volume\n        configMap:\n          name: tongweb-config-configmap\n<\/code><\/pre>\n<hr \/>\n<h2>&#x1f6e0;&#xfe0f; \u4e09\u3001\u914d\u7f6e\u4e2d\u5fc3\u7ba1\u7406 (ConfigMap)<\/h2>\n<p>\u5c06\u4e0d\u540c\u73af\u5883\u3001\u4e0d\u540c\u90e8\u7f72\u65b9\u5f0f\u7684\u6388\u6743\u6587\u4ef6\u7edf\u4e00\u5b58\u653e\u5728\u4e00\u4e2a <code>ConfigMap<\/code> \u4e2d\u3002<\/p>\n<pre><code class=\"language-yaml \">apiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: tongweb-license-configmap\n  namespace: szzx  # \u786e\u4fdd\u4e0e\u5e94\u7528\u5728\u540c\u4e00 Namespace\ndata:\n  # \u901a\u7528\u6388\u6743\u6587\u4ef6\u5185\u5bb9\n  license.dat: |\n    uc3Y29XJfVtZtZTbmF9bd254Jzxxxxxxxxxxxxxxxxxxx \n  # \u4e13\u95e8\u7528\u4e8e Docker \u5bb9\u5668\u7248\u7684\u6388\u6743\n  docker-license.dat: |\n    uc3Y29XJfVtZtZTbmF9bd254JzMxxxxxxxxxxxxxxx\n  # \u4e13\u95e8\u7528\u4e8e JAR \u5305\u5d4c\u5165\u5f0f\u7684\u6388\u6743\n  jar-license.dat: |\n    uc3Y29XJfVtZtZTbmF9bd254Jxxxxxxxxxxxxxxxx\n<\/code><\/pre>\n<hr \/>\n<h2>&#x1f50d; \u56db\u3001\u9a8c\u8bc1\u4e0e\u6545\u969c\u6392\u67e5<\/h2>\n<h3>4.1 \u72b6\u6001\u9a8c\u8bc1<\/h3>\n<p>\u90e8\u7f72\u5b8c\u6210\u540e\uff0c\u53ef\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u6388\u6743\u6587\u4ef6\u662f\u5426\u6b63\u786e\u6302\u8f7d\uff1a<\/p>\n<pre><code class=\"language-bash \"># \u8fdb\u5165\u5bb9\u5668\u67e5\u770b\u6587\u4ef6\u5185\u5bb9\nkubectl exec -it &lt;pod-name&gt; -n szzx -- cat \/AppHome\/license.dat\n<\/code><\/pre>\n<h3>4.2 \u5e38\u89c1\u95ee\u9898\u6392\u67e5<\/h3>\n<ol>\n<li><strong>\u6388\u6743\u8fc7\u671f<\/strong>\uff1a\n<ul>\n<li>\u8868\u73b0\uff1a\u5bb9\u5668\u65e5\u5fd7\u8f93\u51fa <code>License expired<\/code> \u6216 <code>Invalid license<\/code>\u3002<\/li>\n<li>\u89e3\u51b3\uff1a\u66f4\u65b0 ConfigMap \u4e2d\u7684 Data \u5185\u5bb9\uff0c\u5e76<strong>\u91cd\u542f Pod<\/strong>\uff08\u6ce8\u610f\uff1a<code>subPath<\/code> \u6302\u8f7d\u4e0d\u4f1a\u968f ConfigMap \u81ea\u52a8\u70ed\u66f4\u65b0\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u65f6\u533a\u4e0d\u4e00\u81f4<\/strong>\uff1a\n<ul>\n<li>\u8868\u73b0\uff1a\u6388\u6743\u6587\u4ef6\u5728\u6709\u6548\u671f\u5185\uff0c\u4f46\u7cfb\u7edf\u63d0\u793a\u8fc7\u671f\u3002<\/li>\n<li>\u89e3\u51b3\uff1a\u68c0\u67e5 <code>\/etc\/localtime<\/code> \u662f\u5426\u6b63\u786e\u6302\u8f7d\uff0c\u786e\u4fdd\u5bb9\u5668\u65f6\u95f4\u4e0e\u5bbf\u4e3b\u673a\u4e00\u81f4\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u6743\u9650\u95ee\u9898<\/strong>\uff1a\n<ul>\n<li>\u8868\u73b0\uff1aTongWeb \u542f\u52a8\u62a5\u9519 <code>Permission denied<\/code>\u3002<\/li>\n<li>\u89e3\u51b3\uff1a\u68c0\u67e5 <code>volumeMounts<\/code> \u662f\u5426\u8bbe\u7f6e\u4e86\u6b63\u786e\u7684 <code>readOnly<\/code> \u5c5e\u6027\uff0c\u6216\u901a\u8fc7 <code>securityContext<\/code> \u8c03\u6574\u5bb9\u5668\u8fd0\u884c\u7528\u6237\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<p><strong>&#x1f4a1; \u603b\u7ed3<\/strong>\uff1a<br \/>\n\u63a8\u8350\u91c7\u7528 <strong>ConfigMap + subPath<\/strong> \u7684\u65b9\u5f0f\u8fdb\u884c\u6388\u6743\u7ba1\u7406\uff0c\u65e2\u80fd\u4fdd\u8bc1\u6388\u6743\u6587\u4ef6\u7684\u5b89\u5168\u6027\uff0c\u53c8\u80fd\u5728\u4e0d\u91cd\u65b0\u6784\u5efa\u955c\u50cf\u7684\u60c5\u51b5\u4e0b\u5feb\u901f\u5b8c\u6210\u6388\u6743\u66f4\u65b0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e1c\u65b9\u901a TongWeb \u5bb9\u5668\u5316\u6388\u6743\u6587\u4ef6\u66f4\u65b0\u6307\u5357 &#x1f31f; \u6982\u8ff0 \u5728 Kubernetes (K8s) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[495],"tags":[587,576],"class_list":["post-3550","post","type-post","status-publish","format-standard","hentry","category-495","tag-tongweb","tag-576"],"_links":{"self":[{"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/posts\/3550","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/comments?post=3550"}],"version-history":[{"count":4,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/posts\/3550\/revisions"}],"predecessor-version":[{"id":3556,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/posts\/3550\/revisions\/3556"}],"wp:attachment":[{"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/media?parent=3550"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/categories?post=3550"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/tags?post=3550"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}