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 









Thursday, June 4, 2015

Can't connect to MySQL server on 'localhost' (10055)"


Cause of MySQL Error 10055?

This is more of an Operating System Error than a MySQL error.  Each time your website runs a query you open a connection to the Database, run the query, then close the connection.  Each time this happens your Server allocates a dynamic port for use by MySQL and your Website.  For Websites like mine which may run 2000+ Queries per second, this means that 2000+ dynamic ports must be set aside for these connections.  Sometimes your server gets under load and the operating system can't recycle these ports fast enough, leading you to run out of ports and then your server throws a 10055 Error.

By default Windows Server 2008 R2 has 16838 Ports designated for Dynamic use.  The default ranges are 49152 - 65535.  However this can be extended to a wider range of ports.

Fix MySQL Error 10055:

To fix the problem you need to increase the number of dynamic ports.
Running the following Commands will give give you 50000 ports for dynamic use.

On Windows Server 2008 R2
Open command Prompt

Type the following:
netsh int ipv4 set dynamicport tcp start=10000 num=50000
Press Enter

Type the following
netsh int ipv4 set dynamicport udp start=10000 num=50000
Press Enter

Monday, June 1, 2015

Protected directory cannot be enabled: "columns siteId, path are not unique"

Symptoms

When trying to add a new customer and protected directory in Parallels Plesk, the protected directory cannot be enabled:
Error message : ProtDir_IIS::update() failed: Add Protected Directory failed: columns siteId, path are not unique (Error code 1)

Cause

The protected directory was not synchronized properly.

Resolution

Synchronize the protected directories database using the following command:

"%plesk_cli%\repair.exe"  --synchronize-protected-directories-storage