Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Troubleshooting CentOS
Troubleshooting CentOS

Troubleshooting CentOS: A practical guide to troubleshooting the CentOS 7 community-based enterprise server

Arrow left icon
Profile Icon Jonathan Hobson
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (3 Ratings)
Paperback Jun 2015 190 pages 1st Edition
eBook
€17.98 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Jonathan Hobson
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (3 Ratings)
Paperback Jun 2015 190 pages 1st Edition
eBook
€17.98 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
€17.98 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Troubleshooting CentOS

Chapter 2. Troubleshooting Active Processes

A deeper understanding of the underlying active processes in CentOS 7 is an essential skill for any troubleshooter. From high load averages to slow response times, system overloads to dead and dying processes, there comes a time when every server may start to feel sluggish, act impoverished, or fail to respond, and as a consequence, it will require your immediate attention.

In this chapter, we will:

  • Learn about memory management, swap, swappiness, and thrashing
  • Learn how to analyze active processes using the vmstat, top, and ps commands
  • Learn how to monitor the server with iotop, iostat, and lsof
  • Learn about system load and systemd
  • Learn how to find process IDs, identify parent process IDs and orphaned processes, and initiate the various forms of the kill signal

Tuning server performance with memory management and swap

Regardless of how you look at it, the question of memory usage remains critical to the life cycle of a system, and whether you are maintaining system health or troubleshooting a particular service or application, you will always need to remember that the use of memory is a critical resource to your system. For this reason, we will begin by calling the free command in the following way:

# free -m

The main elements of the preceding command will look similar to this:

         Total    used    free    shared    buffers    cached
Mem:      1837     274    1563         8          0       108
-/+ buffers/cache: 164    1673
Swap:     2063       0    2063

In the example shown, I have used the -m option to ensure that the output is formatted in megabytes. This makes it easier to read, but for the sake of troubleshooting, rather than trying to understand every numeric value shown, let's reduce the scope of the original output to highlight...

Managing memory with vmstat

A different aspect of memory management can be achieved by using the vmstat command. Considered to be a summary reporting feature associated with memory, processes, and paging, vmstat can be seen in action by typing:

# vmstat -a

Having used the -a option to call on all active and inactive memory, the most endearing columns shown under vmstat's output are best described as follows:

  • si: This column shows the value swapped in from disk
  • so: This column shows the value swapped out to disk
  • bi: This column shows the value sent to block devices
  • bo: This column shows the value received from block devices
  • us: This column shows the user time
  • sy: This column shows the system time
  • id: This column shows the idle time

The display does look quite confusing to begin with, but for our purposes, we want to concentrate on the following columns contained under the swap column:

free           si   so
1645452          0    0

Where free shows the current allocation of free memory, si shows...

Checking the system load with the top command

The top command can be called at any time by typing:

# top

The top command is the standard command for checking system load (RAM/MEM and CPU). It contains a lot of information related to tasks associated with the kernel; the display is updated in real-time and the highest load factors are expressed as a percentage of CPU or MEM. However, it is important to realize that top may take these values above the expected percentile range. This is because all individual cores are expressed as a percentage and multiple instances of these cores are totaled. For example, a dual core system may have the first core at 70 percent and the second core at 60 percent, and in this instance, top may show a combined result of 130 percent, but you will not know the individual values.

You can use the M key to sort top by memory, but as you will see, rather than simply showing the amount of free memory (as seen with the free command), top will provide the swap details...

Monitoring disk I/O with iotop

Every administrator knows that a system can begin to slow down as a result of heavy disk I/O activities. However, in the role of a troubleshooter you will probably want to know which processes or (in the case of multi-user systems) which users are the culprits that and it is for this reason, you will want to turn to iotop—a tool that shows a list of the most I/O intensive processes in real time in a top-like interface.

To begin with, you will need to install iotop by typing:

# yum install iotop

The download is only small, and to start a discovery session, simply use the following command:

# iotop

Running iotop without any arguments will result in a list of all existing processes regardless of their disk I/O activities, so if you want iotop to only report on processes that are committed to disk I/O activity, you should use the following instead:

# iotop –o

The output is verbose as it works in a way similar to the top command, so familiarity should...

Checking processes with the ps command

For most troubleshooters who want a more complete picture of the processes running on their system, we can employ the ps command in the following way:

# ps aux | less

Alternatively, the information can be displayed in a user-friendly, tree-view mode like this:

# ps axjf | less

If you prefer a little less detail, try:

# ps auxf | less

Of course, there are always a lot more options that we can use with ps. For example, the command can be piped and applied with grep or tail, and you can use explicit statements such as ps -e (to show every process on the system). Alternatively, you can target a specific process by typing the following command:

