centos 7 开机启动服务项优化
1.
使用 systemctl list-unit-files 可以查看启动项
systemctl list-unit-files | grep enable 过滤查看启动项如下
abrt-ccpp.service enabled abrt为auto bug report的缩写 用于bug报告 关闭
abrt-oops.service enabled ----------------------
abrt-vmcore.service enabled ----------------------
abrt-xorg.service enabled ----------------------
abrtd.service enabled ----------------------
auditd.service enabled 安全审计 保留
autovt@.service enabled 登陆相关 保留
crond.service enabled 定时任务 保留
dbus-org.freedesktop.NetworkManager.service enabled 桌面网卡管理 关闭
dbus-org.freedesktop.nm-dispatcher.service enabled ----------------------
getty@.service enabled tty控制台相关 保留
irqbalance.service enabled 优化系统中断分配 保留
kdump.service enabled 内核崩溃信息捕获 自定
microcode.service enabled 处理器稳定性增强 保留
NetworkManager-dispatcher.service enabled 网卡守护进程 关闭
NetworkManager.service enabled ----------------------
postfix.service enabled 邮件服务 关闭
rsyslog.service enabled 日志服务 保留
snmpd.service enabled snmp监控 数据抓取 保留
sshd.service enabled ssh登陆 保留
systemd-readahead-collect.service enabled 内核调用--预读取 保留
systemd-readahead-drop.service enabled ----------------------
systemd-readahead-replay.service enabled ----------------------
tuned.service enabled
default.target enabled 默认启动项 multi-user.target的软连接 保留
multi-user.target enabled 启动用户命令环境 保留
remote-fs.target enabled 集合远程文件挂载点 自定
runlevel2.target enabled 运行级别 用于兼容6的SysV 保留
runlevel3.target enabled ----------------------
runlevel4.target enabled ----------------------
关闭一下开机启动服务
systemctl disable abrt-ccpp.service
systemctl disable abrt-oops.service
systemctl disable abrt-vmcore.service
systemctl disable abrt-xorg.service
systemctl disable abrtd.service
systemctl disable accounts-daemon.service
systemctl disable atd.service
systemctl disable auditd.service
systemctl disable autovt@.service
systemctl disable avahi-daemon.service
systemctl disable bluetooth.service
systemctl disable cups.service
systemctl disable dbus-org.bluez.service
systemctl disable dbus-org.fedoraproject.FirewallD1.service
systemctl disable dbus-org.freedesktop.Avahi.service
systemctl disable dbus-org.freedesktop.ModemManager1.service
systemctl disable dbus-org.freedesktop.NetworkManager.service
systemctl disable dbus-org.freedesktop.nm-dispatcher.service
systemctl disable display-manager.service
systemctl disable dmraid-activation.service
systemctl disable firewalld.service
systemctl disable gdm.service
systemctl disable irqbalance.service
systemctl disable iscsi.service
systemctl disable ksm.service
systemctl disable ksmtuned.service
systemctl disable libstoragemgmt.service
systemctl disable libvirtd.service
systemctl disable lvm2-monitor.service
systemctl disable mcelog.service
systemctl disable mdmonitor.service
systemctl disable microcode.service
systemctl disable ModemManager.service
systemctl disable multipathd.service
systemctl disable NetworkManager-dispatcher.service
systemctl disable NetworkManager.service
systemctl disable postfix.service
systemctl disable qemu-guest-agent.service
systemctl disable rngd.service
systemctl disable rtkit-daemon.service
systemctl disable smartd.service
systemctl disable spice-vdagentd.service
systemctl disable systemd-readahead-collect.service
systemctl disable systemd-readahead-drop.service
systemctl disable systemd-readahead-replay.service
systemctl disable tuned.service
systemctl disable vgauthd.service
systemctl disable vmtoolsd.service
2.systemctl 用法:
显示服务状态:systemctl status docker.service
列出服务层级和依赖关系:systemctl list-dependencies docker.service
启动服务:systemctl start docker.service
关闭服务:systemctl stop docker.service
重启服务:systemctl restart docker.service
设置服务自启动:systemctl enable docker.service
禁止服务自启动:systemctl disable docker.service
查看服务是否自启动:systemctl is-enabled docker.service
列出系统所有服务的启动情况:systemctl list-units --type=service
列出所有自启动服务:systemctl list-unit-files|grep enabled
对应的旧指令(chkconfig、service)
显示服务状态:service docker status
列出服务层级和依赖关系:systemctl list-dependencies docker.service
启动服务:service docker start
关闭服务:service docker stop
重启服务:service docker restart
设置服务自启动:chkconfig --level 3 docker on
禁止服务自启动:chkconfig --level 3 docker off
查看服务是否自启动:chkconfig --list docker
列出系统所有服务的启动情况:chkconfig --list