Saturday, 31 December 2011

Unmetered Bandwidth

Talking about bandwidth it is very crucial to understand what is bandwidth. Bandwidth is basically the amount which you have available to transfer your website data or web pages from web server to the browser of the user who visits your site. Web pages and graphics consume bandwidth or capacity on the web. Bandwidth and disk space cost money. Technically, bandwidth is the data-carrying capacity of a network, indicating the maximum amount of data that can pass from one point to another per unit time.

With the tied and the time web hosting industry is growing rapidly with fast pace and advancements coming in. Web hosting companies have increasingly begun to tout “unlimited bandwidth” or “unmetered bandwidth” as a major selling point of their hosting plans. These claims are generally seen as nothing more than a marketing ploy. Unlimited Bandwidth is a web hosting plan feature that deals with the transfer or traffic your website has. It is useful to both personal and business websites assuming they have sufficient volumes of visitors and do not wish to purchase a dedicated server web hosting. Whereas Unmetered Bandwidth relates with the bandwidth which can not be measured. It generally refers to offering, explicitly mention an initial limit that once reached will be upgraded upon request (no charge). The only reason that a web host is able to make unlimited bandwidth incentives possible is because most websites use only a fraction of the bandwidth available to them.

Both the Unlimited & Unmetred Bandwidth can be said interlinked with each other. In unlimited bandwidth every user who visits your site uses some resources, so with unlimited bandwidth these resources are free. With unlimited bandwidth hosting you can have as much traffic to your website as you want – your hosting account has “unmetered bandwidth”. In unmeterd the system does in fact measure the data traffic consumption. What they don’t do (or claim not to do) is to put a limit to the consumption. In other words we can say that, “Unmetered bandwidth” refers to the speed of data-transfer, whereas on the other hand, “Unlimited bandwidth” ideally means that as far as the amount of data-transfer goes, you can download or upload as much data as you want in a given period of time. With your unmetered server’s unlimited bandwidth plan, you never have to worry about unwanted bandwidth overage fees, plus you can always upgrade your plan to fit your hosting needs.

With the many limitations with your website on the internet user may choose for the unlimited bandwidth as it is one of the attractive options because if it’s unlimited then you never need to worry about running out.

Saturday, 26 November 2011

Enabling the slow query log

MySQL reports how much time it took to execute a query.

Step 1: Enable slow log query, set a slow log query log file, and set the log_query_time in my.cnf.
Edit the MySQL configuration file.


vi /etc/my.cnf



 

In the [mysqld] section add/edit the following variables


long_query_time = 0
slow_query_log = 1
slow_query_log_file=/var/log/mysqld.slow.query.log



We are setting the log_query_time variable to 0. Any MySQL query taking more than 0 seconds will be logged.

 

Step 2: Create the file /var/log/mysqld.slow.query.log and set the system user mysql as the owner.


touch /var/log/mysqld.slow.query.log
chown mysql.mysql /var/log/mysqld.slow.query.log



 

Step 3: Restart MySQL server


/etc/init.d/mysqld restart



 

Step 4: Watch the slow query log using the tail command.


tail -f /var/log/mysqld.slow.query.log



 

A sample entry on my server looks like this:

[root@localhost ~]# tail -f /var/log/mysqld.slow.query.log 
SET timestamp=1255345490;
SELECT `privilege`.* FROM `privilege` WHERE ( name = 'view service invoices"') LIMIT 1;
# User@Host: biz_1[biz_1] @ localhost []
# Query_time: 0.000273 Lock_time: 0.000104 Rows_sent: 1 Rows_examined: 1
SET timestamp=1255345490;
SELECT * FROM organization_details;
# User@Host: biz_1[biz_1] @ localhost []
# Query_time: 0.000048 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 1
SET timestamp=1255345490;
# administrator command: Quit;


If you observe the log entry, the last query took 0.000048 seconds.

Enable MySQL General Query

Enabling the general query log


Step 1: Set your log file in /etc/my.cnf


vi /etc/my.cnf



