博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
edora core 5 办公环境安装配置,fc5不完全指南(十三)我在飞,加快fc5的启动速度(zt)...
阅读量:2453 次
发布时间:2019-05-10

本文共 9207 字,大约阅读时间需要 30 分钟。

上面的几篇文章是bigboar兄弟推荐的,这篇是bigboar的实验总结,很不错的文章,所以就转了过来!

bigboar兄弟的blog:

http://bigboar.itpub.net/

[@more@]

1)通过本次提速,更熟悉linux系统启动过程,了解系统服务。

2)提速后,启动速度真TM不是一般的快(启动服务减少了 + 部分服务并行启动)
结论:超值!

参考资料:

1)好文转贴:fedora core 启动服务详解
http://bigboar.itpub.net/post/8411/114756
2)好文转贴:过并行化 Linux 系统服务来提高引导速度
http://bigboar.itpub.net/post/8411/114685
3)好文转贴:剖析Linux系统启动的后台全过程
http://bigboar.itpub.net/post/8411/114685

做好准备功夫:
首先,修改系统,备份是一切的根本,把备份工作做好。本次需要备份的就一个/etc/rc.d/rc文件
其次,防止修改错误,一张故障修复盘是必不可少的防备工具,不然修改错误,进不了系统,麻烦就搞大了。
(其实不复杂,我测试了N次,没有一次说是起不来的)

1)系统可启动的服务:/etc/rc.d/init.d目录下的服务都可启动。
2)系统服务功能:在/etc/rc.d/init.d系统服务脚本头部有描述,包括配置文件,有的系统服务还可使用man提供帮助,配置文件及更多用法,可从阅服务启动脚本得知。

为了飞,我要先现做好下面工作:

