如何在RHEL7管理systemd units

作   者:林國龍 精誠資訊 恆逸教育訓練中心 資深講師
技術分類:網路管理與通訊應用

傳統的RHEL系統(RHEL6含之前版本),長期以來使用init做為第一個Process,以便管理與啟動系統的其他服務。RHEL7改用了systemd,直接影響的就是開機作業方式與服務啟動關閉的作法,本文簡單介紹systemd架構下,管理服務的方式。

在systemd架構下,被管理的系統物件稱為”unit”,系統上執行的服務只是unit中的一種。systemctl指令用來管理unit。為了讓熟悉舊系統的管理員可以快速了解systemctl用法,下表整理了新舊版本的管理指令差異,以管理httpd為例:

功能 RHEL6(含之前版本) RHEL7
開機後自動啟動httpd服務 chkconfig httpd on systemctl enable httpd.service
開機後不啟動httpd服務 chkconfig httpd off systemctl disable httpd.service
檢查httpd下次啟動時的預設狀態 chkconfig –list httpd systemctl list-unit-files | grep httpd
systemctl is-enabled httpd.service
檢查服務狀態 service httpd status systemctl status httpd.service
立即啟動httpd服務 service httpd start systemctl start httpd.service
立即停止httpd服務 service httpd stop systemctl stop httpd.service
立即重新啟動httpd服務 service httpd restart systemctl restart httpd.service

透過上述表格的整理,希望讓剛接觸RHEL7的朋友可以在管理新舊系統時做為一個參考。

 

Share |
您可在下列課程中了解更多RHEL7管理技巧喔!
相關學習資源︰

【RHCE】Red Hat紅帽RHCE認證課程