Sunday, September 23, 2012

Install memcached on ubuntu

Brie Introduction :
"MemCached is a high-performance, distributed memory object caching system, generic in nature, but originally intended for use in speeding up dynamic web applications by alleviating database load."


Basically, it means it save and retrieve data in the server memory. This is typically used to remove the loads on the database server.
The logic of MemCached is very simple:
  • You verify if MemCached has the data you need, if so you simply use it.
  • if not, you save the data into MemCached and then use it.
run the following command to install memcached:

sudo aptitide install memcached

If you want to change the default settings, simply create the file and update the configuration.
First, create memcached configuration file:
vi  /etc/memcached.conf
Then, change the settings:
# Memory a usage in Mb
-m 16  
# default port  
-p 11211  
# user to run daemon nobody/apache/www-data or else 
-u nobody  
# only listen locally  
-l 127.0.0.1

Save and quit the file. Once this is complete, don't forget to restart the daemon:

sudo /etc/init.d/memcached restart
Now lets install for php

sudo aptitude install php5-memcache
Restart both services:

sudo /etc/init.d/memcached restart ; sudo /etc/init.d/apache2 restart
If you would like additional information about MemCached please visit: http://memcached.org/

Friday, September 21, 2012

Increase file handler on OS level


Open file : vi /etc/security/limits.conf

Add following two lines at bottom of limits.conf file


*       soft    nofile  65535
*       hard    nofile  65535

restart your machine. This will increase number of file handler to 65535. By-Default, Linux having 1024 handler.

Wednesday, September 19, 2012

Linux performance tuning


Kernels 2.6.16 and newer provide a mechanism to have the kernel drop the page cache and/or inode and dentry caches on command, which can help free up a lot of memory. Now you can throw away that script that allocated a ton of memory just to get rid of the cache...
To use /proc/sys/vm/drop_caches, just echo a number to it.


  1. To free pagecache: [root@host]# echo 1 > /proc/sys/vm/drop_caches
  2. To free dentries and inodes: [root@host]# echo 2 > /proc/sys/vm/drop_caches
  3. To free pagecache, dentries and inodes: [root@host]# echo 3 > /proc/sys/vm/drop_caches




This is a non-destructive operation and will only free things that are completely unused. Dirty objects will continue to be in use until written out to disk and are not freeable. If you run "sync" first to flush them out to disk, these drop operations will tend to free more memory.

Monday, September 17, 2012

ERROR 1126 (HY000) at line 38: Can't open shared library 'libmemcached_functions_mysql.so'

Hi,
    I am trying to install mysql-memcached connectivity. Once am trying this

mysql -uroot Producer <sql/install_functions.sql


it is giving me this error


ERROR 1126 (HY000) at line 38: Can't open shared library 'libmemcached_functions_mysql.so' (errno: 22 libmemcached.so.3: cannot open shared object file: No such file or directory)


Can one have idea, how can I resolved it..................

MySQL Optimize Table


The MySQL Optimize Table command will effectively de-fragment a mysql table and is very useful for tables which are frequently updated and/or deleted.

This statement requires SELECT and INSERT privileges for the table.
OPTIMIZE TABLE works only for MyISAMInnoDB, and (as of MySQL 5.0.16) ARCHIVE tables. It does not work for tables created using any other storage engine.
For MyISAM tables, OPTIMIZE TABLE works as follows:
  1. If the table has deleted or split rows, repair the table.
  2. If the index pages are not sorted, sort them.
  3. If the table's statistics are not up to date (and the repair could not be accomplished by sorting the index), update them.


Example:
We have a table called articles which has many thousands of rows which are often inserted, updated and deleted. We can see from the table description below that the table contains variable length column data types:

mysql> desc articles;
+----------------+--------------+------+-----+---------+----------------+
| Field  | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+----------------+
| id  | int(11) | NO   | PRI | NULL    | auto_increment |
| content        | text         | NO   |     | NULL    |                |
| author_id      | int(11)      | YES  |     | NULL    |                |
| article_title  | varchar(120) | YES  |     | NULL    |                |
| article_hash   | int(11)      | YES  |     | NULL    |                |
+----------------+--------------+------+-----+---------+----------------+

6 rows in set (0.00 sec)

If we look at the size of the table on disk we can see that it around 190MB. If we query the table on a column which is indexes we can see the average query response time: 
e.g.
mysql> select count(*) from articles where article_title like 'The%';
+----------+
| count(*) |
+----------+
|    15830 |
+----------+
1 row in set (0.63 sec)

If we now optimize the table with the following command:
mysql> optimize table articles;
+-----------------------+----------+----------+----------+
| Table                 | Op       | Msg_type | Msg_text |
+-----------------------+----------+----------+----------+
| books.articles        | optimize | status   | OK       |
+-----------------------+----------+----------+----------+
1 row in set (6.27 sec)
This has the effect of defragmenting the table and reducing the size of the table on disk down to 105MB. It also has a very positive affect on query performance, reducing the select query response time from 0.63 to 0.39 seconds. N.B. the mysql query cache was turned off to demonstrate.
mysql> select count(*) from articles where article_title like 'The%';
+----------+
| count(*) |
+----------+
|    15830 |
+----------+
1 row in set (0.39 sec)


Monday, September 10, 2012

Status on USCIS

my status on USCIS is being static since last three months or more. And site shows that results will be declared within 90 days. Am not sure how long I have to wait for this status update. Please some one suggest me what should I do?????

Configure apache2 on ubuntu


Configuration Required to see uploaded logo in Producerweb site.

// Ideally it must be on the machine where producerweb is running(Right now it is running on producer machine)
1) Apache 2 must be Installed:
If it is not installed then use the following command to install: sudo apt-get install apache2
Go to location  /var/www/ and create folder images/documentGroup/ and give read and write permissions on this folder(sudo chmod 777 images/documentGroup/ ).

// Must be on producerMachine as the logos on producerweb site will be rendered from here.
2) Run following commands to make configurations
sudo vi /etc/apache2/httpd.conf

Add the following lines in this httpd.conf file.(Change 192.168.10.253 to your local machine IP and gold to your local machine name)

ServerName ec2-50-112-241-186.us-west-2.compute.amazonaws.com
DocumentRoot /home/ubuntu
Alias /ecomail "/home/ubuntu"

<Directory "/home/ubuntu">
Options None
AllowOverride None
Allow From all
</Directory>

3) Now restart apache2 with following 2 commands:
  cd
  sudo service  ../../etc/init.d/apache2 restart

4)Now try to hit url:(replace 192.168.10.253 with your machine IP)
http://192.168.10.253/ecomail/


  4.1)If it says the below, then it means it is not configured properly
"Not Found
The requested URL /ecomail was not found on this server."


  4.2)If it says the below, then it means it is successfully configured
"Forbidden
You don't have permission to access /ecomail/ on this server."