下面开始:
1,在fc5中,reboot执行了init 6,shutdown执行了init 0。
2,下面以init 3为例,分析我本机的服务(从默认的/etc/rc.d/rc脚本可知,运行init 3时,/etc/rc.d/rc3.d目录下的所有S*都会启动):
[root@bigboar rc3.d]# ls S*
S01sysstat S11auditd S22messagebus S44acpid S95anacron
S04readahead_early S12syslog S25bluetooth S50hplip S95atd
S05kudzu S13irqbalance S25netfs S55cups S95firstboot
S06cpuspeed S13portmap S26apmd S55sshd S98avahi-daemon
S08arptables_jf S14nfslock S26hidd S56xinetd S98cups-config-daemon
S08iptables S15mdmonitor S26lm_sensors S85gpm S98haldaemon
S09isdn S18rpcidmapd S28autofs S90crond S99local
S10network S19rpcgssd S40smartd S90xfs
(本来有个sendmail,被我删了,反正也不要,就不是说了)
1)S01sysstat,Reset the system activity logs,重置日志,要。
2) S04readahead_early,This service causes the programs used during startup to be loaded into memory before they are needed,thus improving startup performance。提前缓存启动时要执行的程序,要。
3)S05kudzu,kudzu detects and configures new and/or changed hardware on a system.硬件变更检查,要。
4)S06cpuspeed,Run dynamic CPU speed daemon,监测系统空闲百分比,在系统空闲时将能源消耗降为最小,而在系统繁忙时最大化加快系统执行速度,要。
5)S08arptables_jf,Automates a packet filtering firewall with arptables.防火墙过滤,要。
6)S08iptables,Starts, stops and saves iptables firewall,防火墙,要。
7)S09isdn,Integrated Services Digital Network,综合数字服务网络。提供对isdn设备的支持。不要。
8)S10network, Activates/Deactivates all network interfaces configured to start at boot time.启动激活网络,要。
9)S11auditd,This starts the Linux Auditing System Daemon,系统审计,不要。
10) S12syslog,Syslog is the facility by which many daemons use to log messages to various system log files. It is a good idea to always run syslog.记录日志的公共模块,要。
11)S13irqbalance, The irqbalance daemon will distribute interrupts across the cpus on a multiprocessor system with the purpose of spreading the load.CPU负载均衡服务,单CPU,肯定不用启,不要。
12) S13portmap,The portmapper manages RPC connections, which are used by protocols such as NFS and NIS. The portmap server must be running on machines which act as servers for protocols which make use of the RPC mechanism.守护程序为RPC服务,如NIS和NFS提供动态端口的分配。在需要的时候再启动,不要。
13)S14nfslock, NFS is a popular protocol for file sharing across TCP/IP networks. This service provides NFS file locking functionality.NFS上锁,需要时再启动,不要。
14)S15mdmonitor,software RAID monitoring and management。软RAID监视,暂时没用到,不要。
15)S18rpcidmapd,Starts user-level daemon for NFSv4 that maps user names to UID and GID numbers.rpc的转换,用时再启,不要。
16)S19rpcgssd, Starts user-level daemon that manages RPCSEC GSS contexts for the NFSv4 client.rpc,用时再启,不要。
17)S22messagebus,This is a daemon which broadcasts notifications of system events and other messages. 程序模块间的消息机制,要。
18)S25bluetooth,Bluetooth services for service discovery, authentication, Human Interface Devices, etc.蓝牙服务,不要。
19) S25netfs,Mounts and unmounts all Network File System (NFS), SMB/CIFS (Lan Manager/Windows), and NCP (NetWare) mount points.网络文件系统挂接管理,不要。
20) S26apmd,apmd is used for monitoring battery status and logging it via syslog(8). It can also be used for shutting down the machine when the battery is low.老的电源管理服务,有新的acpid来管理了,不要。
21)S26hidd,Bluetooth Human Interface Device Daemon. Provides keyboard,mouse etc. functionality over Bluetooth.蓝牙的服务,不要。
22)S26lm_sensors,sensors is used for monitoring motherboard sensor values.主板监视,不要。
23)S28autofs, Automounts filesystems on demand。平时光驱等不常用,没必要启动,手工mount即可,不要。
24)S40smartd,Self Monitoring and Reporting Technology (SMART) Daemon,配合smartctl命令可详细检查硬盘,暂时没必要,但留着研究也好,要。
25)S44acpid,Listen and dispatch ACPI events from the kernel。新的电源管理程序,笔记本linux,要。
26) S50hplip, Note, this script file must start before cupsd.Start/stop script for HP Linux Imaging and Printing (HPLIP)必须在CUPS前启动,不用打印服务,可以联同cups一起不要,不要。
27)S55cups,Startup/shutdown script for the Common UNIX Printing System (CUPS).打印服务,不要。
28)S55sshd,OpenSSH server daemon,不提供远程登录,不要。
29) S56xinetd,xinetd is a powerful replacement for inetd.xinetd has access control mechanisms, extensive logging capabilities, the ability to make services available based on time, and can place limits on the number of servers that can be started, among other things.提供一些比如登录服务的总体监控服务,可节省不少资源,也可以不启动,还是要了,要。
30)S85gpm,GPM adds mouse support to text-based Linux applications such as the Midnight Commander. It also allows mouse-based console cut-and-paste operations, and includes support for pop-up menus on the console.我经常要在console下拷贝粘贴,要。
31)S90crond, cron is a standard UNIX program that runs user-specified programs at periodic scheduled times. vixie cron adds a number of features to the basic UNIX cron, including better security and more powerful configuration options.crontab自动任务守护进程,在本机笔记本上,没必要启,要时候再service crond start即可,不要。
32) S90xfs,Starts and stops the X Font Server at boot time and shutdown.It also takes care of (re-)generating font lists.X窗口字体支持,如果是level 5就必须要了,如果没有这个玩意,是启动不了图形的,我会用图形窗口,要启动,要。
33)S95anacron,Run cron jobs that were left out due to downtime。在关机时可执行crontab的任务,自动开关机了,不要。
34) S95atd,Runs commands scheduled by the at command at the time specified when at was run, and runs batch commands when the load average is low enough.底负荷也可批量执行的自动运行服务,不要。
35)S95firstboot,Firstboot is a druid style program that runs on the first time a machine is booted after install. It checks for the existence of an /etc/sysconfig/firstboot file. If it doesn't find the file, then the firstboot program needs to run. If it finds the file, firstboot will not be run. If /etc/reconfigSys exists, run the reconfiguration program and remove /etc/reconfigSys when done.检查是否已经安装过系统吧,不要。
36)S98avahi-daemon, This is a daemon which runs on client machines to perform Zeroconf service discovery on a network. avahi-daemon must be running on systems that use Avahi for service discovery.在线时区服务,不要。
37)S98cups-config-daemon,This is a daemon for configuring printers through D-BUS,都不用CPUS打印服务了,不要。
38) S98haldaemon,This is a daemon for collecting and maintaing information about hardware from several sources.为搜集和维护硬件信息的,可要可不要,要吧。
39)S99local,不知道要干嘛,要。
3,下面list我要的16个服务:
1)S01sysstat
2)S04readahead_early
3)S05kudzu
4)S06cpuspeed
5)S08arptables_jf
6)S08iptables
8)S10network
10)S12syslog
17)S22messagebus
24)S40smartd
25)S44acpid
29)S56xinetd
30)S85gpm
32)S90xfs
38)S98haldaemon
39)S99local
4,从上面过滤出的16个服务分析,按S**的**数字顺序(是默认的启动顺序),我按如下顺序安排执行:
1)sysstat
2)readahead_early
3)cpuspeed
4)kudzu
然后,并行如下:
5)并行一:并行执行arptables_jf和iptables,这两个服务执行完了,再执行network
6)并行二:并行执行syslog,messagebus,acpid,xinetd,gpm,xfs,haldaemon
5,现在一切都好了,准备东风:
1)从 ftp://www6.software.ibm.com/software/developer/library/l-boot/runlevel.zip 下载 James Hunt 写好的模板。
James Hunt写的模板,我在fedora core 5上测试了,有一些问题。
-1) rc脚本他完全使用runlevel.mk来取代原来的启动关闭系统要循环执行的K*和S*脚本,我测试的结果是:首先如果是shutdown,会查找 start0.mk和stop0.mk,如果是重启,会查找start6.mk和 stop6.mk,这4个脚本是没有提供的,得自己写。其次,把所说的4个脚本提供了,关闭或重启时所有进程都关闭后,系统不会自动重启初始化或关闭电 源,一直hang在那儿。
-2)runlevel.mk脚本要修改才可使用。
-3)start3.mk要修改。
6,我的做法:
1)创建目录/etc/rc.d/runlevel目录存储放下载回来的runlevel.mk,start3.mk等脚本。
2)修改/etc/rc.d/rc脚本,在“# Now run the START scripts.”这块循环启动脚本的“for i in”循环外添加一个条件判断:
if [ "$runlevel" = 3 -o "$runlevel" = 5 ]
then
make -j -f /etc/rc.d/runlevel/runlevel.mk RUNLEVEL=$runlevel JOB=start
else
# Now run the START scripts.
for i in /etc/rc$runlevel.d/S* ; do
原有code..................
done
fi
这样判断只有init 3和 init 5才会使用新的快速启动方法启动。
3)修改/etc/rc.d/runlevel/runlevel.mk
要修改的地方有:
--1)
INITD_DIR := /etc/rc.d/init.d #这个路径,模板里是/etc/init.d,要修改
--2)
SUBSYS_FILE_DIR := /var/lock/subsys #这个目录我们是有的,所以可以不用修改
--3)ALL := 需要根据自己需要修改,此处,我修改为上面“3,”我列出的16个服务:
(NOTE:下载回来的模板里,语法为ALL = ,这样是不行的,要在等号前加个冒号,即可把 “=“ 修改为 “ :=” )
ALL :=
sysstat
readahead_early
cpuspeed
kudzu
arptables_jf
iptables
network
syslog
messagebus
acpid
xinetd
gpm
xfs
haldaemon
local

