您的位置:首页 > 运维架构 > Linux

004.Vmware -Linux NFS服务自启动

2011-10-25 23:09 489 查看
Topic:Vmware -Linux NFS服务自启动

Date: 4-Mar-2011

By: Calvinlee1984@163.com

1.本文在《003.Vmware-Linux NFS服务安装使用》的基础上在Vmware-Linux上加入自启动NFS服务的脚本

2.让脚本在开机时自动运行需要对Linux系统的启动过程有所了解。系统加载内核以后运行的第一个程序就是init,所以它的PID永远是1;而init程序首先就要读取/etc/inittab文件,init程序就根据这个文件的内容按照顺序创建进程。



3.分析/etc/inittab文件 more /etc/inittab

#

# inittab This file describes how the INIT process should set up

# the system in a certain run-level.

#

# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>

# Modified for RHS Linux by Marc Ewing and Donnie Barnes

#

# Default runlevel. The runlevels used by RHS are:

# 0 - halt (Do NOT set initdefault to this)

# 1 - Single user mode

# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)

# 3 - Full multiuser mode

# 4 - unused

# 5 - X11

# 6 - reboot (Do NOT set initdefault to this)

#

id:5:initdefault:

# System initialization.

si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0

l1:1:wait:/etc/rc.d/rc 1

l2:2:wait:/etc/rc.d/rc 2

l3:3:wait:/etc/rc.d/rc 3

l4:4:wait:/etc/rc.d/rc 4

l5:5:wait:/etc/rc.d/rc 5

l6:6:wait:/etc/rc.d/rc 6

# Trap CTRL-ALT-DELETE

ca::ctrlaltdel:/sbin/shutdown -t3 -r now

# When our UPS tells us power has failed, assume we have a few minutes

# of power left. Schedule a shutdown for 2 minutes from now.

# This does, of course, assume you have powerd installed and your

# UPS connected and working correctly.

pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"

# If power was restored before the shutdown kicked in, cancel it.

pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"

# Run gettys in standard runlevels

1:2345:respawn:/sbin/mingetty tty1

2:2345:respawn:/sbin/mingetty tty2

3:2345:respawn:/sbin/mingetty tty3

4:2345:respawn:/sbin/mingetty tty4

5:2345:respawn:/sbin/mingetty tty5

6:2345:respawn:/sbin/mingetty tty6

# Run xdm in runlevel 5

x:5:respawn:/etc/X11/prefdm –nodaemon

分析:1)shell 的运行级别是5

2)根据shell的运行级别执行对应的脚本/etc/rc.d/rc5.d

4.查看 /etc/rc.d/目录下的文件 ls –l /etc/rc.d



5.查看/etc/rc.d/rc5.d目录下的文件 ls /etc/rc.d/rc5.d



K20nfs:K为kill ,20是顺序号

S13portmap:S为stop

注:系统确定运行级别以后,进入相应的rcN.d目录,执行以S开头的文件以启用相关服务进程,而且是按照S后面的那个数字的顺序依次执行;而更换运行级别时,会先执行以K开头的脚本,再执行以S开头的脚本,执行顺序都是按照他们后面的数字的顺序;退出系统时,就依次执行以K开头的文件关闭相关服务。

6.查看nfs服务的启动脚本more /etc/rc.d/init.d/nfs





由chkconfig:- 60 20可知,nfs服务不运行在任何级别,启用顺序是60,停止顺序是20

7.使用相关命令使得nfs在运行级别5下自启动



8.reboot并查看nfs服务启用情况



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: