اكتشاف الخدمات
اكتشاف الخدمات (Service Discovery) باستخدام Eureka
10-15 دقيقة
اكتشاف الخدمات (Service Discovery) باستخدام Eureka
يُعدّ اكتشاف الخدمات مكوّنًا أساسيًا في بنية الخدمات المصغّرة. ويتيح Netflix Eureka إدارة تسجيل الخدمات واكتشافها بطريقة فعّالة.
1. إعداد خادم Eureka
1.1 إنشاء المشروع
curl https://start.spring.io/starter.tgz \
-d dependencies=cloud-eureka-server \
-d groupId=com.example \
-d artifactId=eureka-server \
-d name=eureka-server \
-d description=Eureka%20Server%20for%20Microservices \
-d packageName=com.example.eureka \
-d packaging=jar \
-d javaVersion=17 \
| tar -xzvf -
1.2 إعداد الخادم
# application.yml
server:
port: 8761
spring:
application:
name: eureka-server
eureka:
instance:
hostname: localhost
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
1.3 إعداد التوافر العالي
# application-peer1.yml
spring:
application:
name: eureka-server
profiles: peer1
server:
port: 8761
eureka:
instance:
hostname: peer1
client:
service-url:
defaultZone: http://peer2:8762/eureka/
---
# application-peer2.yml
spring:
application:
name: eureka-server
profiles: peer2
server:
port: 8762
eureka:
instance:
hostname: peer2
client:
service-url:
defaultZone: http://peer1:8761/eureka/
التعليقات
التعليقات مدعومة عبر GitHub Discussions
سجّل الدخول باستخدام GitHub للمشاركة في النقاش