#上面每个服务屁股后面有一个斜线,表示接上行,可是在这里,不知道为什么显示不出来

--4)include的地方得写正确了,路径不对就坏事了
include /etc/rc.d/runlevel/$(JOB)$(RUNLEVEL).mk
4)根据上面“4,”列出的执行顺序,修改start3.mk脚本为如下:
(NOTE: 冒号之间是tab键,不是空格)
[root@bigboar runlevel]# cat start3.mk
# GNU Makefile listing dependencies between services when services are
# started.
# Run kudzu first.
$(filter-out $
readahead_early : sysstat
cpuspeed : readahead_early
kudzu : cpuspeed
arptables_jf : kudzu
iptables : kudzu
network : arptables_jf iptables
syslog : kudzu
messagebus : kudzu
acpid : kudzu
xinetd : kudzu
gpm : kudzu
xfs : kudzu
haldaemon : kudzu
# Run local last.
local : $(filter-out $@,$(ALL))
# EOF
5)用一份init 3拷贝一份init 5
[root@bigboar runlevel]# cp start3.mk start5.mk
NOTE:

测试时,可在/var/lock/subsys目录,看到你启动了的服务(文件名就是服务名了,文件为空)。
完事:
现在就可以体验我们的成果了,reboot一下,飞的感觉马上就来了。。。。。。。。。。。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/312079/viewspace-848825/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/312079/viewspace-848825/

你可能感兴趣的文章
bulma.css_在5分钟内学习Bulma CSS-初学者教程
查看>>
如何快速设置您的ES6环境
查看>>
深圳哪个区的it工作多_如何创建虚拟IT工作区
查看>>
组件和高阶组件区别_高阶组件:终极指南
查看>>
如何知道Kubernetes是否适合您的SaaS
查看>>
如何使用React Native构建实时的Todo应用
查看>>
apollo调试工具_GraphQL工具包Apollo的完整介绍
查看>>
函数编程代码例子_使用函数式编程使代码更易于阅读
查看>>
文件从头开始读函数_这是您可以从头开始编写的一些函数修饰符
查看>>
JavaScript中的pipe()和compose()快速介绍
查看>>
react中的状态机_使用状态机增强您的React
查看>>
ruby 数组删除部分数组_您需要了解的六个Ruby数组方法
查看>>
roro cam_现代JavaScript中的优雅图案:RORO
查看>>
React Router v4简介及其对路由的哲学
查看>>
程序自动化 linux_自动化Windows子系统Linux安装程序
查看>>
react获取api_使用React和WordPress API在您的网站上获取博客
查看>>
可视化编程语言_可视化编程语言影响图
查看>>
framer x使用教程_如何使用Framer Motion将交互式动画和页面过渡添加到Next.js Web应用程序
查看>>
如何成为软件工程师的团队合作者
查看>>
快排递归非递归python_Python递归神经网络终极指南
查看>>