前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >RHEL7、CentOS7的服务管理-系统管理(4)

RHEL7、CentOS7的服务管理-系统管理(4)

作者头像
耕耘实录
发布2018-12-20 12:02:07
5710
发布2018-12-20 12:02:07
举报
文章被收录于专栏:耕耘实录耕耘实录

从RHEL7的官方文档中我们,可以看出在未来service和chkconfig可能会退出历史舞台,现在的发行版中还保留这些命令最主的原因是考虑了兼容性,在使用中我们应该逐步放弃这些命令。 目前可用的systemd单元类型

这里写图片描述
这里写图片描述

systemd单元文件位置

这里写图片描述
这里写图片描述

service命令和systemctl命令的一些功能对照表

这里写图片描述
这里写图片描述

chkconfig命令和systemctl命令的一些功能对照表

这里写图片描述
这里写图片描述

停止指定服务单元:

代码语言:javascript
复制
[root@Geeklp-Administrator Geeklp]# systemctl stop firewalld.service

文件扩展可能会被遗忘,被遗忘文件扩展的命令与上述等价:

代码语言:javascript
复制
[root@Geeklp-Administrator Geeklp]# systemctl stop firewalld

显示服务状态:

代码语言:javascript
复制
[root@Geeklp-Administrator Geeklp]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since 五 2017-12-22 15:20:01 CST; 24min ago
     Docs: man:firewalld(1)
  Process: 1742 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 1742 (code=exited, status=0/SUCCESS)
12月 22 15:19:44 Geeklp-Administrator systemd[1]: Starting firewalld - dynamic firewall daemon...

从上面的屏幕输出信息中我们可以看到一些诸如Loaded的关键字,这些被称之为服务单元信息。目前可用的服务单元信息有:

这里写图片描述
这里写图片描述

启动服务:systemctl start name.service 停止服务:systemctl stop name.service 重启服务:systemctl restart name.service 重载服务:systemctl reload name.service 重点提一下重载服务。某些系统允许不中断执行来重载配置,例如:httpd。systemctl命令也支持reload-or-restart 和 reload-or-try-restart来重启服务。 开机启动:systemctl enable name.service 重新创建开机启动:systemctl reenable name.service 设置开机启动的路径为:/usr/lib/systemd/system/name.service,如果已经设置了开机启动,需要重新创建开机启动服务才用此命令。 禁止开机启动:systemctl disable name.service 当执行这个命令时,从/etc/systemd/system及子目录到/usr/lib/systemd/system/name.service的符号链接会被移除。

代码语言:javascript
复制
[root@Geeklp-Administrator system]# systemctl enable vsftpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
[root@Geeklp-Administrator multi-user.target.wants]# systemctl disable vsftpd.service
Removed symlink /etc/systemd/system/multi-user.target.wants/vsftpd.service.
[root@Geeklp-Administrator multi-user.target.wants]# ll
total 0
lrwxrwxrwx. 1 root root 38 12月 25 14:50 vsftpd.service -> /usr/lib/systemd/system/vsftpd.service

屏蔽服务:systemctl mask name.service 这个命令使用之后会将/etc/systemd/system/name.service链接到/dev/null,这样实际操作信息就传达不到systemd,从而实现对服务的屏蔽。

代码语言:javascript
复制
[root@Geeklp-Administrator ~]# systemctl mask vsftpd
Created symlink from /etc/systemd/system/vsftpd.service to /dev/null.
[root@Geeklp-Administrator ~]# systemctl status vsftpd
● vsftpd.service
   Loaded: masked (/dev/null; bad)
   Active: inactive (dead)
12月 25 14:26:33 Geeklp-Administrator systemd[1]: Started Vsftpd ftp daemon.
12月 25 14:26:42 Geeklp-Administrator systemd[1]: Stopping Vsftpd ftp daemon...
[root@Geeklp-Administrator ~]# systemctl start vsftpd
Failed to start vsftpd.service: Unit is masked.

取消屏蔽:systemctl unmask name.service 待续………

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017年12月22日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档