• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

系统管理之系统启动过程【显哥出品,必为精品】

运维基础 lixian 4年前 (2020-01-09) 20975次浏览 0个评论 扫描二维码
文章目录[隐藏]

1、系统启动的过程

①:按电源
②:BIOS自检,硬件检测
③:MBR引导
④:进入GRUB菜单,这里进入的单用户模式或者救援模式
⑤:加载内核
⑥:运行系统进程,使用system管理
⑦:读取系统运行级别   /etc/systemd/system/default.target
⑧:初始化系统   /usr/lib/systemd/system/sysinit.target
⑨:启动开机自启动服务(并行启动)   /usr/lib/systemd/system/*
⑩:运行getty文件,进入登录页面    /usr/lib/systemd/system/getty.target

centos 6和centos 7启动对比

centos 6     centos 7
串行启动    并行启动
启动速度慢    启动速度快
容易启动异常    不会启动异常
init进程管理    system管理

2、运行级别

[root@lixian ~]# ll /usr/lib/systemd/system/runlevel*.target
/usr/lib/systemd/system/runlevel0.target -> poweroff.target
/usr/lib/systemd/system/runlevel1.target -> rescue.target
/usr/lib/systemd/system/runlevel2.target -> multi-user.target
/usr/lib/systemd/system/runlevel3.target -> multi-user.target
/usr/lib/systemd/system/runlevel4.target -> multi-user.target
/usr/lib/systemd/system/runlevel5.target -> graphical.target
/usr/lib/systemd/system/runlevel6.target -> reboot.target

runlevel0.target -> poweroff.target :关机
runlevel1.target -> rescue.target :单用户模式,修改root用户密码
runlevel2.target -> multi-user.target:多用户模式
runlevel3.target -> multi-user.target:多用户模式
runlevel4.target -> multi-user.target:多用户模式
runlevel5.target -> graphical.target :桌面模式
runlevel6.target -> reboot.target :重启模式

显示当前系统的运行级别
systemctl get-default
设置运行级别
systemctl set-default runlevel3.target

3、systemd

systemd(system daemon)是解决系统启动跟系统管理的一种解决方案
1、采取并行启动
2、system管理,不在init.d的脚本
3、只关闭正在运行的进程,centos-6是所有的进程关闭
4、支持快照
5、关闭进程时,会关闭所有的相关进程

system相关的目录
/usr/lib/systemd/system/*   #所有系统开机自启动的服务列表目录
/etc/systemd/system/    #系统主要配置目录
/run/systemd/system/     #系统运行过程中产生的临时程序

systemctl系统管理命令
systemctl start nginx     #启动
systemctl status nginx     #显示启动状态
systemctl stop nginx     #关闭
systemctl restart nginx     #重启
systemctl reload nginx     #平滑重启
systemctl mask nginx     #禁用这个服务
systemctl unmask nginx    #解除禁用
systemctl enable nginx     #加入开机自启动
systemctl disable nginx    #取消开机自启动

使用systemtcl status 服务时的状态
loaded     #程序已经完成一次加载
active(running)    #服务正在运行状态
active(exited)    #程序没有在运行,系统已经完成一次完整的启动退出
active(waiting)    #程序已经完成一次加载,但是需要等待某个事件
inactive     #没有运行
enable     #开机自启动
disable     #没有加入开启自启动
static     #无法被系统管理
failed     #配置文件错误

显示当前系统运行级别所有服务的启动状态
systemctl list-unit-files

系统日志

/var/log/messages     #查看系统日志
journalctl -n 20     #显示系统重要的日志,最后20行内容
journalctl -f     #实时显示系统日志输出
journalctl -p err     #按照日志级别进行显示
journalctl -u sshd     #显示指定的服务的日志
journalctl -xe     #到达对应的服务的错误位置

系统主机名的配置

hostname
[root@lixian ~]# hostnamectl
Static hostname: lixian
Icon name: computer-vm
Chassis: vm
Machine ID: 2a5b570068634bc4968a0c33163dcc23
Boot ID: feba7b783ac14fd3bf42e6e0314bd9bb
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-957.el7.x86_64
Architecture: x86-64

永久修改主机名:

/etc/hostname    #主机名的配置文件
hostnamectl set-hostname lixian

系统的字符集

echo $LANG         #显示当前系统的字符集
export LANG=zh_CN.UTF-8     #临时修改,重新登录失效
/etc/locale.conf         #字符集配置文件
localectl set-locale LANG=zh_CN.UTF-8 #永久修改,重新登录生效


本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:系统管理之系统启动过程【显哥出品,必为精品】
喜欢 (35)

您必须 登录 才能发表评论!