【Linux init】systemd 服务单元管理
来源:互联网 发布:恒生期货软件使用方法 编辑:程序博客网 时间:2024/05/21 09:12
系统服务管理systemd Control the systemd system and service manager #控制systemd系统和服务管理
先前的使用SysV初始化或Upstart的红帽企业版Linux版本中,使用位于/etc/rc.d/init.d/目录中的bash初始化脚本进行管理。
在RHEL 7/CentOS 7中,这些启动脚本被服务单元取代了。为了向后兼容,旧的service命令在CentOS 7中仍然可用,它会重定向所有命令到新的systemctl工具。
systemctl有很多控制参数,这里仅列出常用的部分,更多命令请看man systemctl
systemd所管理的程序脚本在/usr/lib/systemd/,而 /etc/systemd/下的都是软连接。操作系统init进程只有systemd这一个。
Created symlink from /etc/systemd/system/multi-user.target.wants/sshd.service to /usr/lib/systemd/system/sshd.service.
先前的使用SysV初始化或Upstart的红帽企业版Linux版本中,使用位于/etc/rc.d/init.d/目录中的bash初始化脚本进行管理。
在RHEL 7/CentOS 7中,这些启动脚本被服务单元取代了。为了向后兼容,旧的service命令在CentOS 7中仍然可用,它会重定向所有命令到新的systemctl工具。
systemctl有很多控制参数,这里仅列出常用的部分,更多命令请看man systemctl
单元命令:systemctl start httpd.service # 启动httpd # service httpd startsystemctl stop httpd.service # 停止httpd # service httpd stopsystemctl status httpd # 查看httpd状态 # service httpd statussystemctl restart httpd.service # 重启httpd # service httpd restartsystemctl try-restart httpd.service # 尝试重启httpd # systemctl reload httpd.service # 重新加载httpd配置文件 #systemctl enable sshd.service # 设置sshd开机启动 # chkconfig –level 3 sshd onsystemctl disable sshd.service # 设置sshd开机不启动 # chkconfig –level 3 sshd offsystemctl list-units --type=service # 列出type为service的所有服务的启动状况 # chkconfig –listsystemctl is-active mariadb # 查询mariadb服务状态 systemctl list-units --state=failed # 查询state为failed的单元systemctl list-units --state=loaded --type=socket # 列出已加载的类型为socket的单元systemctl enable sshd.service --now -f # 设置自启的同时,立即启动sshd服务, 强制创建并覆盖冲突链接systemctl disable sshd.service --now # 设置禁用的同时,立即停止sshd服务systemctl enable mariadb --no-block --no-reload # 异步操作,不等待结果,不重载配置文件systemctl disable mariadb --global # 对全局所有在线用户生效systemctl list-units --plain --no-pager # 分类列出系统单元,直接输出所有结果,不分页systemctl get-default # 获得默认的系统targetsystemctl try-restart mariadb # 尝试重启mariadb,如果mariadb没有启动,则不做任何操作系统命令systemctl is-system-running # running 系统完全可控;degraded 系统可控,但存在单元失败;maintenance 营救模式启动;stopping 管理器停止systemctl suspend #系统挂起systemctl hibernate #系统睡眠systemctl daemon-reload #操作系统所有初始化脚本重载自动启动的原理:Systemctl控制着SysV所管理的程序脚本,由此实现了对SysV的兼容,脚本软连接重定向到chkconfig来管理,系统启动的init进程为Systemctl,
systemd所管理的程序脚本在/usr/lib/systemd/,而 /etc/systemd/下的都是软连接。操作系统init进程只有systemd这一个。
Created symlink from /etc/systemd/system/multi-user.target.wants/sshd.service to /usr/lib/systemd/system/sshd.service.
[dream361@za ~]$ sudo systemctl enable network network.service is not a native service, redirecting to /sbin/chkconfig.Executing /sbin/chkconfig network onnetwork 实际是被chkconfig直接管理,Systemctl通过chkconfig实现了对network的间接管理
0 0
- 【Linux init】systemd 服务单元管理
- [置顶]【Linux init】systemd 服务单元管理
- linux下如何使用systemctl管理systemd服务与单元
- linux下如何使用systemctl管理systemd服务与单元
- Linux-systemd服务管理之一 简介
- systemd 管理服务
- systemd 服务管理
- systemd管理服务
- linux初始化init系统:systemd
- linux第一个用户进程init--systemd
- Linux系统init过程之 Systemd
- Linux 初始化 init 系统3---Systemd
- 浅析 Linux 初始化 init 系统,Systemd
- Linux 初始化 init 系统(Systemd)
- 浅析 Linux 初始化 init 系统 systemd
- systemd命令管理linux系统
- linux任务计划cron、chkconfig工具、systemd管理服务、unit介绍和target介绍讲解
- Linux的Init程序与系统服务管理
- PHP递归遍历目录,递归删除目录及文件
- Cube painting UVA
- 数据库第5天
- 蓝桥 打印图形
- Material Design之RippleDrawable详解
- 【Linux init】systemd 服务单元管理
- 算法导论B树
- Python笔记-类和实例、继承和多态
- Spreadsheet Tracking
- Python爬虫之——爬取妹子图片
- # VMWARE上的 RHEL 7扩展lv
- Ubuntu系统下IPython Notebook的安装和远程访问配置
- Score UVA
- hdu 6020 MG loves apple //bc Round #93 1002