Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Linux Service Management Made Easy with systemd

You're reading from   Linux Service Management Made Easy with systemd Advanced techniques to effectively manage, control, and monitor Linux systems and services

Arrow left icon
Product type Paperback
Published in Feb 2022
Publisher Packt
ISBN-13 9781801811644
Length 420 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Donald A. Tevault Donald A. Tevault
Author Profile Icon Donald A. Tevault
Donald A. Tevault
Arrow right icon
View More author details
Toc

Table of Contents (23) Chapters Close

Preface 1. Section 1: Using systemd
2. Chapter 1: Understanding the Need for systemd FREE CHAPTER 3. Chapter 2: Understanding systemd Directories and Files 4. Chapter 3: Understanding Service, Path, and Socket Units 5. Chapter 4: Controlling systemd Services 6. Chapter 5: Creating and Editing Services 7. Chapter 6: Understanding systemd Targets 8. Chapter 7: Understanding systemd Timers 9. Chapter 8: Understanding the systemd Boot Process 10. Chapter 9: Setting System Parameters 11. Chapter 10: Understanding Shutdown and Reboot Commands 12. Section 2: Understanding cgroups
13. Chapter 11: Understanding cgroups Version 1 14. Chapter 12: Controlling Resource Usage with cgroups Version 1 15. Chapter 13: Understanding cgroup Version 2 16. Section 3: Logging, Timekeeping, Networking, and Booting
17. Chapter 14: Using journald 18. Chapter 15: Using systemd-networkd and systemd-resolved 19. Chapter 16: Understanding Timekeeping with systemd 20. Chapter 17: Understanding systemd and Bootloaders 21. Chapter 18: Understanding systemd-logind 22. Other Books You May Enjoy

The shortcomings of SysV Init and upstart

The first problem with SysV is that of its rather lengthy boot-up times. When you boot up a SysV machine, all of its services have to start up in sequential order. That might not be so bad on a normal desktop machine, but it can be a bit problematic on a server that needs to run lots of services. In that case, each service would have to wait its turn to start, which could take a while.

The next problem with SysV is its complexity. Instead of simple, easy-to-understand configuration files, SysV does everything with complex Bash shell scripts. The init scripts that control system services all have to be assigned a priority number, so that services will start and stop in the proper order. Take, for example, the init script that starts the Apache web server on a CentOS 5 machine. First, we can see that it's a fairly lengthy script, as shown here:

[student@localhost init.d]$ pwd
/etc/init.d
[student@localhost init.d]$ ls -l httpd
-rwxr-xr-x 1 root root 3523 Sep 16  2014 httpd
[student@localhost init.d]$ wc -l httpd
131 httpd
[student@localhost init.d]$

You can see from the wc -l output that it consists of 131 lines. As you can see here, 37 of those lines are comments, which still leaves us with 94 lines of actual code:

[student@localhost init.d]$ grep ^# httpd | wc -l
37
[student@localhost init.d]$

Look inside, and you'll see that it's quite complex and convoluted. Here's just the first part of it:

Figure 1.1 – An old-fashioned SysV Init script

Toward the end of the script, you'll see the code that stops, starts, restarts, and reloads the Apache daemon, as shown here:

Figure 1.2 – The start, stop, restart, reload section of an init script

This code, or code similar to this, has to be in every init script so that the human user can control the daemon. To complicate things even more, developers didn't always write this code consistently for different programs. So, for example, a status display for one daemon didn't always look the same as the status display for another daemon.

Then, there's the problem of inconsistent implementation across the different families of Linux distros. With SysV, there were at least three different methods of implementation. Red Hat-type distros used one method, Debian-type distros used another method, and Slackware-type distros use yet another. For example, the Red Hat way of controlling services required using the service and chkconfig commands. When working with Debian-type systems, I always used to have to look up the service management commands, because I could never remember them. With Slackware, you don't have any service management commands. To enable or disable a service on a Slackware machine, you just set or remove the executable permission from the appropriate init script.

Runlevels were also a source of confusion, because each family of distro had its own set of runlevel definitions. For example, here are the definitions for the graphical runlevel:

  • The Red Hat family used runlevel 5.
  • The Slackware family uses runlevel 4.
  • The Debian family used no specific runlevel for either text mode or graphical mode. Instead, you enabled or disabled graphical mode by enabling or disabling the X server daemon.

So, you can see that this was all quite confusing, especially for anyone who worked in a mixed environment. It should be fairly obvious that we needed something that was a bit less confusing.

As if this weren't enough, there was also the issue of performance. SysV worked well in its day, when computing hardware was more primitive. But, on modern hardware with multiple CPUs that each have multiple cores, we need something a bit more robust. Ubuntu's upstart was supposed to fix this, but it didn't quite live up to its promise. Nowadays, Upstart is completely dead, but there are still some diehards who refuse to give up SysV. In the enterprise, systemd is king.

You have been reading a chapter from
Linux Service Management Made Easy with systemd
Published in: Feb 2022
Publisher: Packt
ISBN-13: 9781801811644
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image