周振林 周振林
首页
  • 前端文章

    • HTML
    • CSS
    • Tailwind CSS (opens new window)
    • JavaScript
    • Vue3
    • 其他
  • 规范
  • Spring
  • 安装教程
  • 其他教程
  • 归真医学
  • 常用药材
  • 学习笔记
  • 经方学习心得
  • 基础
  • 虚拟化
  • Docker
  • OpenStack
  • 心情杂货
关于
收藏

周振林

IT界的小学生
首页
  • 前端文章

    • HTML
    • CSS
    • Tailwind CSS (opens new window)
    • JavaScript
    • Vue3
    • 其他
  • 规范
  • Spring
  • 安装教程
  • 其他教程
  • 归真医学
  • 常用药材
  • 学习笔记
  • 经方学习心得
  • 基础
  • 虚拟化
  • Docker
  • OpenStack
  • 心情杂货
关于
收藏
  • 基础

  • 虚拟化

  • Docker

    • Docker概念
    • Docker安装
    • 运行第一个容器
    • Docker常用命令
    • Docker完整操作
    • Docker存储
    • Docker网络
    • Redis主从集群
    • Docker最佳实践
    • Docker Compose
    • Dockerfile制作镜像
    • 一键安装超多中间件
      • Docker部署MySQL
      • Docker运行JAR
    • OpenStack

    • 心情杂货

    • 更多
    • Docker
    周振林
    2025-08-14
    目录

    一键安装超多中间件

    #Disable memory paging and swapping performance
    sudo swapoff -a
    
    # Edit the sysctl config file
    sudo vi /etc/sysctl.conf
    
    # Add a line to define the desired value
    # or change the value if the key exists,
    # and then save your changes.
    vm.max_map_count=262144
    
    # Reload the kernel parameters using sysctl
    sudo sysctl -p
    
    # Verify that the change was applied by checking the value
    cat /proc/sys/vm/max_map_count
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16

    # yaml

    注意:

    • 将下面文件中 kafka 的 119.45.147.122 改为你自己的服务器IP。
    • 所有容器都做了时间同步,这样容器的时间和linux主机的时间就一致了 准备一个 compose.yaml文件,内容如下:
    name: devsoft
    services:
      redis:
        image: bitnami/redis:latest
        restart: always
        container_name: redis
        environment:
          - REDIS_PASSWORD=123456
        ports:
          - '6379:6379'
        volumes:
          - redis-data:/bitnami/redis/data
          - redis-conf:/opt/bitnami/redis/mounted-etc
          - /etc/localtime:/etc/localtime:ro
    
      mysql:
        image: mysql:8.0.31
        restart: always
        container_name: mysql
        environment:
          - MYSQL_ROOT_PASSWORD=123456
        ports:
          - '3306:3306'
          - '33060:33060'
        volumes:
          - mysql-conf:/etc/mysql/conf.d
          - mysql-data:/var/lib/mysql
          - /etc/localtime:/etc/localtime:ro
    
      rabbit:
        image: rabbitmq:3-management
        restart: always
        container_name: rabbitmq
        ports:
          - "5672:5672"
          - "15672:15672"
        environment:
          - RABBITMQ_DEFAULT_USER=rabbit
          - RABBITMQ_DEFAULT_PASS=rabbit
          - RABBITMQ_DEFAULT_VHOST=dev
        volumes:
          - rabbit-data:/var/lib/rabbitmq
          - rabbit-app:/etc/rabbitmq
          - /etc/localtime:/etc/localtime:ro
      opensearch-node1:
        image: opensearchproject/opensearch:2.13.0
        container_name: opensearch-node1
        environment:
          - cluster.name=opensearch-cluster # Name the cluster
          - node.name=opensearch-node1 # Name the node that will run in this container
          - discovery.seed_hosts=opensearch-node1,opensearch-node2 # Nodes to look for when discovering the cluster
          - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 # Nodes eligibile to serve as cluster manager
          - bootstrap.memory_lock=true # Disable JVM heap memory swapping
          - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
          - "DISABLE_INSTALL_DEMO_CONFIG=true" # Prevents execution of bundled demo script which installs demo certificates and security configurations to OpenSearch
          - "DISABLE_SECURITY_PLUGIN=true" # Disables Security plugin
        ulimits:
          memlock:
            soft: -1 # Set memlock to unlimited (no soft or hard limit)
            hard: -1
          nofile:
            soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
            hard: 65536
        volumes:
          - opensearch-data1:/usr/share/opensearch/data # Creates volume called opensearch-data1 and mounts it to the container
          - /etc/localtime:/etc/localtime:ro
        ports:
          - 9200:9200 # REST API
          - 9600:9600 # Performance Analyzer
    
      opensearch-node2:
        image: opensearchproject/opensearch:2.13.0
        container_name: opensearch-node2
        environment:
          - cluster.name=opensearch-cluster # Name the cluster
          - node.name=opensearch-node2 # Name the node that will run in this container
          - discovery.seed_hosts=opensearch-node1,opensearch-node2 # Nodes to look for when discovering the cluster
          - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 # Nodes eligibile to serve as cluster manager
          - bootstrap.memory_lock=true # Disable JVM heap memory swapping
          - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
          - "DISABLE_INSTALL_DEMO_CONFIG=true" # Prevents execution of bundled demo script which installs demo certificates and security configurations to OpenSearch
          - "DISABLE_SECURITY_PLUGIN=true" # Disables Security plugin
        ulimits:
          memlock:
            soft: -1 # Set memlock to unlimited (no soft or hard limit)
            hard: -1
          nofile:
            soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
            hard: 65536
        volumes:
          - /etc/localtime:/etc/localtime:ro
          - opensearch-data2:/usr/share/opensearch/data # Creates volume called opensearch-data2 and mounts it to the container
    
      opensearch-dashboards:
        image: opensearchproject/opensearch-dashboards:2.13.0
        container_name: opensearch-dashboards
        ports:
          - 5601:5601 # Map host port 5601 to container port 5601
        expose:
          - "5601" # Expose port 5601 for web access to OpenSearch Dashboards
        environment:
          - 'OPENSEARCH_HOSTS=["http://opensearch-node1:9200","http://opensearch-node2:9200"]'
          - "DISABLE_SECURITY_DASHBOARDS_PLUGIN=true" # disables security dashboards plugin in OpenSearch Dashboards
        volumes:
          - /etc/localtime:/etc/localtime:ro
      zookeeper:
        image: bitnami/zookeeper:3.9
        container_name: zookeeper
        restart: always
        ports:
          - "2181:2181"
        volumes:
          - "zookeeper_data:/bitnami"
          - /etc/localtime:/etc/localtime:ro
        environment:
          - ALLOW_ANONYMOUS_LOGIN=yes
    
      kafka:
        image: 'bitnami/kafka:3.4'
        container_name: kafka
        restart: always
        hostname: kafka
        ports:
          - '9092:9092'
          - '9094:9094'
        environment:
          - KAFKA_CFG_NODE_ID=0
          - KAFKA_CFG_PROCESS_ROLES=controller,broker
          - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://0.0.0.0:9094
          - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://119.45.147.122:9094
          - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
          - KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@kafka:9093
          - KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
          - ALLOW_PLAINTEXT_LISTENER=yes
          - "KAFKA_HEAP_OPTS=-Xmx512m -Xms512m"
        volumes:
          - kafka-conf:/bitnami/kafka/config
          - kafka-data:/bitnami/kafka/data
          - /etc/localtime:/etc/localtime:ro
      kafka-ui:
        container_name: kafka-ui
        image: provectuslabs/kafka-ui:latest
        restart: always
        ports:
          - 8080:8080
        environment:
          DYNAMIC_CONFIG_ENABLED: true
          KAFKA_CLUSTERS_0_NAME: kafka-dev
          KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092
        volumes:
          - kafkaui-app:/etc/kafkaui
          - /etc/localtime:/etc/localtime:ro
    
      nacos:
        image: nacos/nacos-server:v2.3.1
        container_name: nacos
        ports:
          - 8848:8848
          - 9848:9848
        environment:
          - PREFER_HOST_MODE=hostname
          - MODE=standalone
          - JVM_XMX=512m
          - JVM_XMS=512m
          - SPRING_DATASOURCE_PLATFORM=mysql
          - MYSQL_SERVICE_HOST=nacos-mysql
          - MYSQL_SERVICE_DB_NAME=nacos_devtest
          - MYSQL_SERVICE_PORT=3306
          - MYSQL_SERVICE_USER=nacos
          - MYSQL_SERVICE_PASSWORD=nacos
          - MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
          - NACOS_AUTH_IDENTITY_KEY=2222
          - NACOS_AUTH_IDENTITY_VALUE=2xxx
          - NACOS_AUTH_TOKEN=SecretKey012345678901234567890123456789012345678901234567890123456789
          - NACOS_AUTH_ENABLE=true
        volumes:
          - /app/nacos/standalone-logs/:/home/nacos/logs
          - /etc/localtime:/etc/localtime:ro
        depends_on:
          nacos-mysql:
            condition: service_healthy
      nacos-mysql:
        container_name: nacos-mysql
        build:
          context: .
          dockerfile_inline: |
            FROM mysql:8.0.31
            ADD https://raw.githubusercontent.com/alibaba/nacos/2.3.2/distribution/conf/mysql-schema.sql /docker-entrypoint-initdb.d/nacos-mysql.sql
            RUN chown -R mysql:mysql /docker-entrypoint-initdb.d/nacos-mysql.sql
            EXPOSE 3306
            CMD ["mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]
        image: nacos/mysql:8.0.30
        environment:
          - MYSQL_ROOT_PASSWORD=root
          - MYSQL_DATABASE=nacos_devtest
          - MYSQL_USER=nacos
          - MYSQL_PASSWORD=nacos
          - LANG=C.UTF-8
        volumes:
          - nacos-mysqldata:/var/lib/mysql
          - /etc/localtime:/etc/localtime:ro
        ports:
          - "13306:3306"
        healthcheck:
          test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
          interval: 5s
          timeout: 10s
          retries: 10
      prometheus:
        image: prom/prometheus:v2.52.0
        container_name: prometheus
        restart: always
        ports:
          - 9090:9090
        volumes:
          - prometheus-data:/prometheus
          - prometheus-conf:/etc/prometheus
          - /etc/localtime:/etc/localtime:ro
    
      grafana:
        image: grafana/grafana:10.4.2
        container_name: grafana
        restart: always
        ports:
          - 3000:3000
        volumes:
          - grafana-data:/var/lib/grafana
          - /etc/localtime:/etc/localtime:ro
    
    volumes:
      redis-data:
      redis-conf:
      mysql-conf:
      mysql-data:
      rabbit-data:
      rabbit-app:
      opensearch-data1:
      opensearch-data2:
      nacos-mysqldata:
      zookeeper_data:
      kafka-conf:
      kafka-data:
      kafkaui-app:
      prometheus-data:
      prometheus-conf:
      grafana-data:
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246

    # 启动

    # 在 compose.yaml 文件所在的目录下执行
    docker compose up -d
    # 等待启动所有容器
    
    1
    2
    3

    tip:如果重启了服务器,可能有些容器会启动失败。再执行一遍 docker compose up -d即可。所有程序都可运行成功,并且不会丢失数据。请放心使用。

    # 访问

    • zookeeper可视化工具下载:
      • https://github.com/vran-dev/PrettyZoo/releases/download/v2.1.1/prettyZoo-win.zip
    • redis可视化工具下载:
      • https://github.com/qishibo/AnotherRedisDesktopManager/releases/download/v1.6.4/Another-Redis-Desktop-Manager.1.6.4.exe
    组件(容器名) 介绍 访问地址 账号/密码 特性
    Redis(redis) k-v 库 你的ip:6379 单密码模式:123456 已开启AOF
    MySQL(mysql) 数据库 你的ip:3306 root/123456 默认utf8mb4字符集
    Rabbit(rabbit) 消息队列 你的ip:15672 rabbit/rabbit 暴露5672和15672端口
    OpenSearch(opensearch-node1/2) 检索引擎 你的ip:9200 内存512mb;两个节点
    opensearch-dashboards search可视化 你的ip:5601
    Zookeeper(zookeeper) 分布式协调 你的ip:2181 允许匿名登录
    kafka(kafka) 消息队列 你的ip:9092 外部访问:9094 占用内存512mb
    kafka-ui(kafka-ui) kafka可视化 你的ip:8080
    nacos(nacos) 注册/配置中心 你的ip:8848 nacos/nacos 持久化数据到MySQL
    nacos-mysql(nacos-mysql) nacos配套数据库 你的ip:13306 root/root
    prometheus(prometheus) 时序数据库 你的ip:9090
    grafana(grafana 你的ip:3000 admin/admin
    Last Updated: 2025/08/14, 18:32:19
    Dockerfile制作镜像
    Docker部署MySQL

    ← Dockerfile制作镜像 Docker部署MySQL→

    最近更新
    01
    肺
    10-24
    02
    脾胃
    10-24
    03
    肝
    10-24
    更多文章>
    Copyright © 2019-2025 鲁ICP备19032096号-1
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式