# ps aux | grep <process_name>

Moreover, you can even extend its usage to show every process (except those running as root) with the following variation:

# ps -U root -u root -N

For a specific user, you can use:

# ps -u <username> u

Finally, you can then obtain additional security information and output the...

Tuning server performance with memory management and swap


Regardless of how you look at it, the question of memory usage remains critical to the life cycle of a system, and whether you are maintaining system health or troubleshooting a particular service or application, you will always need to remember that the use of memory is a critical resource to your system. For this reason, we will begin by calling the free command in the following way:

# free -m

The main elements of the preceding command will look similar to this:

         Total    used    free    shared    buffers    cached
Mem:      1837     274    1563         8          0       108
-/+ buffers/cache: 164    1673
Swap:     2063       0    2063

In the example shown, I have used the -m option to ensure that the output is formatted in megabytes. This makes it easier to read, but for the sake of troubleshooting, rather than trying to understand every numeric value shown, let's reduce the scope of the original output to highlight the...

Managing memory with vmstat


A different aspect of memory management can be achieved by using the vmstat command. Considered to be a summary reporting feature associated with memory, processes, and paging, vmstat can be seen in action by typing:

# vmstat -a

Having used the -a option to call on all active and inactive memory, the most endearing columns shown under vmstat's output are best described as follows:

  • si: This column shows the value swapped in from disk

  • so: This column shows the value swapped out to disk

  • bi: This column shows the value sent to block devices

  • bo: This column shows the value received from block devices

  • us: This column shows the user time

  • sy: This column shows the system time

  • id: This column shows the idle time

The display does look quite confusing to begin with, but for our purposes, we want to concentrate on the following columns contained under the swap column:

free           si   so
1645452          0    0

Where free shows the current allocation of free memory, si shows page...

Checking the system load with the top command


The top command can be called at any time by typing:

# top

The top command is the standard command for checking system load (RAM/MEM and CPU). It contains a lot of information related to tasks associated with the kernel; the display is updated in real-time and the highest load factors are expressed as a percentage of CPU or MEM. However, it is important to realize that top may take these values above the expected percentile range. This is because all individual cores are expressed as a percentage and multiple instances of these cores are totaled. For example, a dual core system may have the first core at 70 percent and the second core at 60 percent, and in this instance, top may show a combined result of 130 percent, but you will not know the individual values.

You can use the M key to sort top by memory, but as you will see, rather than simply showing the amount of free memory (as seen with the free command), top will provide the swap details...

Monitoring disk I/O with iotop


Every administrator knows that a system can begin to slow down as a result of heavy disk I/O activities. However, in the role of a troubleshooter you will probably want to know which processes or (in the case of multi-user systems) which users are the culprits that and it is for this reason, you will want to turn to iotop—a tool that shows a list of the most I/O intensive processes in real time in a top-like interface.

To begin with, you will need to install iotop by typing:

# yum install iotop

The download is only small, and to start a discovery session, simply use the following command:

# iotop

Running iotop without any arguments will result in a list of all existing processes regardless of their disk I/O activities, so if you want iotop to only report on processes that are committed to disk I/O activity, you should use the following instead:

# iotop –o

The output is verbose as it works in a way similar to the top command, so familiarity should make you feel...

Checking processes with the ps command


For most troubleshooters who want a more complete picture of the processes running on their system, we can employ the ps command in the following way:

# ps aux | less

Alternatively, the information can be displayed in a user-friendly, tree-view mode like this:

# ps axjf | less

If you prefer a little less detail, try:

# ps auxf | less

Of course, there are always a lot more options that we can use with ps. For example, the command can be piped and applied with grep or tail, and you can use explicit statements such as ps -e (to show every process on the system). Alternatively, you can target a specific process by typing the following command:

# ps aux | grep <process_name>

Moreover, you can even extend its usage to show every process (except those running as root) with the following variation:

# ps -U root -u root -N

For a specific user, you can use:

# ps -u <username> u

Finally, you can then obtain additional security information and output...

Checking performance with iostat and lsof


Having already discovered how vmstat can be used to provide statistics related to memory management, when troubleshooting performance-related issues an overburdened CPU is yet another area of concern. For this purpose, we can use the iostat command like this:

# iostat

However, to display a more interactive CPU utilization report, you can use the –c option (and provide a numeric value measured in seconds, such as 5 seconds) like this:

# iostat –c 5

Most of the columns should be self-explanatory, but if the system is getting busy, you will see an increase in %iowait, which is used to report on an increase in waiting time for any I/O requests to be completed. Based on this, if the server is transferring or copying a large amount of files, you may also notice additional time being spent at the system level as files will be moved in and out of relevant disk partitions. A feature that is particularly useful when attempting to monitor storage devices in...

