From 2e335c1e6e24d2c206fa674e7ead4584e333e3ea Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期二, 15 七月 2025 11:35:39 +0800 Subject: [PATCH] 解决kafka存储数据问题 --- docker/kraft.yml | 46 +++++++++++++++ docker/spring.yml | 134 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+), 0 deletions(-) diff --git a/docker/kraft.yml b/docker/kraft.yml new file mode 100644 index 0000000..f68ed50 --- /dev/null +++ b/docker/kraft.yml @@ -0,0 +1,46 @@ +version: "3.8" +services: + # kafka + kafka: + image: bitnami/kafka:3.4 + environment: + # 鍚敤KRaft妯″紡 + KAFKA_BROKER_ID: 1 + KAFKA_ENABLE_KRAFT: yes + KAFKA_CFG_PROCESS_ROLES: broker,controller + KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER + #KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093,SASL_PLAINTEXT://:9094 + #KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://192.168.11.203:9092,SASL_PLAINTEXT://192.168.11.203:9094 + KAFKA_CFG_LISTENERS: CONTROLLER://:9093,SASL_PLAINTEXT://:9092 + KAFKA_CFG_ADVERTISED_LISTENERS: SASL_PLAINTEXT://192.168.11.203:9092 + KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SASL_PLAINTEXT:SASL_PLAINTEXT + KAFKA_CFG_INTER_BROKER_LISTENER_NAME: SASL_PLAINTEXT + # 寮哄埗璁剧疆闆嗙兢ID锛堝繀椤诲敮涓�锛� + KAFKA_CFG_NODE_ID: 1 + KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 1@localhost:9093 + KAFKA_KRAFT_CLUSTER_ID: kgvdPTwkStm6XDCOCZLi0w + # SASL/PLAIN璁よ瘉閰嶇疆 + KAFKA_CFG_SASL_ENABLED_MECHANISMS: PLAIN + KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL: PLAIN + KAFKA_CLIENT_USERS: admin + KAFKA_CLIENT_PASSWORDS: kaFka_12#$56 + # 鍏朵粬蹇呰鍙傛暟 + #ALLOW_PLAINTEXT_LISTENER: yes + healthcheck: + test: ["CMD", "kafka-broker-api-versions", "--bootstrap-server", "localhost:9092"] + interval: 10s + timeout: 2s + retries: 3 + volumes: + # chmod -R 777 kafka_data/ + - ./kafka_data:/bitnami/kafka + - /var/run/docker.sock:/var/run/docker.sock + ports: + - 9092:9092 + - 9094:9094 + privileged: true + networks: + - network-jhs +networks: + network-jhs: + driver: bridge diff --git a/docker/spring.yml b/docker/spring.yml new file mode 100644 index 0000000..8558be9 --- /dev/null +++ b/docker/spring.yml @@ -0,0 +1,134 @@ +version: "3.8" +services: + # postgis + postgis: + image: postgis/postgis:17.5 + ports: + - 5432:5432 + volumes: + - ./postgis/pgdata:/var/lib/postgresql/data + - ./postgis/init:/docker-entrypoint-initdb.d + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: Postgres!_17_jHs + ALLOW_IP_RANGE: 0.0.0.0/0 + TZ: Asia/Shanghai + POSTGRES_DB: jhs + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 10s + timeout: 2s + retries: 3 + privileged: true + networks: + - network-jhs + # nacos + nacos: + image: nacos/nacos-server:v3.0.2 + environment: + TZ: Asia/Shanghai + MODE: standalone + SPRING_DATASOURCE_PLATFORM: postgresql + DB_URL: jdbc:postgresql://postgis:5432/jhs?tcpKeepAlive=true&reWriteBatchedInserts=true&ApplicationName=nacos_java + DB_USER: postgres + DB_PASSWORD: Postgres!_17_jHs + NACOS_AUTH_ENABLE: true + NACOS_AUTH_IDENTITY_KEY: nacos + NACOS_AUTH_IDENTITY_VALUE: nAcos_!9#_admIn + DB_POOL_CONFIG_DRIVERCLASSNAME: org.postgresql.Driver + NACOS_AUTH_TOKEN: TmFjb3NfUmFuZG9tX1N0cmluZ18zMl9DaGFyc19Pcl9Mb25nZXI= + volumes: + - ./nacos/logs/:/home/nacos/logs + - ./nacos/plugins:/home/nacos/plugins + #- ./nacos/conf/application.properties:/home/nacos/conf/application.properties + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:8080 || exit 1"] + interval: 10s + timeout: 2s + retries: 3 + start_period: 7s + ports: + - 8080:8080 + - 8848:8848 + - 9848:9848 + depends_on: + postgis: + condition: service_healthy + privileged: true + networks: + - network-jhs + #restart: always + # redis + redis: + image: redis:7 + ports: + - 6379:6379 + volumes: + - ./redis/redis.conf:/data/redis.conf + - ./redis/data:/data + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 2s + retries: 3 + #command: redis-server --requirepass Redis_s!E_6.2.6 + command: redis-server /data/redis.conf + networks: + - network-jhs + # gateway + gateway: + image: openjdk:8-jre + volumes: + - ./gateway/logs:/logs + - ./gateway:/app + environment: + TZ: Asia/Shanghai + #entrypoint: /bin/sh -c "sleep 30 && java -jar /app/se-gateway.jar --spring.config.location=file:/app/" + entrypoint: java -jar /app/se-gateway.jar --spring.config.location=file:/app/ + depends_on: + redis: + condition: service_healthy + nacos: + condition: service_healthy + networks: + - network-jhs + # system + system: + image: openjdk8-422-gdal:3.5.2 + volumes: + - ./system/logs:/logs + - ./system:/app + environment: + TZ: Asia/Shanghai + #entrypoint: /bin/sh -c "sleep 30 && java -jar /app/se-system.jar --spring.config.location=file:/app/" + entrypoint: java -jar /app/se-system.jar --spring.config.location=file:/app/ + depends_on: + postgis: + condition: service_healthy + redis: + condition: service_healthy + nacos: + condition: service_healthy + networks: + - network-jhs + # nginx + nginx: + image: nginx:1.29 + ports: + - 80:80 + - 443:443 + environment: + TZ: Asia/Shanghai + volumes: + - ./nginx/logs:/var/log/nginx + - ./nginx/html:/usr/share/nginx/html + - ./nginx/conf/conf.d:/etc/nginx/conf.d + - ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf + depends_on: + - gateway + - system + networks: + - network-jhs +networks: + network-jhs: + driver: bridge -- Gitblit v1.9.3