Professional Documents
Culture Documents
Virtualsysadminday StartingandStoppingServices 140114 2024 140
Virtualsysadminday StartingandStoppingServices 140114 2024 140
Introduction
Oracle Linux 6 uses Upstart, a replacement for the System V init system to start and stop services at boot time. When the system is booted up, it
is configured to reach a certain run-level. Run levels are numbered and define what services should be started or stopped in order to reach that
run level or when transitioning to another run level. For example, run level 3 usually identifies that all services except for the graphical desktop
environment are started. The GUI is started when switching to run level 5. Also, the shutdown of a system is defined as a run level that just stops
all running services and does not start any new ones.
Each service that can be started or stopped comes with an init script, a shell script that performs the appropriate actions to start or stop the
service in question. Init scripts are stored in the directory /etc/init.d/ and accept a number standard options, e.g. start or stop. Depending
on the option, they then perform the requested action. They can either be called directly, or they can be invoked by the init process or the
service utility. Note that some init scripts are only supposed to be started once at system bootup; they don't start a service (a permanently
running process) per se, but they are being run to perform tasks like configuring the networking subsystem or adjusting certain kernel parameters.
Requirements
These lab exercises focus on services that can be started and stopped at runtime, using the Apache httpd web server as an example. The
general approach of starting/stopping and enabling services applies to most other services (e.g. CUPS print services, Samba file sharing) as well.
In order to perform the exercises outlined below, first ensure that the Apache web server (package httpd) is installed:
If it is missing, use the yum package manager to install the package, as outlined in the exercises of Package management with RPM and yum:
sudo yum install httpd
OK
You can now verify that the web server is running by pointing a web browser to its IP address (e.g. http://localhost/, if you are running these
exercises from a local desktop environment).
You should see a default web page similar to this one:
Unable to render embedded object: File (httpd.png) not found.
The following example checks the status of the Apache httpd web server, stops the service and checks the status again.
4589) is running...
OK
You can verify this by trying to open http://localhost/ in your local browser before and after stopping the httpd service. If the web server isn't up
and running, you should get an error message.
0:off
0:off
0:off
0:off
0:off
0:off
0:off
0:off
0:off
0:off
0:off
0:off
0:off
0:off
In the example below, the httpd service is currently disabled, as it is usually the default for freshly installed packages:
Now we use the on option to enable the web server during system bootup and check the configuration again:
Verify that the Apache httpd is actually starting on bootup now by rebooting your system. After logging in again, run service httpd status or
open a web browser from the VM desktop and open http://localhost/ it should display the default start page now right away.