优化Linux系统中的服务




实验要求


  • 设置Linux系统每次开机后自动进入字符模式界面。
  • 使用ntsysv工具同时调整2、3、4、5运行级别中的服务状态,关闭下列服务: atd、bluetooth、cups、ip6tables、iptables、mdmonitor、nfslock、rhnsd、rpcgssd、 postfix。
  • 使用chkconfig工具调整个别服务的启动状态。
  • 将cups服务在运行级别3中的默认启动状态设为关闭。
  • 将postfix服务在运行级别3、5中的默认启动状态设为启用其余级别中设为关闭。
  • 查看当前系统中内存占用情况,重启并登录到字符模式,再次查看内存占用情况。
  • 使用init命令切换到图形模式,再次确认运行级别并查看内存占用情况,比较优化 服务前后及在不同运行级别中的差异。




设置Linux系统每次开机后自动进入字符模式界面。


通过vim /etc/inittab进入这个界面进行修改



使用ntsysv工具同时调整2、3、4、5运行级别中的服务状态,关闭下列服务: atd、bluetooth、cups、ip6tables、iptables、mdmonitor、nfslock、rhnsd、rpcgssd、postfix。


查看改变之前的状态:

[root@test2 jason]# chkconfig --list
NetworkManager 0:off1:off2:on3:on4:on5:on6:off
abrt-ccpp  0:off1:off2:off3:on4:off5:on6:off
abrtd  0:off1:off2:off3:on4:off5:on6:off
acpid  0:off1:off2:on3:on4:on5:on6:off
atd    0:off1:off2:off3:on4:on5:on6:off
auditd 0:off1:off2:on3:on4:on5:on6:off
autofs 0:off1:off2:off3:on4:on5:on6:off
blk-availability0:off1:on2:on3:on4:on5:on6:off
bluetooth  0:off1:off2:off3:on4:on5:on6:off
certmonger 0:off1:off2:off3:on4:on5:on6:off
cpuspeed   0:off1:on2:on3:on4:on5:on6:off
crond  0:off1:off2:on3:on4:on5:on6:off
cups   0:off1:off2:on3:on4:on5:on6:off
dnsmasq0:off1:off2:off3:off4:off5:off6:off
firstboot  0:off1:off2:off3:off4:off5:off6:off
haldaemon  0:off1:off2:off3:on4:on5:on6:off
ip6tables  0:off1:off2:on3:on4:on5:on6:off
iptables   0:off1:off2:on3:off4:on5:off6:off
irqbalance 0:off1:off2:off3:on4:on5:on6:off
kdump  0:off1:off2:on3:on4:on5:on6:off
lvm2-monitor   0:off1:on2:on3:on4:on5:on6:off
mdmonitor  0:off1:off2:on3:on4:on5:on6:off
messagebus 0:off1:off2:on3:on4:on5:on6:off
netconsole 0:off1:off2:off3:off4:off5:off6:off
netfs  0:off1:off2:off3:on4:on5:on6:off
network0:off1:off2:on3:on4:on5:on6:off
nfs0:off1:off2:off3:off4:off5:off6:off
nfslock0:off1:off2:off3:on4:on5:on6:off
ntpd   0:off1:off2:off3:off4:off5:off6:off
ntpdate0:off1:off2:off3:off4:off5:off6:off
oddjobd0:off1:off2:off3:off4:off5:off6:off
portreserve0:off1:off2:on3:on4:on5:on6:off
postfix0:off1:off2:on3:on4:on5:on6:off
psacct 0:off1:off2:off3:off4:off5:off6:off
quota_nld  0:off1:off2:off3:off4:off5:off6:off
rdisc  0:off1:off2:off3:off4:off5:off6:off
restorecond0:off1:off2:off3:off4:off5:off6:off
rngd   0:off1:off2:off3:off4:off5:off6:off
rpcbind0:off1:off2:on3:on4:on5:on6:off
rpcgssd0:off1:off2:off3:on4:on5:on6:off
rpcsvcgssd 0:off1:off2:off3:off4:off5:off6:off
rsyslog0:off1:off2:on3:on4:on5:on6:off
saslauthd  0:off1:off2:off3:off4:off5:off6:off
smartd 0:off1:off2:off3:off4:off5:off6:off
snmpd  0:off1:off2:off3:off4:off5:off6:off
snmptrapd  0:off1:off2:off3:off4:off5:off6:off
spice-vdagentd 0:off1:off2:off3:off4:off5:on6:off
sshd   0:off1:off2:on3:on4:on5:on6:off
sssd   0:off1:off2:off3:off4:off5:off6:off
sysstat0:off1:on2:on3:on4:on5:on6:off
udev-post  0:off1:on2:on3:on4:on5:on6:off
vmware-tools   0:off1:off2:on3:on4:on5:on6:off
vmware-tools-thinprint0:off1:off2:on3:on4:on5:on6:off
wdaemon0:off1:off2:off3:off4:off5:off6:off
webmin 0:off1:off2:on3:on4:off5:on6:off
winbind0:off1:off2:off3:off4:off5:off6:off
wpa_supplicant 0:off1:off2:off3:off4:off5:off6:off
xinetd 0:off1:off2:off3:on4:on5:on6:off
ypbind 0:off1:off2:off3:off4:off5:off6:off

