【发布时间】:2018-06-16 21:14:26
【问题描述】:
我已经使用 mysql 创建了 spring-boot 应用程序和数据库。然后我 Dockerised 并部署了它。下面显示我的 docker-compse.yml
version: '2'
services:
seat_reservation_service:
image: springio/seat_reservation_service
ports:
- "8090:8090"
environment:
- SPRING_PROFILES_ACTIVE=docker
seat_reservation_sql:
image: mysql:5.7
ports:
- 33306:3306
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=seat-reservation-query
这是我的 spring application.yml 文件
server:
port: 8090
spring:
profiles: docker
main:
banner-mode: 'off'
datasource:
url: jdbc:mysql://seat_reservation_sql:3306/seat-reservation-query?useSSL=false
username: root
password: root
validation-query: SELECT 1
test-on-borrow: true
jpa:
show_sql: false
hibernate:
ddl-auto: update
dialect: org.hibernate.dialect.MySQL5
properties:
hibernate:
cache:
use_second_level_cache: false
use_query_cache: false
generate_statistics: false
data:
rest:
base-path: /api/
rabbitmq:
host: rabbitmq-1
username: test
password: password
logging:
level:
org.springframework: false
org.hibernate: ERROR
path: logs/prod/
axon:
amqp:
exchange: SeatReserveEvents
eventhandling:
processors:
statistics.source: statisticsQueue
我的问题是我需要更多来自seat_reservation_service 服务的副本。如果我扩大引用相同数据库的seat_reservation_service。根据微服务架构,每个副本都需要单独的数据库。我怎样才能做到这一点?
如果我在内存数据库中使用它可以做到
【问题讨论】:
-
您能否说明您是否希望通过所有主-主关系横向扩展 MySQL,或者
seat_reservation_service是否可以与只读 MySQL 副本一起使用?在这两种情况下,这都不是一个简单的答案。使用 MySQL(没有 Google Cloud SQL 或 AWS RDS 之类的东西)构建任何自动扩展都不是很简单。
标签: mysql docker spring-boot docker-compose microservices