Calculating the system load


The system load is a measure of the amount of processing a computer system is currently performing. It is not the perfect way to measure computer performance, but it does provide the troubleshooter with the additional evidence they need to fix a system.

The expression most commonly associated with calculating load is:

Actual Load = Total Load (uptime) / Number of CPUs

As you probably know the number of CPUs, you can calculate the uptime by reviewing the results of the top command or by typing:

# uptime

The output of the preceding command may look like this:

09:59:41 up  2:36,  1 user,  load average: 0.01, 0.02, 0.05

The server load is expressed as a value based on 1 minute, 5 minute, and 15 minute read times. So, by looking at the final three values in the preceding output, we can see that, for this system, the average load was 0.01 (at 1 minute), 0.02 (at 5 minutes), and 0.05 (at 15 minutes).

At this current time, the example system shows no sign of fatigue, but...

Discovering process IDs with pgrep and systemctl


Rather than using ps, another way of discovering a specific process ID is to use the pgrep command like this:

# pgrep <servicename>

In most cases, the use of this command will reveal the process ID or PID. However, by using this approach, it is also possible that the output will provide more than one value. So remember, if an application (such as httpd or ssh) provides one or more process IDs, you can safely assume that the lowest number (which represents the first PID generated by the system) is the most important. This value is known as the PPID or parent process ID.

On the other hand, a more succinct method could be based on taking advantage of systemd by using the following command:

# systemctl status <service_name>.service

The output of the preceding command will look similar to the following sample, and as we can see, the main PID for Apache is 2413:

httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd...
Left arrow icon Right arrow icon

Description

It is assumed that you will already have a server up and running, you have a good working knowledge of CentOS, and you are comfortable with the concept of working with those services used by your server.

Who is this book for?

It is assumed that you will already have a server up and running, you have a good working knowledge of CentOS, and you are comfortable with the concept of working with those services used by your server.

What you will learn

  • Consider the need to understand, manipulate, and make use of the relevant system log files
  • Analyze, review, and make decisions regarding how and what to do with troublesome active processes on a CentOS server
  • Discover how to approach issues regarding the network environment
  • Approach issues regarding package management and learn how to make the necessary steps to diagnose and fix the problems found in relation to their YUM and RPMbased needs
  • Diagnose and troubleshoot issues related to Samba, NFS, and various external storage methods
  • Diagnose and troubleshoot issues related to iptables, SELinux, some common firewalls, shell access, and SSH

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jun 24, 2015
Length: 190 pages
Edition : 1st
Language : English
ISBN-13 : 9781785289828
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jun 24, 2015
Length: 190 pages
Edition : 1st
Language : English
ISBN-13 : 9781785289828
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 108.97
Troubleshooting CentOS
€24.99
Mastering CentOS 7 Linux Server
€41.99
CentOS 7 Linux Server Cookbook, Second Edition
€41.99
Total 108.97 Stars icon

Table of Contents

11 Chapters
1. Basics of Troubleshooting CentOS Chevron down icon Chevron up icon
2. Troubleshooting Active Processes Chevron down icon Chevron up icon
3. Troubleshooting the Network Environment Chevron down icon Chevron up icon
4. Troubleshooting Package Management and System Upgrades Chevron down icon Chevron up icon
5. Troubleshooting Users, Directories, and Files Chevron down icon Chevron up icon
6. Troubleshooting Shared Resources Chevron down icon Chevron up icon
7. Troubleshooting Security Issues Chevron down icon Chevron up icon
8. Troubleshooting Database Services Chevron down icon Chevron up icon
9. Troubleshooting Web Services Chevron down icon Chevron up icon
10. Troubleshooting DNS Services Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(3 Ratings)
5 star 33.3%
4 star 33.3%
3 star 33.3%
2 star 0%
1 star 0%
Amazon Customer Mar 12, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Awesome book!
Amazon Verified review Amazon
Ed P Jul 10, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Jonathan Hobson's book is a handy intro to troubleshooting a variety of issues that CentOS system admins may encounter. In addition he covers some basic information on installing and configuring some of the more popular Linux services, like MySQL/MariaDB, file shares and DNS services. While not exhaustive in any one area, it does provide a place to start when trying to resolve problems on the operating system.
Amazon Verified review Amazon
Human Jan 29, 2017
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
This book mainly seems to be composed of various basic Linux commands with a few examples. I have a few months experience supporting small web servers (mainly VPS's) with no prior server experience and I don't feel that I learned a lot from this, though it probably would have been an OK way to get started when I was first trying to learn if this wasn't covered in the training I got.I need much more detail than this for work.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.