学習MSA(3)-発見サービス
Service Discovery
1.Eureka Serverプロジェクトの作成
2.デフォルトサーバー設定(アプリケーション.yml)
server:
port: 8761
spring:
application:
name: discovery-service
eureka:
client:
register-with-eureka: false
fetch-registry: false
# 개발시 false 운영시 true
server:
enable-self-preservation: false
eviction-interval-timer-in-ms: 3000 #하트비트 수신점검
@EnableEurekaServer操作を追加して実行3.サーバーの実行を検証する
4.Eurekaクライアントプロジェクトの作成
5.クライアント設定(アプリケーション.yml)
server:
port: 9001
spring:
application:
name: user-service
eureka:
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://127.0.0.1:8761/eureka
6.アプリケーションの実行
@EnableDiscorveryClientアクションの追加と実行
7.サーバWebリフレッシュ後のチェックサービス
8.ランダムポートのport:0を変更し、instance idを設定する
server:
port: 0
spring:
application:
name: user-service
eureka:
instance:
instance-id: ${spring.cloud.client.hostname}:${spring.application.instance_id:${random.value}}
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://127.0.0.1:8761/eureka
9.アプリケーションを起動し、mvn spring-boot:runを入力して、インスタンスが同時に実行された後にインスタンスを検証します。
10.mysql、JPA、Eurekaクライアント時のyml
server:
port: 0
spring:
application:
name: product-service
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
password: 1234
url: jdbc:mysql://localhost:3306/product-service?useSSL=false&characterEncoding=UTF-8&serverTimezone=UTC
username: root
jpa:
database: mysql
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
generate-ddl: true
show-sql: true
hibernate:
ddl-auto: update
properties:
hibernate:
format_sql: true
eureka:
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://127.0.0.1:8761/eureka
instance:
instance-id: ${spring.cloud.client.hostname}:${spring.application.instance_id:${random.value}}
# 운영시 삭제
lease-renewal-interval-in-seconds: 1 # 디스커버리한테 1초마다 하트비트 전송 (기본 30초)
lease-expiration-duration-in-seconds: 2 # 디스커버리는 서비스 등록 해제 하기 전에 마지막 하트비트에서부터 2초 기다림
Reference
この問題について(学習MSA(3)-発見サービス), 我々は、より多くの情報をここで見つけました https://velog.io/@wnsdud2336/MSA-학습3-Service-discovery-프로젝트-생성テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol