تخصيص الأجزاء وإعادة موازنتها
افهم كيف يقرر Elasticsearch أماكن الأجزاء، وكيف يوزّع وعي التخصيص النسخ المتماثلة عبر العتاد، وكيف تتحكم في إعادة الموازنة أثناء التوسّع والصيانة.
تخصيص الأجزاء وإعادة موازنتها درس مجاني في Elasticsearch & Full Text Search Systems على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Elasticsearch & Full Text Search Systems، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Elasticsearch & Full Text Search Systems 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Where Do Shards Go?
When you create an index or add a node, Elasticsearch must decide which node holds each shard. This process is shard allocation, and keeping it balanced is key to a healthy, performant cluster.
The Allocation Process
The master node runs allocation deciders for every unassigned shard. They check disk space, shard count, awareness rules, and filters before placing a shard. Failing any decider keeps the shard UNASSIGNED.
Primary vs Replica Placement
A replica is never allocated to the same node as its primary. This guarantees that losing one node cannot take out both copies of the same data. With one replica you survive any single-node failure.
Watching Allocation
Use the _cat/shards API to see where each shard sits and its state. STARTED means active; RELOCATING means it is moving.
GET _cat/shards?vExplaining a Stuck Shard
When a shard will not allocate, the _cluster/allocation/explain API tells you exactly which decider blocked it and why. This is the first stop for debugging a yellow or red cluster.
GET _cluster/allocation/explain
{
"index": "my_index",
"shard": 0,
"primary": false
}Allocation Awareness
Allocation awareness spreads copies across physical boundaries like racks or availability zones. You tag nodes with custom attributes and tell the cluster to be aware of them.
cluster.routing.allocation.awareness.attributes: zoneForced Awareness
Forced awareness goes further: it refuses to over-allocate replicas to surviving zones if a zone goes down, preventing one zone from holding all copies. This protects capacity planning during outages.
cluster.routing.allocation.awareness.force.zone.values: zone1,zone2Shard Filtering
You can pin or exclude an index from specific nodes using allocation filters. This is handy for hot/warm architectures where older indices migrate to cheaper hardware.
PUT my_index/_settings
{
"index.routing.allocation.require.box_type": "warm"
}Rebalancing
After nodes join or leave, the cluster rebalances to even out shard counts. This is automatic but generates network and disk I/O, so it should be controlled during sensitive operations.
Pausing Allocation
Before a rolling restart, disable allocation so the cluster does not waste effort relocating shards from a node you are about to bring back. Re-enable it afterward.
PUT _cluster/settings
{
"transient": {
"cluster.routing.allocation.enable": "primaries"
}
}Throttling
Limit concurrent recoveries with cluster.routing.allocation.node_concurrent_recoveries and bandwidth with indices.recovery.max_bytes_per_sec to keep rebalancing from starving live queries.
Quick Check
Test your understanding of shard allocation.
Recap
You learned how shards are placed and balanced:
- Allocation deciders choose shard locations; replicas avoid their primary's node.
- Debug stuck shards with
allocation/explain. - Allocation awareness and forced awareness spread copies across zones.
- Use allocation filters for hot/warm tiers and disable allocation during rolling restarts.
الأسئلة الشائعة
هل درس «تخصيص الأجزاء وإعادة موازنتها» مجاني؟
نعم — نص درس «تخصيص الأجزاء وإعادة موازنتها» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Elasticsearch & Full Text Search Systems، انتقل إلى CoddyKit PRO. تتضمن دورة Elasticsearch & Full Text Search Systems 4 دروس في المجموع.
ماذا ستتعلم في «تخصيص الأجزاء وإعادة موازنتها»؟
افهم كيف يقرر Elasticsearch أماكن الأجزاء، وكيف يوزّع وعي التخصيص النسخ المتماثلة عبر العتاد، وكيف تتحكم في إعادة الموازنة أثناء التوسّع والصيانة. تتمرن على Elasticsearch & Full Text Search Systems مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Elasticsearch & Full Text Search Systems؟
لا تُشترط خبرة سابقة. Elasticsearch & Full Text Search Systems على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «تخصيص الأجزاء وإعادة موازنتها»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Elasticsearch & Full Text Search Systems هذا؟
نعم. كل درس في Elasticsearch & Full Text Search Systems يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- شرح التجزئة والنسخ المتماثلة
- سلامة العنقود ومراقبته
- أدوار العقد وبنيتها
- تخصيص الأجزاء وإعادة موازنتها