Thuta Learning
ရှာဖွေရန်
AdvancedDevOps & Toolsbeginner

systemd & Services (systemctl)

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • systemd & Services (systemctl) ကို ကြောက်စရာမလိုအောင် နားလည်မယ်
  • Terminal ထဲမှာ ကိုယ်တိုင် command ကို စမ်းသုံးတတ်အောင် လုပ်မယ်
  • Real server/project မှာ ဒီ command ဘယ်လို အသုံးဝင်သလဲ ချိတ်မြင်မယ်

ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်

systemd ဆိုတာ modern Linux distro (Ubuntu, Debian, Fedora) အများစုမှာ default အဖြစ် run နေတဲ့ 'init system' ပါ — computer ဖွင့်တာနဲ့ ပထမဆုံး run ပြီး service (background program) အားလုံးကို boot up, monitor, restart လုပ်ပေးတဲ့ 'orchestra conductor' လို အခန်းကဏ္ဍပါ။ Service တစ်ခုကို systemctl command နဲ့ ထိန်းချုပ်ပါတယ် — systemctl start <service> (စ), systemctl stop <service> (ရပ်), systemctl restart <service> (ပြန်စ), systemctl status <service> (အခြေအနေ ကြည့်)။ systemctl enable <service> ကတော့ 'boot တိုင်း auto-start' ဖြစ်စေတာပါ, enable ရုံနဲ့ ချက်ချင်း start မဖြစ်သေးပါဘူး — start ကို သီးသန့် run ရပါမယ်။

လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်

Nginx web server install လုပ်ပြီးရင် sudo systemctl start nginx ဖြင့် စတင်ပြီး sudo systemctl enable nginx ဖြင့် server restart ဖြစ်ရင်တောင် auto-start ဖြစ်အောင် သတ်မှတ်ထားပါတယ် — ဒီနှစ်ခု ခွဲခြားထားရင် 'server restart ပြီးရင် website ပျောက်သွားတယ်' ဆိုတဲ့ common beginner mistake ကို ရှောင်နိုင်ပါတယ်။ sudo systemctl status nginx က service run နေလား၊ error log ဘာတွေ ရှိလား ချက်ချင်းပြပါတယ် — troubleshooting လုပ်တဲ့အခါ ပထမဆုံး run ရမယ့် command ပါ။

အတူတူ terminal ထဲ စမ်းမယ်

bash
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl status nginx
sudo systemctl restart nginx
sudo systemctl stop nginx
You should see
systemctl status nginx ကို run ရင် 'active (running)' စကားလုံးအစိမ်းရောင် highlight ဖြင့် ပေါ်လာမည်။

၅ မိနစ် စမ်းကြည့်

systemctl status ssh (သို့) systemctl status cron ကို run ကြည့်ပါ (install ရှိတဲ့ system မှာ)။ Active လား inactive လား ရေးပါ။

သတိလေးတစ်ချက်

systemctl stop ကို production server ပေါ်က critical service (database, web server) ပေါ်မှာ run ရင် user တွေ ချက်ချင်း website ကို access မရနိုင်တော့ပါဘူး — service ဘယ်ဟာလဲ double-check လုပ်ပြီးမှ run ပါ။

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • enable ကို run ရင် service ချက်ချင်း start ဖြစ်သွားတယ်လို့ ထင်ခြင်း — enable = auto-start setup ပဲ, start ကို သီးခြားလုပ်ရမည်
  • systemctl status ရဲ့ output ကို လုံးဝမဖတ်ဘဲ 'active' စာသားပဲ ရှာကြည့်ပြီး error log ကို လျစ်လျူရှုခြင်း

အခု ကိုယ်တိုင် စမ်းကြည့်

systemctl status ssh (သို့) systemctl status cron ကို run ကြည့်ပါ (install ရှိတဲ့ system မှာ)။ Active လား inactive လား ရေးပါ။

You'll know it worked when: systemctl status nginx ကို run ရင် 'active (running)' စကားလုံးအစိမ်းရောင် highlight ဖြင့် ပေါ်လာမည်။

systemd & Services (systemctl) | Thuta Learning