CentOs7 開(kāi)機(jī)自動(dòng)啟動(dòng)
locator script
file name:geode.service
<code>
[Unit]
Description=geode
[Service]
Type=forking
ExecStart=/yougola/cluster/geode/Pivotal_GemFire_820_b17919_Linux/bin/gfsh start locator --name=locator171 --locators='192.168.0.171[10334],192.168.0.172[10334]' --mcast-port=0 --dir=/yougola/cluster/geode/Pivotal_GemFire_820_b17919_Linux/data --classpath=/yougola/cluster/geode/classes
PrivateTmp=true
[Install]
WantedBy=multi-user.target
</code>
server script
file name:geode.service
<code>
[Unit]
Description=geode
[Service]
Type=forking
ExecStart=/yougola/cluster/geode/Pivotal_GemFire_820_b17919_Linux/bin/gfsh start server --name=server173 --locators='192.168.0.171[10334],192.168.0.172[10334]' --classpath=/yougola/cluster/geode/classes --dir=/yougola/cluster/geode/Pivotal_GemFire_820_b17919_Linux/data --cache-xml-file=/yougola/cluster/geode/Pivotal_GemFire_820_b17919_Linux/defaultConfigs/cache.xml --max-heap=3G --J=-Xmx3G --J=-Xms3G
PrivateTmp=true
[Install]
WantedBy=multi-user.target
</code>
[Unit]:服務(wù)的說(shuō)明
Description:描述服務(wù)After:描述服務(wù)類別
[Service]服務(wù)運(yùn)行參數(shù)的設(shè)置
Type=forking是后臺(tái)運(yùn)行的形式
ExecStart為服務(wù)的具體運(yùn)行命令
ExecReload為重啟命令
ExecStop為停止命令
PrivateTmp=True表示給服務(wù)分配獨(dú)立的臨時(shí)空間
注意:[Service]的啟動(dòng)义桂、重啟权悟、停止命令全部要求使用絕對(duì)路徑
[Install]服務(wù)安裝的相關(guān)設(shè)置,可設(shè)置為多用戶
保存目錄
以754的權(quán)限保存在目錄:
/lib/systemd/system
設(shè)置開(kāi)機(jī)自啟動(dòng)
systemctl enable geode.service
任務(wù)
舊指令
新指令
使某服務(wù)自動(dòng)啟動(dòng)
chkconfig --level 3 httpd on
systemctl enable httpd.service
使某服務(wù)不自動(dòng)啟動(dòng)
chkconfig --level 3 httpd off
systemctl disable httpd.service
檢查服務(wù)狀態(tài)
service httpd status
systemctl status httpd.service (服務(wù)詳細(xì)信息) systemctl is-active httpd.service (僅顯示是否 Active)
顯示所有已啟動(dòng)的服務(wù)
chkconfig --list
systemctl list-units --type=service
啟動(dòng)某服務(wù)
service httpd start
systemctl start httpd.service
停止某服務(wù)
service httpd stop
systemctl stop httpd.service
重啟某服務(wù)
service httpd restart
systemctl restart httpd.service
啟動(dòng)nginx服務(wù)
systemctl start nginx.service
設(shè)置開(kāi)機(jī)自啟動(dòng)
systemctl enable nginx.service
停止開(kāi)機(jī)自啟動(dòng)
systemctl disable nginx.service
查看服務(wù)當(dāng)前狀態(tài)
systemctl status nginx.service
重新啟動(dòng)服務(wù)
systemctl restart nginx.service
查看所有已啟動(dòng)的服務(wù)
systemctl list-units --type=service