Thursday, December 18, 2014

List all databases in Postgresql and their sizes and ordering by size descending

List all databases and size



psql -c "select p1.datname as DB_Name, pg_size_pretty(pg_database_size(p1.datname)) as DB_Size from pg_database p1 order by pg_database_size(p1.datname) desc;"


List size of a particular database.

select pg_database_size('databaseName');


Thursday, June 19, 2014

Checkout sizes of MySQL databases

Checkout sizes of MySQL databases

If you are trying to find which databases are actually taking up how much space but only have one huge ibdata1 in your /var/lib/mysql and the directories inside your mysql data directory don't represent the actual database sizes?
Go for this

Run from mysql command prompt with root permission

SELECT table_schema AS "Database name", SUM(data_length + index_length) / 1024 / 1024 AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema;


Result will be like this.

+--------------------+---------------+
| Database name      | Size (MB)     |
+--------------------+---------------+
| information_schema |    0.00781250 |
| db1               | 1753.67187500 |
| db1_live          | 3458.10937500 |
| db1_rpt_live      |   82.37500000 |
| mysql              |    0.61531639 |
+--------------------+---------------+
5 rows in set (29.33 sec)

Thursday, May 29, 2014

Show or Hide Liferay Portal name and version details in HTTP response headers

The default behavior for Liferay Portal is to return the name and version details in HTTP response headers.




This poses a potential security risk as Liferay Portal is advertising itself to the world.

This is not ideal for public facing web web sites which are open to attack by third-parties.

This article outlines the configuration support in Liferay Portal 6.1.2 Enterprise Edition (EE) for adjusting the Liferay Portal name and version details returned in HTTP response headers.

Configuration

Liferay Portal Properties

Edit file "LIFERAY_HOME/portal-ext.properties".
Add the following snippet.
Adjust property "http.header.version.verbosity" to suit your web site requirements.

http.header.version.verbosity=partial
or
http.header.version.verbosity=Liferay Portal Enterprise Edition

Thursday, March 27, 2014

How to set jvmRoute in JBoss EAP 6 or JBoss CE 7

For session stickiness, failover and loadbalancing support mod_jk/mod_cluster relies on a jvmRoute property set at JBoss EAP/CE configuration. If you are using mod_jk, make sure that jvmRoute attribute is set and that the jvmRoute attribute value matches your worker name in workers.properties.

Set instance-id="<value>" on the web subsystem.


  • Using CLI:

     /subsystem=web:write-attribute(name=instance-id,value=<value>)  

  • XML (standalone.xml / domain.xml):

    <subsystem xmlns="urn:jboss:domain:web:1.1" ... instance-id="<value>">
or

Set jvmRoute system property.


  • Using CLI:

      /system-property=jvmRoute/:add(value=<value>,boot-time=true)   

  • XML (standalone.xml / domain.xml):

         <system-properties>
<property name="jvmRoute" value="<value>"/>
 </system-properties>

Note that the instance-id setting gets preference over the jvmRoute system property if you specify both settings at once.

You can use expressions in the instance-id like instance-id="${my.jvmRoute}" and override the value using standalone.sh option (or Java VM option). For example:
$JBOSS_HOME/bin/standalone.sh -Dmy.jvmRoute=node1
Usually you need to specify unique value to jboss.node.name system property for each node in cluster environment. So you may set the instance-id like instance-id="${jboss.node.name}" then specify unique jboss.node.name to standalone.sh like:
$JBOSS_HOME/bin/standalone.sh -Djboss.node.name=node1

Note that be careful to use jboss.node.name (or jboss.server.name) system properties in domain environment. they are set automatically based on host configuration by default. jboss.node.name is "hostname:servername" format by default and it contains colon character (":") which is not a valid worker name for mod_jk.
The name of the worker can contain only the alphanumeric characters [a-z][A-Z][0-9][_-] and is case sensitive. And jboss.server.name is not unique across hosts, so you have to make sure to set them unique value.

Monday, February 24, 2014

Install and configure TrueType fonts in Linux


  1. Download *.ttf fonts to a directory and add it to the font path, a list of directories containing fonts:
  2. Create a directory for new fonts
    1. mkdir /usr/share/fonts/ttf
  3. Move the font files to the new font directory
    1. mv *.ttf /usr/share/fonts/ttf
  4. Navigate to the font directory
    1. # cd /usr/share/fonts/ttf
  5. Create fonts.scale and fonts.dir
    1. # mkfontscale && mkfontdir
    2. # fc-cache

Friday, January 31, 2014

optimizing mod_jk for JBoss EAP

While optimizing the configuration in Apache HTTP Server, mod_jk, mod_proxy, mod_cluster and JBoss Platform typically resolves any and all problems and errors in load balancing, there are exceptions (such as long running servlets that require additional optimization).
In most cases, a correctly tuned configuration is the catch all for mod_jk issues. This section discusses some problems and how the configuration can be improved to avoid them.

Common Problems

The list below outlines some common configuration problems. Ensuring your implementation is not subject to one of these may assist to resolve your issue.
A firewall between Apache HTTP Server and JBoss Enterprise Application Platform
If there is a firewall between Apache HTTP Server and JBoss Enterprise Application Platform and no socket_keepalive parameter is set, the firewall can close connections unexpectedly.
example:
worker.node1.socket_keepalive=1

JkShmFile on a NFS share

Placing the JkShmFile on a NFS share can cause unexplained pauses in mod_jk and odd behavior. It is strongly recommended that the JkShmFile always be placed on local storage to avoid problems.

No CPing/CPong set

The CPing/CPong property in mod_jk is the most important worker property setting, allowing mod_jk to test and detect faulty connections. Not setting this parameter can lead to bad connections not being detected as quickly which can lead to web requests behaving as if 'hung'.
example:
worker.node1.ping_mode=A

Running an old version of mod_jk.

There are known issues with sticky sessions in versions prior to mod_jk 1.2.27.

MaxClients higher than maxThreads

Setting the MaxClients parameter in Apache HTTP Server higher than the maxThreads setting in JBoss (with a high load on the server) will result in Apache HTTP Server overwhelming the JBoss instance with threads which will cause hung and/or dropped connections.

No connectionTimeout parameter set

The connectionTimeout parameter set in JBoss is required for proper maintenance of old connections.

Running an older version of EAP.

There is a bug in EAP 4.2 base and EAP 4.2 CP01 which causes sockets to be left in the CLOSE_WAIT state, thus causing the appearance of hung requests again. This issue has been reported and fixed https://jira.jboss.org/jira/browse/JBPAPP-366

Thursday, January 30, 2014

Lots of ext4-dio-unwrit processes in the server.

Issue

  • There are a lot of processes with the name ext4-dio-unwrit running on the system.
  • What are those processes?
  • Why so many ext4-dio-unwrit processes?
In RHEL 5.x and later you can see these processes are running. 

Root Cause

ext4-dio-unwrit processes are workqueues statically created at mount time of the filesystem, one workqueue per-cpu for each filesystem.