请用dokcer-compose写出xxljob集群详细配置
时间: 2023-08-22 10:04:32 浏览: 96
docker-compose部署xxl-job方案.rar
好的,下面是一个简单的xxljob集群的docker-compose.yml配置文件:
```yaml
version: '3'
services:
# xxl-job-admin
admin:
image: xxl-job-admin:2.2.0
container_name: xxl-job-admin
restart: always
ports:
- 8080:8080
environment:
- PARAMS="-Xms512m -Xmx512m -Dspring.datasource.url=jdbc:mysql://mysql:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false -Dspring.datasource.username=root -Dspring.datasource.password=123456 -Dspring.datasource.driver-class-name=com.mysql.jdbc.Driver -Dxxl.job.admin.address=http://admin:8080/xxl-job-admin"
depends_on:
- mysql
networks:
- xxl-job-network
# xxl-job-executor
executor:
image: xxl-job-executor:2.2.0
container_name: xxl-job-executor
restart: always
volumes:
- ./xxl-job/executor/conf:/app/xxl-job/executor/conf
environment:
- PARAMS="-Xms512m -Xmx512m -Dspring.datasource.url=jdbc:mysql://mysql:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false -Dspring.datasource.username=root -Dspring.datasource.password=123456 -Dspring.datasource.driver-class-name=com.mysql.jdbc.Driver -Dxxl.job.admin.address=http://admin:8080/xxl-job-admin"
- SERVER_PORT=9999
- XXL_JOB_EXECUTOR_IP=executor
depends_on:
- admin
networks:
- xxl-job-network
# mysql
mysql:
image: mysql:5.7
container_name: mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=123456
- MYSQL_DATABASE=xxl_job
- MYSQL_USER=xxl_job
- MYSQL_PASSWORD=123456
volumes:
- ./mysql/data:/var/lib/mysql
ports:
- 3306:3306
networks:
- xxl-job-network
networks:
xxl-job-network:
driver: bridge
```
上面配置文件中,我们定义了三个服务:xxl-job-admin、xxl-job-executor和mysql。其中,xxl-job-admin和xxl-job-executor分别是xxl-job的管理端和执行端,而mysql则是用来存储xxl-job的任务和日志信息的数据库。
在这个配置文件中,我们使用了docker-compose的网络功能,将三个服务都连接在了一个名为xxl-job-network的网络中,以方便它们之间的通信。
在启动这个集群之前,需要先将xxl-job的相关配置文件(如application.properties)放到xxl-job/executor/conf目录下,并根据实际情况修改其中的配置项。启动方式为在docker-compose.yml文件所在目录下执行docker-compose up -d命令即可。
阅读全文