Linux Services

Starting Services

init daemon

* Run when system boots or enter a run level.
* Starts all rc scripts starting with “S” in a run level’s rc subdirectory (e.g. /etc/rc.d/rc.3).
* Restarts a service if service dies in a particular run level and marked by respawn (e.g. x:5:respawn:/etc/X11/prefdm -nodaemon).

Run levels

* Defined in /etc/inittab file
* Total 7 run levels (0 to 6).
* Default run level defined by “id:5:initdefault:” (5 for GUI, 3 for non-GUI).
* System can only be at one run level at a time.
* /sbin/runlevel: current run level.

Manages init Script Symbolic Links

/sbin/chkconfig

* Copy startup script, e.g. myscript, to /etc/init.d directory.
* Add to the beginning of myscript:

# chkconfig: 234 99 90
# description: myscript runs my daemon at runlevel 2, 3, or 4

* Run chkconfig:

chkconfig --delete myscript
chkconfig --add myscript

* This will create symbolic links named “S99myscript” in the rc.2, rc.3, rc.4 directories and “K90myscript” in the rc.0, rc.1, rc.5, rc.6 directories.

Start/Stop Services

/etc/init.d/myscript start
/etc/init.d/myscript stop

# Redhat
service myscript start
service myscript stop
service myscript restart

heartbeat

* When service starts or need a resource
* Better to have redundant heartbeat connections
– Serial cable
– Ethernet cable
* Partitioned clusters
– When both assume primary server role
– Resolution: stonith
* Heartbeat configuration files
– /etc/ha.d/ha.cf # specifies how ha daemons communicate with each other
– /etc/ha.d/haresources # specifies which server should act as primary for a resource
– /etc/ha.d/authkeys # specifies how ha packets should be encrypted

xinetd: when network request comes in

Other non-standard method

Secondary IP Addresses

# View both primary and secondary ip addresses
ip addr sh
ip addr sh dev eth0

# Add secondary ip
ip addr add 209.100.100.3/24 broadcast 209.100.100.255 dev eth0

# Remove secondary ip
ip addr del 209.100.100.3/24 broadcast 209.100.100.255 dev eth0

References

The Linux Enterprise Cluster by Karl Kopper

This entry was posted in Linux, Uncategorized. Bookmark the permalink.