21.systemd进程管理
救援模式
前提:虚拟机设置已经挂载iso镜像
MBR引导被破坏怎么解决?
1  | #注:仅演示救援模式清空MBR!!!!!!!!!!!!!  | 
1  | #解决办法  | 
MBR破坏后启动自动跳到这里
进入救援模式前进入BISO,修改优先CD-ROM启动加载
grub菜单误删怎么解决?
1  | #仅做演示删除gruub菜单!!!!!!!!!!!!  | 
解决过程
1  | # 1.获取root环境  | 
grub菜单被删启动界面
同样进入救援模式
系统损坏拷贝文件?
1  | bash-4.2# mkfs.xfs -f /dev/sdc  | 
修改网卡名 了解
1  | biosdevname=0 net.ifnames=0  | 
Systemd 进程管理
1  | systemd即为system daemon守护进程,systemd主要解决上文的问题而诞生,systemd的目标是,为系统的启动和管理提供一套完整的解决方案。  | 
1  | #CentOS6启动  | 
1  | #systemd优势  | 
| 相关配置文件 | CentOS6 | CentOS7 | 
|---|---|---|
| 服务启动脚本 | /etc/init.d/ | /usr/lib/systemd/system/ | 
| 开机启动服务 | /etc/rcN.d/ | /etc/systemd/system/ | 
systemd相关命令
启动重启服务
| System V init(6系统) | systemctl命令(7系统) | 作用 | 
|---|---|---|
| service nginx start  /etc/init.d/nginx start  | 
systemctl start nginx.service | 启动服务 | 
| service nginx stop  /etc/init.d/nginx stop  | 
systemctl stop nginx.service | 停止服务 | 
| service nginx restart  /etc/init.d/nginx restart  | 
systemctl restart nginx.service | 重启服务 | 
| service nginx reload  /etc/init.d/nginx reload  | 
systemctl reload nginx.service | 重新加载配置(不终止服务) | 
| service nginx status  /etc/init.d/nginx status  | 
systemctl status nginx.servre | 查看服务运行状态 | 
| systemctl is-active sshd.service | 查看服务是否在运行中 | |
| systemctl mask nginx.servre | 禁止服务运行 | |
| systemctl unmask nginx.servre | 取消禁止服务运行 | 
设置服务开机自启,查看各级别下服务启动状态
| System V init(6系 统) | systemctl命令(7系统) | 作用 | 
|---|---|---|
| chkconfig nginx on | systemctl enable nginx.service | 开机自动启动 | 
| chkconfig nginx off | systemctl disable nginx.service | 开机不自动启动 | 
| chkconfig --list | systemctl list-unit-files | 查看各个级别下服务的启动与禁 用 | 
| chkconfig --list nginx | systemctl is-enabled nginx.service | 查看特定服务是否为开机自启动 | 
| chkconfig–add nginx | systemctl daemon-reload | 创建新服务文件或者变更设置 | 
1  | 设置开机自启相当于给启动脚本做个软链接  | 
systemctl服务状态说明
| 服务状态 | 状态说明 | 
|---|---|
| loaded | 服务单元的配置文件已经被处理 | 
| active(running) | 服务的一个或多个进程在运行中 | 
| active(exited) | 一次性运行的服务成功被执行并退出(服务运行后完成任务,相关进程会自动退出) | 
| active(waiting) | 服务已经运行但在等待某个事件 | 
| inactive | 服务没有在运行 | 
| enable | 服务设定为开机运行 | 
| disabled | 服务设定为开机不运行 | 
| static | 服务不能被设定开机启动,但可以由其他服务启动该服务 | 
 评论











