Axon 参考指南
  • 介绍
  • 架构概览
    • DDD & CQRS 概念
    • 事件溯源
    • 事件驱动的微服务
  • Axon Server
  • 发行说明
    • Axon Framework
      • Major Releases
      • Minor Releases
    • Axon Server
      • Major Releases
      • Minor Releases Standard Edition
      • Minor Releases Enterprise Edition
    • Axon Framework Extensions
      • AMQP
        • Major Releases
      • CDI
        • Major Releases
      • JGroups
        • Major Releases
      • Kafka
        • Major Releases
        • Minor Releases
      • Kotlin
        • Experimental Releases
      • Mongo
        • Major Releases
        • Minor Releases
      • Reactor
        • Major Releases
        • Minor Releases
      • Spring Cloud
        • Major Releases
        • Minor Releases
      • Tracing
        • Major Releases
        • Minor Releases
  • Getting Started
    • 快速开始
  • Axon Framework
    • 介绍
    • 消息传递概念
      • 消息剖析
      • 消息关联
      • 消息拦截
      • 支持带注解的处理程序
      • 异常处理
      • 工作单元
    • 命令
      • 建模
        • 聚合
        • 多实体聚合
        • 聚合状态存储
        • 从另一个聚合创建聚合
        • 聚合多态性
        • 解决冲突
      • 命令调度器
      • 命令处理程序
      • 基础设施
      • 配置
    • 事件
      • 事件调度器
      • 事件处理程序
      • 事件处理器
        • 订阅事件处理器
        • 流式事件处理器
      • 事件总线和事件存储
      • 事件版本控制
    • 查询
      • 查询处理
      • 查询调度器
      • 查询处理程序
      • 实现
      • 配置
    • 长时处理过程(Sagas)
      • 实现
      • 关联
      • 基础设施
    • Deadlines
      • Deadline Managers
      • Event Schedulers
    • 测试
      • 命令 / 事件
      • 长时处理过程(Sagas)
    • 序列化
    • 调整
      • 事件快照
      • 事件处理
      • 命令处理
    • 监控和指标
    • Spring Boot 集成
    • 模块
  • Axon Server
    • 介绍
    • 安装
      • 本地安装
        • Axon Server SE
        • Axon Server EE
      • Docker / K8s
        • Axon Server SE
        • Axon Server EE
    • 管理
      • 配置
        • System Properties
        • Command Line Interface
        • REST API
        • GRPC API
      • Monitoring
        • Actuator Endpoints
        • gRPC Metrics
        • Heartbeat Monitoring
      • Clusters
      • Replication Groups
      • Multi-Context
      • Tagging
      • Backup and Messaging-only Nodes
      • Backups
      • Recovery
      • Plugins
      • Error Codes
    • 安全
      • SSL
      • 访问控制
      • 访问控制 - 标准版
      • 访问控制 - 企业版
      • 访问控制 - 客户端应用程序
      • 访问控制 - 命令行
      • 访问控制 - REST API
      • 访问控制 - LDAP
      • 访问控制 - OAuth 2.0
    • 性能
      • 事件段
      • 流量控制
    • 迁移
      • Standard to Enterprise Edition
      • Non-Axon Server to Axon Server
  • Extensions
    • Spring AMQP
    • JGroups
    • Kafka
    • Kotlin
    • Mongo
    • Reactor
      • Reactor Gateways
    • Spring Cloud
    • Tracing
  • Appendices
    • A. RDBMS Tuning
    • B. Message Handler Tuning
      • 参数解析器
      • 处理程序增强
    • C. 元数据注解
    • D. 标识符生成
    • E. Axon Server Query Language
由 GitBook 提供支持
在本页
  • Docker Images
  • DEPRECATED: The "distroless" images
  • The Eclipse Temurin based images
  • Running Axon Server
  • Customization
  • Docker Compose
  • Kubernetes
  • Using Helm
  1. Axon Server
  2. 安装
  3. Docker / K8s

Axon Server SE

上一页Docker / K8s下一页Axon Server EE

最后更新于2年前

This section is split into 3 sub-sections.

Docker Images

AxonIQ provides a ready to use . There are several variations available:

DEPRECATED: The "distroless" images

