Centos 配置開機啓動項

  Linux system  部署新的服務,初次啓動服務都是通過command的方式手工啓動,時間久了之後重啓系統或有別的人員維護系統【不熟悉環境、業務】,可能造成服務未啓動、業務受影響,排查起來維護成本較高,且影響業務連續性。因此,設置新增業務爲開機啓動,顯得十分必要,作者本身也是深有體會。本文着重介紹,如何爲新增服務設置開啓啓動。

設置開機啓動方式一

#ntsysv 【quit 】 =--圖形界面查看、設置開機啓動項

快捷鍵
CTRL+V 下翻
空格鍵 選中
tab
quit 命令退出圖形界面

Centos  配置開機啓動項

設置開機啓動方式二

#chkconfig --list ----chkconfig 類似 MSConfig

Centos  配置開機啓動項

Linux System Mode

Linux一般會有7個Mode(可由init N來切換,init0爲關機,init 6爲重啓系統)
0 - 停機
1 - 單用戶模式
2 - 多用戶,但是沒有NFS ,不能使用網絡
3 - 完全多用戶模式
4 - 打醬油的,沒有用到
5 - X11 圖形化登錄的多用戶模式
6 - 重新啓動 (如果將默認啓動模式設置爲6,Linux將會不斷重啓)

Chkconfig 語法格式

     chkconfig --add <name>
     chkconfig --del <name>
     chkconfig [--level <levels>] <name> <on|off|reset|resetpriorities>

配置示例:

設置IPtables開機啓動或關閉

---注意一下linux有5個啓動模式,分別對應不同的權限

chkconfig --list | grep iptables

iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off

#chkconfig iptables --level 3 off/on ----給3打開或關閉開啓啓動

chkconfig --list | grep iptables

iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off

chkconfig iptables off

chkconfig --list | grep iptables

iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off

Linux服務器,服務管理--systemctl命令詳解,設置開機自啓動
syetemclt就是service和chkconfig這兩個命令的整合,在CentOS 7就開始被使用了。
摘要: systemctl 是系統服務管理器命令,它實際上將 service 和 chkconfig 這兩個命令組合到一起。

任務 舊指令 新指令

使某服務自動啓動 chkconfig --level 3 httpd on systemctl enable httpd.service
使某服務不自動啓動 chkconfig --level 3 httpd off systemctl disable httpd.service
檢查服務狀態 service httpd status systemctl status httpd.service (服務詳細信息) systemctl is-active httpd.service (僅顯示是否 Active)
顯示所有已啓動的服務 chkconfig --list systemctl list-units --type=service
啓動某服務 service httpd start systemctl start httpd.service
停止某服務 service httpd stop systemctl stop httpd.service
重啓某服務 service httpd restart systemctl restart httpd.service

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章