xinetd based services:
chargen-dgram: off
chargen-stream:off
daytime-dgram: off
daytime-stream:off
discard-dgram: off
discard-stream:off
echo-dgram:off
echo-stream:   off
rsync: off
tcpmux-server: off
telnet:on
time-dgram:off
time-stream:   off
[root@test2 jason]#


目标服务及状态汇总信息


service Status
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
bluetooth 0:off 1:off 2:off 3:on 4:on 5:on 6:off
cups 0:off 1:off 2:on 3:on 4:on 5:on 6:off
ip6tables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iptables 0:off 1:off 2:on 3:off 4:on 5:off 6:off
mdmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:off
nfslock 0:off 1:off 2:off 3:on 4:on 5:on 6:off
rpcsvcgssd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off


开始修改


[root@test2 jason]# ntsysv --level 2345


atd



bluetooth



cups



ip6tables



iptables+mdmonitor



nfslock+postfix



修改过程中没有找到rhnsd


修改之后查看信息


[root@test2 jason]# chkconfig --list
NetworkManager 0:off1:off2:on3:on4:on5:on6:off
abrt-ccpp  0:off1:off2:on3:on4:on5:on6:off
abrtd  0:off1:off2:on3:on4:on5:on6:off
acpid  0:off1:off2:on3:on4:on5:on6:off
atd0:off1:off2:off3:off4:off5:off6:off
auditd 0:off1:off2:on3:on4:on5:on6:off
autofs 0:off1:off2:on3:on4:on5:on6:off
blk-availability0:off1:on2:on3:on4:on5:on6:off
bluetooth  0:off1:off2:off3:off4:off5:off6:off
certmonger 0:off1:off2:on3:on4:on5:on6:off
cpuspeed   0:off1:on2:on3:on4:on5:on6:off
crond  0:off1:off2:on3:on4:on5:on6:off
cups   0:off1:off2:off3:off4:off5:off6:off
dnsmasq0:off1:off2:off3:off4:off5:off6:off
firstboot  0:off1:off2:off3:off4:off5:off6:off
haldaemon  0:off1:off2:on3:on4:on5:on6:off
ip6tables  0:off1:off2:off3:off4:off5:off6:off
iptables   0:off1:off2:off3:off4:off5:off6:off
irqbalance 0:off1:off2:on3:on4:on5:on6:off
kdump  0:off1:off2:on3:on4:on5:on6:off
lvm2-monitor   0:off1:on2:on3:on4:on5:on6:off
mdmonitor  0:off1:off2:off3:off4:off5:off6:off
messagebus 0:off1:off2:on3:on4:on5:on6:off
netconsole 0:off1:off2:off3:off4:off5:off6:off
netfs  0:off1:off2:on3:on4:on5:on6:off
network0:off1:off2:on3:on4:on5:on6:off
nfs0:off1:off2:off3:off4:off5:off6:off
nfslock0:off1:off2:off3:off4:off5:off6:off
ntpd   0:off1:off2:off3:off4:off5:off6:off
ntpdate0:off1:off2:off3:off4:off5:off6:off
oddjobd0:off1:off2:off3:off4:off5:off6:off
portreserve0:off1:off2:on3:on4:on5:on6:off
postfix0:off1:off2:off3:off4:off5:off6:off
psacct 0:off1:off2:off3:off4:off5:off6:off
quota_nld  0:off1:off2:off3:off4:off5:off6:off
rdisc  0:off1:off2:off3:off4:off5:off6:off
restorecond0:off1:off2:off3:off4:off5:off6:off
rngd   0:off1:off2:off3:off4:off5:off6:off
rpcbind0:off1:off2:on3:on4:on5:on6:off
rpcgssd0:off1:off2:off3:off4:off5:off6:off
rpcsvcgssd 0:off1:off2:off3:off4:off5:off6:off
rsyslog0:off1:off2:on3:on4:on5:on6:off
saslauthd  0:off1:off2:off3:off4:off5:off6:off
smartd 0:off1:off2:off3:off4:off5:off6:off
snmpd  0:off1:off2:off3:off4:off5:off6:off
snmptrapd  0:off1:off2:off3:off4:off5:off6:off
spice-vdagentd 0:off1:off2:on3:on4:on5:on6:off
sshd   0:off1:off2:on3:on4:on5:on6:off
sssd   0:off1:off2:off3:off4:off5:off6:off
sysstat0:off1:on2:on3:on4:on5:on6:off
udev-post  0:off1:on2:on3:on4:on5:on6:off
vmware-tools   0:off1:off2:on3:on4:on5:on6:off
vmware-tools-thinprint0:off1:off2:on3:on4:on5:on6:off
wdaemon0:off1:off2:off3:off4:off5:off6:off
webmin 0:off1:off2:on3:on4:on5:on6:off
winbind0:off1:off2:off3:off4:off5:off6:off
wpa_supplicant 0:off1:off2:off3:off4:off5:off6:off
xinetd 0:off1:off2:on3:on4:on5:on6:off
ypbind 0:off1:off2:off3:off4:off5:off6:off


