Have you encountered a situation where there is no traffic light or traffic police at a major junction? Can you imagine how much chaos it would cause? How many accidents occur in no time? Traffic lights are used to control traffic movement, and they are installed at junctions, crossings, or intersections. The different colors on them tell drivers what to do.
In simple terms, an init system or an initialization system is like a traffic light of the computer. Imagine your computer as a traffic junction or intersection where several programs from various directions cross the junction. The init system ensures that the traffic is properly handled when the computer is powered up. Now, the exciting part is someone sitting in the control center and managing the traffic lights remotely, which in the Linux world is called Systemctl. The systemctl command is a tool to control the systemd system and Linux services, also called daemons. This is the replacement of the old SysV init system management.
Do you know?
Lennart Poettering and Kay Sievers wrote systemd, inspired by macOS’s launchd and Upstart, to create a modern and dynamic system.
To better understand the above figure, here are the following details,
When the system powers up, a call is sent to the BIOS. Here, BIOS initializes minimal hardware and hands over the call to the Boot Loader.
The boot loader then calls the Kernel, which mounts the Initial RAM disk.
System files and Root files are then loaded into the initial RAM disk, resulting in the invocation of the systemd process.
The systemd process mounts all the needed host's file system and starts the services in sequence.
# Systemd Units
About
Systemd introduces the concept of Systemd Units. Units are defined in the Unit configuration files, which tell about the behavior of the unit and its behavior. In simple terms, Systemd unit configuration files have a set of instructions or a script that tells the computer how to run a specific task or a service. So, systemd units are the rules or recipes that help your computer manage various tasks, programs, and schedules clean and organized.
Examples
Service Unit
The Service Unit has information, like how the services are set up, how to start (Manual/Automated on boot), what happens if it encounters unexpected issues, etc.
Timer Unit
The Timer Unit has information like how a service is scheduled, for example; daily, weekly, monthly, or yearly, which programs or services should they trigger, and so on. Timer Units are like scheduling instructions (Alarm clock).
Socket Unit
The Socket Units define how the programs communicate with each other.
Systemctl Syntax
Model: systemctl [OPTION] [SERVICE]
Systemctl - start|stop|restart|disable|enable|status Confluent & Kafka nodes.
Broker
systemctl option confluent-server
systemctl option confluent-kaka
Connect
systemctl option confluent-kaka-connect
KSQL
systemctl option confluent-ksqldb (version 6.1.1)
Schema registry
systemctl option confluent-schema-registry
REST Proxy
systemctl option confluent-kaka-rest
Control Center
systemctl option confluent-control-user
Systemctl - start|stop|restart|disable|enable|status mysql nodes.
Start|Stop
sudo systemctl start mysql.service
sudo systemctl stop mysql.service
Restart|Reload|reload-or-restart Service
sudo systemctl reload mysql.service
sudo systemctl restart mysql.service
sudo systemctl reload-or-restart mysql.service
Enable|Disable
sudo systemctl enable mysql.service
sudo systemctl disable mysql.service
Status
sudo systemctl status mysql.service
Currently Active|Disabled
sudo systemctl is-active mysql.service
sudo systemctl is-enabled mysql.service
Systemctl - list units
List all systemd units currently loaded by systemd (Use the Space or PgDn keys on your keyboard to page through the output).
systemctl
List all currently active configuration units that systemd is managing.
systemctl list-units
systemctl list-units --all
systemctl list-units --type service (Restrict the unit listing to a particular unit type using the --type option).
systemctl list-units --type service -all (list all, including inactive ones).
Synopsys of the above commands
Reload: Used to reload the configuration of a running service.
Restart: Used to restart (Stop/Start) a running service.
reload-or-restart: Used to reload a service default, but if reload is unavailable for that service. It will restart it.
Enable or Disable Service: Use this to enable or disable any service on your system.
The enabled service autostarts on system boot. This is a similar option for the system to chkconfig for the SysV init.
Enable: Enable service to start on system boot.
Disable: Disable service to not start on system boot.
Status of Service: Check the status of any service.
Status: Check the current status of a service.
Check Service is Enabled or Disabled: Check whether any service is active or enabled.
is-active: Check the current service status.
is-enabled: Check if the service is enabled to start on system boot.
Comments