Upload
cecil-hamilton
View
212
Download
0
Embed Size (px)
Citation preview
1
Starting Network Services
Version A.01H3065S Module 7 Slides
2 © 1999 Hewlett-Packard Co.
H3065S A.01
Starting System and Network Services
a67364
PDC chooses a boot disk.
ISL finds and loads the kernel.
Kernel calls /sbin/init.
Init calls /sbin/rc.
/sbin/rc starts system and network services.
NFSDNS
NTP
NetworkSubsystem
Kernel(vmunix)
Network Drivers
…
Memory
/
/stand /etc /sbin /usr
File System
vmunix
LANIC
1
23
init
4
/sbin/rc
rc1.d rc2.d rc3.d
Networkdaemons
1
2
3
4
3 © 1999 Hewlett-Packard Co.
H3065S A.01
Run Levels
a67365
• init and /sbin/rc start and stop services in stages called run levels.• The system run level determines what services are available.• At boot, init progresses from run level 1 to 3, starting services.• At shutdown, init progresses from run level 3 to 0, killing services.
• Example: (Not all run levels and services shown)
Run Level Services Available
3 syncer, NFS, CDE
2 syncer, NFS
1 syncer
0
Sta
rtu
pS
hu
tdow
n
4 © 1999 Hewlett-Packard Co.
H3065S A.01
/sbin/rc*.d Directories
a67366
• /sbin/rc*.d directories determine at which run levels services start and stop.• /sbin/rc runs S scripts to start services during system startup.• /sbin/rc runs K scripts to kill services during system shutdown.
K100dtlogin.rc
K900nfs.server
S340net
S430nfs.client
S500inetd
S660xntpd
/sbin
rc2.d
rc1.d
rc0.d
rc3.d
5 © 1999 Hewlett-Packard Co.
H3065S A.01
S/K Script Naming Convention
a67367
/sbin/rc2.d/S730cron
Run Level
Type
Sequence Number
Service Name
6 © 1999 Hewlett-Packard Co.
H3065S A.01
/sbin/init.d/* Scripts
a67368
/sbin
init.d rc2.drc1.d
cronK270cron S730cronlink link
• Every service started by /sbin/rc has an associated script in /sbin/init.d.• /sbin/init.d scripts contain code needed to actually start/kill services.• /sbin/rc*.d/* scripts are just symbolic links to /sbin/init.d scripts!
7 © 1999 Hewlett-Packard Co.
H3065S A.01
What’s in an init.d Script?
a67369
case $1 in start_msg) echo “Start clock daemon” stop_msg) echo “Stop clock daemon” start) # Commands to start cron stop) # Commands to kill cronesac
• Scripts in /sbin/init.d accept a single argument.• Scripts do one of four things, depending on the argument value.• Sample init.d script (simplified):
/sbin/init.d/cron:
8 © 1999 Hewlett-Packard Co.
H3065S A.01
/etc/rc.config.d/* Files
a67370
/etc/rc.config.d/cron
CRON=1 # Set control variable to 1 to enable # Set control variable to 0 to disable
/sbin/init.d/cron (simplified)
case $1 in start_msg) echo “Start clock daemon” stop_msg) echo “Stop clock daemon” start) if CRON=1 then start the cron daemon stop) if CRON=1 then kill the cron daemonesac
• You may wish to disable a service that’s not needed, or enable a new service.• Services may be enabled or disabled via control variables.• Control variables are defined in files under /etc/rc.config.d.• /sbin/init.d/ scripts source /etc/rc.config.d/* files to determine control variable values.
9 © 1999 Hewlett-Packard Co.
H3065S A.01
Pulling it All Together
a67371
Pool of Startup/Shutdown Scripts Data Configuration Files
/etc/rc.config.d/sbin/init.drc Script
net
inetd
nfs.server
nis.client...
netconf
netdaemons
nfsconf
namesvrs...
/sbin/rc1.d
/sbin/rc2.d
/sbin/rc3.d
K500inetdK660net
K900nfsS340netS500inetd
S100nfs.server
start
stop
stop_msg
start_msg
10 © 1999 Hewlett-Packard Co.
H3065S A.01
Viewing Console Messages when Changing Run Levels
a67372
init brings system to run level 2.
init calls /sbin/rc.
/sbin/rc executes /sbin/rc2.d/S* scripts with start_msg argument.
/sbin/rc executes /sbin/rc2.d/S*scripts with start argument
Transition to run level 2 complete.
Start clock daemon..................[ ]Start internet services daemon......[ ]Start NFS client subsystem..........[ ]
Start clock daemon..................[N/A]Start internet services daemon......[OK ]Start NFS client subsystem..........[OK ]
11 © 1999 Hewlett-Packard Co.
H3065S A.01
Creating Custom Start Scripts
a67373
Cookbook Procedure
1. cd /sbin/init.d2. cp template scope_collect3. vi scope_collect a. Edit start_msg statement b. Edit stop_msg statement c. Edit start statement i. Change CONTROL_VARIABLE to SCOPE_COLLECT ii. Add command /opt/perf/bin/scope.start iii. Add command set_return d. Edit stop statement i. Change CONTROL_VARIABLE to SCOPE_COLLECT ii. Add command /opt/perf/bin/scope.stop iii. Add command set_return4. vi /etc/rc.config.d/scope_collect a. Add single line, SCOPE_COLLECT=15. ln -s /sbin/init.d/scope_collect /sbin/rc3.d/S900scope_collect6. ln -s /sbin/init.d/scope_collect /sbin/rc2.d/K100scope_collect