从这里可以看出来修改是成功的


service Status
atd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
bluetooth 0:off 1:off 2:off 3:off 4:off 5:off 6:off
cups 0:off 1:off 2:off 3:off 4:off 5:off 6:off
ip6tables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
mdmonitor 0:off 1:off 2:off 3:off 4:off 5:off 6:off
nfslock 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rpcsvcgssd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
postfix 0:off 1:off 2:off 3:off 4:off 5:off 6:off


使用chkconfig工具调整个别服务的启动状态。


当前postfix状态:

[root@test2 jason]# chkconfig --list postfix
postfix            0:off    1:off    2:off    3:off    4:off    5:off    6:off

修改postfix:

[root@test2 jason]# chkconfig --level 35 postfix on

查看

[root@test2 jason]# chkconfig --list postfix
postfix0:off1:off2:off3:on4:off5:on6:off

postfix在35已经开启


将cups服务在运行级别3中的默认启动状态设为关闭。


查看cups的状态

[root@test2 jason]# chkconfig --list cups
cups   0:off1:off2:off3:off4:off5:off6:off

开启cups level3

[root@test2 jason]# chkconfig --level 3 cups on

开启后查看

[root@test2 jason]# chkconfig --list cups
cups   0:off1:off2:off3:on4:off5:off6:off


将network服务在运行级别3、5中的默认启动状态设为启用。


当前network的状态

[root@test2 jason]# chkconfig --list network
network0:off1:off2:on3:on4:on5:on6:off

关掉

[root@test2 jason]# chkconfig --level 35 network off

关掉后查看

[root@test2 jason]# chkconfig --list network
network0:off1:off2:on3:off4:on5:off6:off

开启network35

[root@test2 jason]# chkconfig --level 35 network on

开启后查看

[root@test2 jason]# chkconfig --list network
network0:off1:off2:on3:on4:on5:on6:off


查看当前系统中内存占用情况,重启并登录到字符模式,再次查看内存占用情况。


未做任何修改之前

字符界面:

[root@test2 jason]# grep "MemFree" /proc/meminfo
MemFree: 7386376 kB

桌面模式:



修改之后:


字符模式:

[root@test2 jason]# grep "MemFree" /proc/meminfo
MemFree: 7584276 kB

桌面模式:

重启

字符模式:

[root@test2 jason]# grep "MemFree" /proc/meminfo
MemFree: 7703308 kB
[root@test2 jason]#

桌面模式:




results matching ""

    No results matching ""