CentOS 7继承了RHEL 7的新的特性,例如强大的systemctl,而systemctl的使用也使得系统服务的/etc/init.d的启动脚本的方式发生重大改变,也大幅提高了系统服务的运行效率。但服务的配置和以往也发生了极大的不同,变的简单而易用了许多(仁者见仁,米扑博客)。
systemd提供更优秀的框架以表示系统服务间的依赖关系,实现系统初始化时服务的并行启动,同时达到降低Shell的系统开销的效果。
systemd 目标是:尽可能启动更少进程;尽可能将更多进程并行启动,systemd尽可能减少对shell脚本的依赖。
systemd单位类型
systemctl –type=单位类型,用来过滤单位,
例如:systemctl –type=service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
[root@mimvp_usa ~]
# systemctl --type=service
UNIT LOAD ACTIVE SUB DESCRIPTION
aegis.service loaded active running LSB: aegis update.
agentwatch.service loaded active exited SYSV: Starts and stops guest agent
aliyun.service loaded active running auto run aliyunservice or agent
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
getty@tty1.service loaded active running Getty on tty1
httpd.service loaded active running The Apache HTTP Server
kmod-static-nodes.service loaded active exited Create list of required static device nodes
for
the current kernel
lvm2-monitor.service loaded active exited Monitoring of LVM2 mirrors,snapshots etc. using dmeventd or progress
mariadb.service loaded active running MariaDB database server
mongodb.service loaded active running mongodb
network.service loaded active exited LSB: Bring up
/down
networking
nscd.service loaded active running Name Service Cache Daemon
ntpd.service loaded active running Network Time Service
polkit.service loaded active running Authorization Manager
rc-
local
.service loaded active exited
/etc/rc
.d
/rc
.
Compatibility
|
[Unit]
Description=mongodb
After=auditd.service systemd-user-sessions.service
time
-
sync
.target network.target
[Service]
Type=forking
PIDFile=
/var/run/mongodb/mongod
.pid
ExecStart=
/root/script/mongo_server_start
.sh
ExecStop=
/root/script/mongo_server_stop
.sh
PrivateTmp=
true
[Install]
WantedBy=multi-user.target
|
@H_404_172@
● mongodb.service - mongodb
Loaded: loaded (
/usr/lib/systemd/system/mongodb
.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2016-06-15 19:05:41 CST; 2min 24s ago
Process: 1143 ExecStop=
.sh (code=exited,status=1
/FAILURE
)
Process: 1158 ExecStart=
/SUCCESS
)
Main PID: 1161 (mongod)
CGroup:
/system
.slice
/mongodb
.service
└─1161
/usr/bin/mongod
-f
/etc/mongod
.conf
Jun 15 19:05:41 mimvp_usa systemd[1]: Starting mongodb...
Jun 15 19:05:41 mimvp_usa mongo_server_start.sh[1158]: about to fork child process,waiting
until
server is ready
con...ions.
Jun 15 19:05:41 mimvp_usa mongo_server_start.sh[1158]: forked process: 1161
Jun 15 19:05:41 mimvp_usa mongo_server_start.sh[1158]: child process started successfully,parent exiting
Jun 15 19:05:41 mimvp_usa systemd[1]: Started mongodb.
Hint: Some lines were ellipsized,use -l to show
in
full.
|
@H_404_172@