Author Archives: manishsanger

release_port_8080

Release port 8080 on Windows

Sometimes when we run java application on windows platform, it doesn’t start tomcat and says port 8080 already in use. To resolve this issue, we have to kill the process running on port 8080. Below are the few simple steps to release port 8080.

Start you command prompt as an administator:

cmd_run_as_administrator

Run the following command to get the process which is using the port 8080:

netstat -o -n -a | findstr 0.0:8080

To kill the process running on port 8080:

taskkill /F /PID <pid>

release_port_8080

That’s it, have fun!!

NoSQL

What is NoSQL?

NoSQL Databases is also called as “Not Only SQL”. NoSQL does not prohibit the SQL (Structured query Language). It employs less Consistency model for storage and retrieval of data than traditional relational databases. Some of the NoSQL databases are completely non-relational, others avoid relational functionalities as Fixed table schemas and joins. Most of the NoSQL databases are highly optimized “Key-Value stores” or “tuple stores”, for simple insertion and retrieval operations. NoSQL approach started with the goal of simple schema design, horizontal scalability, higher performance & availability etc.

 

Types of NoSQL Databases?

We can classify the NoSQL databases on the basis of data model, these are as follows:

  1. Wide-Column – HBase, BigTable, Apache Cassandra, Amazon SimpleDB, HyperTable

  2. Document – MongoDB, CouchDB, CouchBase

  3. Key-Value – DynamoDB, Riak, Redis, Voldemort

  4. Graph – Neo4j, Virtuoso, Allegro

java7 install

Install Java7 on Linux (Ubuntu 12.04)

If you are running an older version on java on your Ubuntu 12.04 environment, you must remove it before installing Java7. Do the following to remove:

$sudo apt-get purge openjdk*

If you installed java 7 earlier and having problem with java then you have to do the following to remove it:

$sudo rm /var/lib/dpkg/info/oracle-java7-installer*
$sudo apt-get purge oracle-java7-installer*
$sudo rm /etc/apt/sources.list.d/*java*
$sudo apt-get update

Installing Oracle Java7 on Ubuntu 12.04 LTS:

$sudo add-apt-repository ppa:webupd8team/java
$sudo apt-get update
$sudo apt-get install oracle-java7-installer

You will be prompted couple of times for permissions and Oracle Policy agreement [You must be agreed to Oracle policies to install Java :-)].

That’s it! Now you have Oracle Java7 installed on your Ubuntu 12.04 environment, to check the Java version run the following on terminal:

$java -version
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

Or You can check the java version by searching java in Ubuntu dashboard.

Oracle Java 7 plugin Control Panel -> General Tab -> About

java7 version Ubuntu 12.04

Install APC

How To: Install APC

APC is Alternative PHP Cache. APC is an opcode cache that speed up your PHP applications, by caching both PHP code and user variables. Adding APC to an application improves application response time, reduces server load and make your users happy. This is a free, open, and robust framework for caching and optimizing PHP intermediate code. APC reads your PHP files, parses them into binary format and then caches them in memory so that each request for your PHP files and PHP library files can be served from the parsed cache.

You can see the difference by tracing your code through Xdebug or Zend debugger. You will definately notice a big difference.

Installing APC on RHEL:

First, login as Root User using “su” command.

$pecl install apc

If pecl doesn’t work, install php-devel

$yum install php-devel.i386

if still doesn’t work, if the pecl don’t work then, Please install PEAR first

Then create and add the following to apc.ini

$echo extension=apc.so &gt; /etc/php.d/apc.ini
extension=apc.so
apc.enabled="1"
apc.shm_segments="1"
apc.shm_size="100"
apc.ttl="5"
apc.user_ttl="5"
apc.gc_ttl="5"
apc.file_update_protection="2"
apc.enable_cli="1"
apc.max_file_size="1M"
apc.write-lock="1"
apc.report_autofilter="0"
apc.include_once_override="0"

Restart the Apache webserver:

$service httpd restart

Installing APC on Ubuntu:

$sudo apt-get install php-apc
$sudo /etc/init.d/apache2 restart

That’s it!!! You are done, APC is installed on your web server.

memcached

How to install Memcache on Linux RHEL6.2?

$yum install memcached

Most important value to configure is CACHESIZE, which is cache size on Megabytes. Example Following configuration use 512 Mb memory for Memcached

$vi /etc/sysconfig/memcached

change CACHESIZE to 512, i.e. CACHESIZE=”512″

# Set Memcached to start automatically on boot

$chkconfig memcached on

# Start Memcached

$/etc/init.d/memcached start

## OR ##

$service memcached start

To check the version of Memcached

$memcached -h

#install zlib package if not installed, I have to do that

$wget http://www.zlib.net/zlib-1.2.5.tar.gz ( Go to http://www.zlib.net/ and take the latest version)
$tar xvfz zlib-1.2.5.tar.gz
$cd zlib-1.2.5
$./configure
$make
$make install
$wget http://pecl.php.net/get/memcache-2.2.5.tgz
$tar xvfz memcache-2.2.5.tgz
$cd memcache-2.2.5
$phpize

(phpize:Command not found case, run yum install php-devel then YES)
Again

$phpize
$./configure –enable-memcache
$make
$make install

#search for PHP.ini file, if you donot know

$php -i | grep php.ini
Configuration File (php.ini) Path =&gt; /etc/
Loaded Configuration File =&gt; /etc/php.ini
$vi /etc/php.ini
#Add the following into PHP ini file
[code lang="bash"]
extension = memcache.so

#restart apache

$/etc/init.d/httpd restart

or

$service httpd restart

#To check is memcache extension loaded in php, execute following command.

$php -i | grep memcache
#you will get the output like
memcache
memcache support =&gt; enabled
memcache.allow_failover =&gt; 1 =&gt; 1
memcache.chunk_size =&gt; 8192 =&gt; 8192
memcache.default_port =&gt; 11211 =&gt; 11211
memcache.default_timeout_ms =&gt; 1000 =&gt; 1000
memcache.hash_function =&gt; crc32 =&gt; crc32
memcache.hash_strategy =&gt; standard =&gt; standard
memcache.max_failover_attempts =&gt; 20 =&gt; 20
Registered save handlers =&gt; files user sqlite memcache
PWD =&gt; /usr/src/memcache-2.2.5
_SERVER["PWD"] =&gt; /usr/src/memcache-2.2.5
_ENV["PWD"] =&gt; /usr/src/memcache-2.2.5

#you can also check this information using phpinfo() in php.

PHP

How to downgrade PHP version from 5.3.X to 5.2.X on Linux RHEL6.2?

Login as a Root User using “su” command

$yum remove php*

Install the atomic repositories like this

$wget -q -O – http://www.atomicorp.com/installers/atomic | sh
$vi /etc/yum.conf

edit /etc/yum.conf and add this line at the end of the file

exclude=php*5.3*

This is very important for not upgrading those versions of PHP and MySQL

$yum update

and, now you have php 5.2.17 running on your server