နားလည်ထားရမယ့် အချက်
Elasticsearch ကို local machine ပေါ်တွင် native install လုပ်ရင် JVM version, memory settings, OS-level file descriptor limits စတာတွေကို manually ချိန်ရတတ်လို့ learner တိုင်းအတွက် environment ကွာနိုင်ပါတယ်—Docker container သုံးရင်တော့ image တစ်ခုတည်းက learner အားလုံးကို environment တူညီစေပါတယ်။ Elasticsearch container ကို run တဲ့အခါ single-node development mode (security disabled, `discovery.type=single-node`) နဲ့ run ရလေ့ရှိပြီး ဒါက production cluster setup နဲ့ တော်တော်ကွာပါတယ်—production မှာတော့ multi-node cluster၊ TLS၊ authentication လိုအပ်ပါတယ်။ Container စတင်ပြီးတာနဲ့ Elasticsearch က ချက်ချင်း ready မဖြစ်သေးပါဘူး—JVM startup, index initialization အတွက် စက္ကန့်အနည်းငယ်ကြာနိုင်လို့ readiness ကို polling စစ်ရပါတယ်။ `GET /_cluster/health` ဆိုတဲ့ endpoint က cluster ရဲ့ overall status ကို `green` (fully healthy)၊ `yellow` (primary shards ok ပေမယ့် replica မပြည့်စုံ—single-node dev environment မှာ ပုံမှန်ဖြစ်တတ်တယ်)၊ `red` (data တစ်ချို့ unavailable) ဆိုပြီး color-coded အနေနဲ့ ချက်ချင်းပြပေးပါတယ်။ ဒါက car ရဲ့ dashboard warning light (green/yellow/red) နဲ့တူတဲ့ mental model တစ်ခုလို့ တွေးလို့ရပါတယ်—engine light အနီ တောက်နေရင် immediately investigate ရမယ့်နည်းတူ cluster health red ဖြစ်နေရင် data availability ပြဿနာရှိနေတယ်ဆိုတာ ချက်ချင်းသတိပြုရပါမယ်။
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
Tutorial Platform search backend ကို local dev environment မှာ prototype လုပ်ဖို့ `docker run` ဖြင့် single-node Elasticsearch ကို port `9200` ပေါ် expose မယ်—team member အားလုံးက image version တစ်ခုတည်းသုံးလို့ "my machine မှာ အလုပ်လုပ်ပေမယ့်" ပြဿနာကို ရှောင်နိုင်ပါတယ်။ Container စလိုက်ပြီးတာနဲ့ `curl` ဖြင့် `GET /_cluster/health` ကို ချက်ချင်းမခေါ်ဘဲ short retry loop တစ်ခု (ဥပမာ 2 စက္ကန့်ခြား 5 ကြိမ်) ထားထားမယ်—Elasticsearch startup မပြီးသေးရင် connection refused error ကို app code ထဲမှာ crash မဖြစ်စေချင်လို့ပါ။ Status `green` သို့ `yellow` ရရင် setup အောင်မြင်တယ်လို့ ယူဆနိုင်ပါတယ်—single node ဖြစ်လို့ replica shard တွေ unassigned ဖြစ်နေနိုင်လို့ `yellow` ကို ဒီ context မှာ ပြဿနာလို့ မယူဆပါ။
အတူတူ စမ်းရေးကြည့်မယ်
docker run --name es-tutorial \
-p 127.0.0.1:9200:9200 \
-e "discovery.type=single-node" \
-e "xpack.security.enabled=false" \
-e "ES_JAVA_OPTS=-Xms512m -Xmx512m" \
-d docker.elastic.co/elasticsearch/elasticsearch:8.15.0
# wait a few seconds for startup, then check health
curl -s http://localhost:9200/_cluster/health?pretty`status` field "green" (သို့) "yellow" ပါသော JSON cluster health response ရမည်။၅ မိနစ် စမ်းကြည့်
Container ကို stop/start ပြန်လုပ်ပြီး `GET /_cluster/health` ကို ချက်ချင်းခေါ်ကြည့်ပါ—ဘယ်လောက်ကြာမှ `green`/`yellow` ပြန်ဖြစ်လဲ observe လုပ်ပြီး retry loop တစ်ခု pseudocode ရေးပါ။
သတိလေးတစ်ချက်
`xpack.security.enabled=false` ဖြင့် run ထားတဲ့ dev container ကို production ကလိုစိတ်ချရသလို public network ပေါ်ဖွင့်ထားခြင်း—security disable ထားတာက local learning purpose အတွက်ပဲ ဖြစ်ရပါမယ်။
Container start ပြီးလို့ ချက်ချင်း `PUT`/index creation request ပို့ပြီး connection error ကို app bug လို့ထင်ခြင်း—Elasticsearch startup မပြီးသေးတဲ့ race condition ကို retry logic ဖြင့်သာ ဖြေရှင်းရမယ်။