In the [mysqld] section specify the general log file name:


log=/var/log/mysqld.general.log



 

Step 2: Create the file and make sure it is owned by the system user mysql


touch /var/log/mysqld.general.log
chown mysql.mysql /var/log/mysqld.general.lo



 

Step 3: Enable the general log in the MySQL client. Connect to the MySQL server using the MySQL client and execute this query.


SET GLOBAL general_log = 'ON';



 

Step 4: Restart mysqld and watch the logs


/etc/init.d/mysqld restart



 

To watch the logs use the tail command.


tail -f /var/log/mysqld.general.log



 

A sample entry in my general query log looks like:

[root@localhost ~]# 
[root@localhost ~]# tail -f /var/log/mysqld.general.log
091012 13:52:53 2 Query SELECT `profile`.* FROM `profile` WHERE (user_id = 1) LIMIT 1
2 Query SELECT `u`.`user_id`, `u`.`email`, `u`.`status`, `u`.`mode`, `u`.`hash`, `u`.`created`, `u`.`alt_email`, `u`.`host_created`, `u`.`ip_created`, `u`.`user_timezone`, `p`.*, `r`.`name` AS `primaryRoleName`, `urp`.`email` AS `reportsToEmail`, `b`.`branch_name` FROM `user` AS `u`
LEFT JOIN `profile` AS `p` ON p.user_id = u.user_id
LEFT JOIN `role` AS `r` ON r.role_id = p.primary_role
LEFT JOIN `user` AS `urp` ON urp.user_id = p.reports_to
LEFT JOIN `branch` AS `b` ON b.branch_id = p.branch_id WHERE (u.user_id = '1')
2 Query SELECT `profile`.* FROM `profile` WHERE (user_id = 1) LIMIT 1
2 Query SELECT `privilege`.* FROM `privilege` WHERE ( name = 'view service invoices"') LIMIT 1
2 Query SELECT * FROM organization_details
2 Quit

Monday, 21 November 2011

[FIX] Cannot update domain or sub domain configuration in IIS

APPLIES TO:


  • Parallels Plesk Panel for Windows



 Symptoms


When attemting to reconfigure domain or sub domain configuration in IIS using thewebsrvmng.exe  Plesk tool an error message is received. For a domain:
"%plesk_bin%websrvmng.exe" --reconfigure-vhost --vhost-name=domain.com

The system cannot find the file specified. (COM Error 80070002) For a sub domain:
"%plesk_bin%websrvmng.exe" --update-subdomain --vhost-name=domain.com --subdomain=sub

The system cannot find the file specified. (COM Error 80070002) at configSubdomain(sub.domain.com)


Cause


Some default folders for Plesk domain are missing in (sub) domain root folder.


Resolution


The missing folders need restoring using the Plesk reconfigurator.  This feature checks files permissions + restores missing folders + creates missing system users for (sub) domain. It can be executed via command line as follows:
reconfigurator.exe /check-permissions=domain.com

or using Plesk Panel.

Plesk, Domains, domain.com, check on problem domain, click `Check permissions`.

This should eliminate the source and the command should running properly. For a subdomain, the parent domain needs to be checked.


Monday, 31 October 2011

Linux: /tmp: Read-only file system Error

One of the server that  has problem as below when I want to edit some files in crontab:


$ crontab -e
/tmp/crontab.XXXX1ibTLU: Read-only file system



It shows that the /tmp partition is unwriteable. The read-only has been mounted as read-only because file-system facing some error. To fix this, we need to do file system check (fsck) for /tmp partition. Before we do fsck, we need to unmount the directory but following error occurred:


$ umount /tmp
/tmp: Device or resource busy



It seems like /tmp directory is locked to be unmounted due to some files are already in process/being opened/being executed by some other processes. Using lsof, we can list out all the open files:


$ lsof | grep /tmp
mysqld 2599 mysql 5u REG 7,0 0 6098 /tmp/ibaqFhew (deleted)
mysqld 2599 mysql 6u REG 7,0 0 6099 /tmp/ibC7Yfbn (deleted)
mysqld 2599 mysql 7u REG 7,0 0 6100 /tmp/ibJ8AFbe (deleted)
mysqld 2599 mysql 11u REG 7,0 0 6101 /tmp/ibrLO9t5 (deleted)



As we can see that mysqld is locking some temporary files in /tmp directory. The 2nd column shows PID of the locking process. We need to stop this process using kill command:


$ kill -9 2599



Only then we are able to unmount the /tmp:


$ umount /tmp



Make sure that there is no error being prompt during the unmounting process. Now we can proceed to do fsck with -f (force) and -y (always accept prompt as Yes) to automate the file system check process:


$ fsck -f -y /tmp
fsck 1.39 (29-May-2006)
e2fsck 1.39 (29-May-2006)
/usr/tmpDSK: recovering journal
Pass 1: Checking inodes, blocks, and sizes
Deleted inode 6097 has zero dtime. Fix? yes

Inodes that were part of a corrupted orphan linked list found. Fix? yes

Inode 6098 was part of the orphaned inode list. FIXED.
Inode 6099 was part of the orphaned inode list. FIXED.
Inode 6100 was part of the orphaned inode list. FIXED.
Inode 6101 was part of the orphaned inode list. FIXED.
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Inode bitmap differences: -(6097--6101)
Fix? yes

Free inodes count wrong for group #3 (2025, counted=2030).
Fix? yes

Free inodes count wrong (127695, counted=127700).
Fix? yes

/usr/tmpDSK: ***** FILE SYSTEM WAS MODIFIED *****
/usr/tmpDSK: 316/128016 files (3.2% non-contiguous), 66394/512000 blocks



Now the file system has been modified and fixed. We can remount back the partition using following command:


$ mount -a



You should able to use back the /tmp partition at this time, as well as I can do some changes on the crontab!

How to change mail attachment size

To change mail attachment size, we have to change 3 settings.

To change mail attachment size, we have to change 3 settings.
Change mail size in postfix

Postfix is MTA, so we have to change its setting to make it transfer large mail.

If you want to make it allow to transfer mail which size is less than 100Mb, just change 'message_size_limit' setting:

# ---- Run below command in terminal ---- 
# postconf -e message_size_limit='104857600' 
# ---- Restart postfix to make it work ---- 
# /etc/init.d/postfix restart


Note:

  • 104857600 is equal to 100MB x 1024 KB x 1024 Bit.

  • Normally, mail will be encoded before transferred, so the actual mail size will be larger than 100MB, you can simplily increase to 110Mb or 120Mb to make it work as expected.


----
If you use mail clients such as Outlook, thunderbird to fetch/send mails, it's enough to sent large attachments in mail.
If your users will use webmail as mail client, you have to change two more settings:
Change PHP setting to allow to upload large attachment

You should change 'memory_limit', 'upload_max_filesize' and 'post_max_size' in /etc/php.ini (RHEL/CentOS) or/etc/php5/apache2/php.ini (Debian/Ubuntu).

memory_limit = 200M; 
upload_max_filesize = 100M; 
post_max_size = 100M;


Change Roundcube webmail to allow to upload large attachment

Change same settings in .htaccess which under roundcube root directory, it's /usr/local/cpanel/base/3rdparty/roundcube/ (RHEL/CentOS) or  /usr/share/apache2/roundcube/ (Debian/Ubuntu) by default.

php_value upload_max_filesize 100M 
php_value post_max_size 100M


Restart apache web server



# ---- For RHEL/CentOS users ---- 
# /etc/init.d/httpd restart 
# ---- For Debian/Ubuntu users ---- 
# /etc/init.d/apache2 restart




Sunday, 30 October 2011

PCI compliance – Vulnerability SSL Version 2 (v2) Protocol Detection linux

Simple enough to fix on apache.

Load the ssl.conf file and add at the bottom the following:

SSLProtocol -ALL +SSLv3 +TLSv1

then restart apache.

To test the connection on the command line type:

openssl s_client -ssl2 -connect google.com:443