Monday, July 6, 2015

How to change the primary IP addres of a WHM/cPanel server

Steps in WHM:
  • Log into WHM and go to Basic cPanel & WHM Setup
  • Change the Primary IP here with the option that says "The IP address (only one address) that will be used for setting up shared IP virtual hosts"
  • Note: This might not actually be necessary.

Log in to SSH, and do the following:
  • Edit /etc/sysconfig/network-scripts/ifcfg-eth0
    • Change the IPADDR and GATEWAY lines to match the new IP and Gateway for the new ip

  • Edit /etc/sysconfig/network
    • Change the GATEWAY line here if it does not exist in the ifcfg-* file.
  • Edit /etc/ips
    • Remove the new primary IP from this file if it is present
    • Add the old primary IP to this file with the format ::
       
  • Edit /var/cpanel/mainip
    • Replace the old primary IP with the new primary IP
  • Edit /etc/hosts
    • Replace the old primary IP with the new one if needed. The hostname's dns will need to be updated too
  • Restart the network service to make the new IP the primary
    • service network restart
    • Note: You're probably going to be disconnected at this point, and have to log in to ssh using the new primary ip.
  • Restart the ipaliases script to bring up the additional IP
    • service ipaliases restart
       
  • Run ifconfig and make sure all IPs show up correctly
  • Update the cpanel license to the new primary IP 
  • Verify you can still log in to WHM and there is no license warning

Saturday, June 13, 2015

Check Current and Past Server Load

What causes high server loads?
Excessive usage of any of the following items can typically cause this issue:

  • CPU
  • memory (including swap)
  • disk I/O
How can I check these items?
That depends you want to review their current resource usage, or historical resource usage.
System Activity Reporter (SAR) is an important tool that shows system admins an overview of the server machine with status of various metrics at different points of time.

To view the load averages for your server from the 23rd of the month:
Code:
[user@technoquick ~]$ sar -q -f /var/log/sa/sa23
'-q' to obtain the load average information, and '-f' to specify which sar file to obtain the information from.
Result:
Linux 2.6.18-348.16.1.el5 (technoquickfix.com)   23/05/2015
12:00:01 AM   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15
12:10:01 AM   5         331         0.83      1.20      1.39
12:20:01 AM   7         316         1.20      0.78      1.01
12:30:01 AM   6         317         0.51      0.67      0.84
12:40:01 AM   5         312         0.75      0.62      0.73

Here’s an explanation of the above variables:
“runq-sz” run queue length, which is the number of tasks waiting for run time.
“plist-sz” is the number of tasks in the task list.
“1davg-1″ refers to the system load average over the
 last minute. The load average is calculated as the average number of 
runnable or running tasks (R state), and the number of tasks in 
uninterrupted sleep (D state) over the specified interval.
“ldavg-5″ is the system load average for the past 5 minutes.
“ldavg-15″  the system load average for the past 15 minutes.

Current CPU usage:

Code:
 [user@technoquickfix ~]$ top c 
Tip: hit "P" to sort by processes that currently consuming the most CPU.

Historical CPU usage:
Check the "%idle" column:
Code:
 [user@technoquickfix ~]$ sar -p 

Current memory usage:

Code:
 [user@technoquickfix ~]$ free -m 

Historical memory usage:
This depends on the version of sar, which used to use '-r' to show %memused and %swpused (swap memory used), but later changed to '-S' to show %swpused.
Check "%memused" and "%swpused":
Code:
 [user@technoquickfix ~]$ sar -r 

Current disk I/O usage:

This will print the disk usage statistics 10 times, every 1 seconds. 
Check the %util column.

Code: 
 [user@technoquickfix ~]$ iostat -x 1 10 

Historial disk I/O usage:
Code:
 [user@technoquickfix ~]$ sar -d