Monday, August 27, 2012

ORA-01034: ORACLE not available ORA-27101: shared memory realm does not exist Linux-x86_64 Error: 2: No such file or directory

I get the following issue when connecting to Oracle DB via SID:

$sqlplus myusername/mypassword@sid
SQL*Plus: Release 11.2.0.3.0 Production on Wed Aug 22 00:35:56 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.

ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Process ID: 0
Session ID: 0 Serial number: 0


This server is running Oracle 11.2.0.3 on Redhat 6 64bit.

I made a change in /opt/oracle/112/network/admin/tnsnames.ora

# tnsnames.ora Network Configuration File: /opt/oracle/112/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

PSDS =
    (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = oracle.abc.com)(PORT = 1521))
        (CONNECT_DATA =
            (SERVER = DEDICATED)
            #(SERVICE_NAME = sid)
            (SID=sid)
        )
    )


Then it worked!

Wednesday, August 1, 2012

How to Install Munin on CentOS


Munin is a monitoring tool for servers. It uses RRDtool to log and graph data from your servers. The plugin API is very easy to grasp. Actually, I haven’t read the API documentation yet. I just looked at the output of the plugins and it looks easy to achieve. The data can be accessed through the web.

This guide will walk you through installing and configuring Munin on CEntOS 4.3/4.4 x86. The steps are pretty much the same for later releases of CEntOS, Red Hat, Fedora [Core] and/or Red Hat-based installations.

Munin works by polling your servers for the data hence two applications, Munin and Munin Node. The former periodically gathers data (cronned) and the latter serves the data to the former. Please refer to the following for our example configuration. You can make up a domain if you want Munin to group your servers similar to the live demo.

Munin “Graph Server” – alpha.sample.net (192.168.1.1)
A Munin Node – bravo.sample.net (192.168.1.2)

Thursday, July 26, 2012

Memcache vs APC cache in PHP

I often see this question asked; which is a better caching mechanism for PHP: Memcache or APC cache. I wanted to write about how different both of them are inherently in their very concept.

Memcache for PHP is a distributed caching mechanism. If you have several webservers running under a load balancer serving the same content and you want a caching mechanism to avoid frequent database hits , Memcache is the way to go. When using Memcache you will make the update to one webserver and it would be auto-replicated across all the severs through distributed caching mechanism. Since it requires dealing with network protocols in order to support the distributed part of caching, it is slower compared to APC cache. If data is stored in APC cache, updates need to be done individually on all APC caches on all web servers. They wont be automatically replicated.

However, Memcached is NOT an Opcode cacher like APC. APC when employed will cache all the opcode the first time it is converted and serve the cached version for subsequent HTTP requests. APC can also be used to store data like Memcache but in a non-distributed manner. Most of the times memcache is used to store results of time consuming data queries, so the need to hit database on every query is eliminated and this gives a huge performance benefit.

The good part of both these technologies, is that they are compatible with each other. A good design for scalable websites should be employing APC for opcode caching and data-caching through Memcache to exploit the distributed capabilities across several webservers. If there is just a single webserver, using just APC cache for both opcode and data caching is a good idea.



http://www.4elements.com/blog/2011/07/

Tuesday, July 24, 2012

Convert MyISAM to InnoDB

This shows how to convert MyISAM to InnoDB engine from command line:


#mysql -p -e "show tables in <database_name>;" | tail --lines=+2 | xargs -i echo "ALTER TABLE {} ENGINE=INNODB;" > alter_table.sql


#mysql --database=<database_name> -p < alter_table.sql