The images that use only the version as tag, including "latest", have been built using the Google "Distroless Java" images as base. These images are unique in being very compact, in the sense that they only contain the files needed to run a single Java application, but nothing else. The Axon Server SE images use “gcr.io/distroless/java:11”, which means they run Axon Server using a Java 11 JVM.

Features

The distroless images will only run on recent Intel and AMD processors, using the architecture commonly referred to as "amd64".

Axon Server is installed in the root directory, using the following properties file:

axoniq.axonserver.event.storage=/eventdata
axoniq.axonserver.snapshot.storage=/eventdata
axoniq.axonserver.controldb-path=/data
axoniq.axonserver.pid-file-location=/data
axoniq.axonserver.plugin-package-directory=/data/plugins/bundles
axoniq.axonserver.plugin-cache-directory=/data/plugins/cache
logging.file=/data/axonserver.log
logging.file.max-history=10
logging.file.max-size=10MB

The "/data" and "/eventdata" directories are exported as Docker volumes and will be mapped to directories on the host even if you do not provide alternative locations. To override properties, you can provide a directory with a file named "axonserver.properties" in it and mount that as "/config" in the container.

The Eclipse Temurin based images

All other images, recognizable through tag names that consist of multiple, dash-separated elements, have been built using the "eclipse-temurin" multi-platform images. These are significantly larger than the Distroless ones, but a safe and widely used alternative. For Axon Server they provide the important benefit of supporting not only the 64-bit Intel architecture, but also 32-bit and 64-bit ARM, which means they can run on a wider range of hardware, including Raspberry Pis and Apple M1 based systems. For development and debugging scenarios the biggest advantage is that they also contain a shell (Bash), which means that you can "connect into" a running container.

On using an image with a shell

Features

The Eclipse Temurin based images all run Axon Server in its own home directory, at "/axonserver". The properties file contains the following settings:

axoniq.axonserver.event.storage=/axonserver/events
axoniq.axonserver.snapshot.storage=/axonserver/events
axoniq.axonserver.controldb-path=/axonserver/data
axoniq.axonserver.pid-file-location=/axonserver/data
axoniq.axonserver.plugin-package-directory=/axonserver/plugins/bundles
axoniq.axonserver.plugin-cache-directory=/axonserver/plugins/cache
logging.file=/axonserver/data/axonserver.log
logging.file.max-history=10
logging.file.max-size=10MB

The "/axonserver/config", "/axonserver/data", "/axonserver/events", and "/axonserver/plugins" directories are exported as Docker volumes and will be mapped to directories on the host even if you do not provide alternative locations. To override properties, you can provide a directory with a file named "axonserver.properties" in it and mount that as "/axonserver/config" in the container.

Variants

The Eclipse Temurin based images are available in several variants, shown by the tag:

  • "<version>-dev" or "latest-dev"

    These images run Axon Server as user "root" with a Java 11 JVM. Note the "-dev" fragment is used in all Eclipse Temurin based images to indicate the presence of a shell.

  • Tags with "-jdk-8", "-jdk-11", or "jdk-17"

    These images run Axon Server with the indicated Java version.

  • Tags with "-nonroot"

    These images run Axon Server as user "axonserver", with user-id (UID) 1001 and group-id (GID) 1001.

Running Axon Server

To run the provided image the command below can be executed. This starts Axon Server SE in a docker container that exposes the HTTP (by default 8024) and GRPC (by default 8124) ports to the host.

$ docker run -d --name axonserver -p 8024:8024 -p 8124:8124 axoniq/axonserver

A quick verification of the running docker container can be done by querying the REST API that is available to retrieve configuration information for a running Axon Server instance.

$ curl -s http://localhost:8024/actuator/info

If Axon Server is running, this will display the information below:

{"app":{"name":"Axon Server","description":"AxonIQ","version":"4.5.11"}}

Customization

Assuming that you have a directory named "axon-server-se" which will be the designated location for your volumes and configuration information, we will first create the subdirectories for the volumes. We will also add a couple of custom properties (name/hostname) to the axonserver.properties file which will be placed in the config subdirectory. As stated above, you can add additional properties to control the configuration.

