What Do I Need?
- A Dedicated or VPS Linux Server
- CentOS
What is Debugging?
Every now and again you’re going to need to do some troubleshooting and that will sometimes mean some debugging is needed too. Any server can suffer from hardware, software, and connectivity problems.
- Check the Hardware
- If you have access to the physical hardware you should have all of the cable connections, internally and externally checked.
- Check your ethernet hardware connection:
sudo ethtool eth0
- Check your bios/uefi hardware, including memory:
sudo dmidecode --type memory
- If the information summary looks correct, but you still suspect a memory problem, it’s time to deploy an additional tool, Memtest86. If you’re running into numerous memory problems, you should check the edac_core module:
sudo modprobe edac_core
- After a moment you should then check the following:
sudo grep “[0-9]†/sys/devices/system/edac/mc/mc*/csrow*/ch*_ce_count
- Define your Problem
- Your web server has gone rogue; however, you can’t work out what’s happening. Before you attempt to deal with the end result, you need to lock down exactly what the problem is. For example, if your users are complaining about a problem with a server application, first make sure it’s not actually failing on the client’s side. Is the problem with the server or the application?
- To check if an application is running try the two following commands:
sudo ps -ef | grep apache2 sudo netstat -plunt | grep apache2
- If it’s shown that, for example, the Apache web server isn’t running, you can start it with the following command:
sudo service apache2 start
- Using Top
- Another super useful tool for systems debugging is Top. Use it to check load average, swap and which processes are using resources. Top shows all of a Linux server’s currently running processes.
- You’ll receive a wealth of useful troubleshooting information. To find the process consuming the most memory, sort the process list by pressing the ‘M’ key. To see which applications are using the CPU cycles, press ‘P’; and to sort by running time, press ‘T’. To see more easily which column you’re using for sorting, press the ‘B’ key. You can also interactively filter top’s results by pressing ‘O’, which displays the following prompt:
add filter #1 (ignoring case) as: [!]FLD?VAL
- You can then enter a search for a particular process, for example:
COMMAND=apache
- Check Hard Disk Space
- Running out of space on an active web server is remarkably easy nowadays considering the size of media uploads and various sharable content. To track down these kinds of issues use the following commands:
sudo df -h
This command presents data about your hard disk drives in a human-readable format; for example, it displays storage as gigabytes rather than the exact number of bytes.
sudo df -i
This command displays the number of used inodes and their percentage for the file system.
- You can use other useful optional flags, like ‘T’. This displays your storages file system types:
sudo df -hT
- For deeper analysis, you should use the iostat command. This command is part of the sysstat advanced system performance monitoring tools collection. It reports granular CPU and i/o statistics for block storage devices, partitions, and network file systems.
- The most useful version of this command displays the reads, writes, read kb and write kb per second to the device. It also shows you the average i/o in milliseconds in terms of wait times. The command is used in this way:
iostat -xz 1
Next Steps
Last but definitely not by any means least you should check the server logs. These can usually be found in /var/log in a subdirectory specific to the service itself. For the noob, log files can be indeed quite scary. But despite their innate cryptic nature, you can still learn your way around them. Time, patience, frequent Google searches and, of course, checking back here regularly for more awesome how-to guides is your recommended approach.
Conclusion
Maybe your servers will never attain all time longevity records. Perhaps they’ll never need to be restarted. However, fixing problems and ensuring that your servers are as stable as possible are worthwhile goals. With the concepts described above, you’re well on your way to being able to get started confidently debugging your systems.
- Want suggestions about Best dedicated servers hosting? Click here and read more.