$ mkdir -p axon-server-se/data axon-server-se/events axon-server-se/config
$ (
> echo axoniq.axonserver.name=axonserver
> echo axoniq.axonserver.hostname=localhost
> ) > axon-server-se/config/axonserver.properties

To start the container with the customizations done above, the following command can be executed:

docker run -d --rm --name axonserver -p 8024:8024 -p 8124:8124 -v `pwd`/axon-server-se/data:/axonserver/data -v `pwd`/axon-server-se/events:/axonserver/events -v `pwd`/axon-server-se/config:/axonserver/config axoniq/axonserver:latest-dev

Now if you query the API (utilizing the “curl” command depicted above) it will show that it is running with name “axonserver” and hostname “localhost”. Also, the "data" directory will contain the ControlDB file, PID file, and a copy of the log output, while the “events” directory will have the event and snapshot data.

This completes a basic setup of the Axon Server SE Docker image with implementation of customizations.

Docker Compose

Running Axon Server SE in docker-compose helps address more complex requirements around distributed scenarios. The following file will help start Axon Server SE with “./axon-server-se/data”, “./axon-server-se/events”, and “./axon-server-se/config” mounted as volumes. The config directory is mounted Read-Only.

This again assumes that you have a directory "./axon-server-se", which will be the location for your volumes and configuration information.

version: '3.3'
services:
  axonserver:
    image: axoniq/axonserver:latest-dev
    hostname: axonserver
    volumes:
      - axonserver-data:/axonserver/data
      - axonserver-events:/axonserver/events
      - axonserver-config:/axonserver/config:ro
    ports:
      - '8024:8024'
      - '8124:8124'
    networks:
      - axon-demo

volumes:
  axonserver-data:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: ${PWD}/axon-server-se/data
  axonserver-events:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: ${PWD}/axon-server-se/events
  axonserver-config:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: ${PWD}/axon-server-se/config

networks:
  axon-demo:

Starting Axon Server SE using the docker-compose command is shown below.

$ docker-compose up
Creating network "docker-compose_axon-demo" with the default driver
Creating volume "docker-compose_axonserver-data" with local driver
Creating volume "docker-compose_axonserver-events" with local driver
Creating volume "docker-compose_axonserver-config" with local driver
Creating docker-compose_axonserver_1 ... done
Attaching to docker-compose_axonserver_1
axonserver_1  |      _                     ____
axonserver_1  |     / \   __  _____  _ __ / ___|  ___ _ ____   _____ _ __
axonserver_1  |    / _ \  \ \/ / _ \| '_ \\___ \ / _ \ '__\ \ / / _ \ '__|
axonserver_1  |   / ___ \  >  < (_) | | | |___) |  __/ |   \ V /  __/ |
axonserver_1  |  /_/   \_\/_/\_\___/|_| |_|____/ \___|_|    \_/ \___|_|
axonserver_1  |  Standard Edition                        Powered by AxonIQ

Kubernetes

An Axon Server SE instance has a clear and persistent identity, in that it saves identifying information about itself in the controlDB. Also, if it is used as an event store, the context’s events will be stored on disk as well, which means that Axon Server SE is a stateful application.

In the context of Kubernetes that means we want to bind every Axon Server deployment to its own storage volumes, and also to a predictable network identity. Kubernetes provides us with a StatefulSet deployment class which does just that.

Using Helm

From a security perspective the presence of the shell can be considered a risk. If this is a problem for you, you should build your own image using the examples provided in the "" GitHub repository.

Several sample YAML descriptors are provided in the "" GitHub repository.

To deploy, you would need a Kubernetes cluster and access to the utility to help control these clusters. For a development Kubernetes cluster, it is recommended to use , , or which installs a Red Hat OpenShift Kubernetes cluster on your laptop. For production, it is recommended to use a managed service like AWS / Google's or Azure's .

Helm (version 3.0 and up) is a very popular tool to install applications in Kubernetes. In the "" GitHub repository we provide an example Helm chart that you can customize to your liking.

Running Axon Server
Running Axon Server
kubectl
Docker for Desktop
minikube
Red Hat CodeReady Containers
EKS
GKE
AKS
Running Axon Server
Deployment using Helm
Axon Server SE image on Docker Hub
Deploying the ready to use Axon Server SE Docker Image
Deployment using Docker Compose
Deployment using Kubernetes