Archive for November, 2010

Bucardo – asynchronous PostgreSQL replication system

Bucardo Overview

Bucardo is an asynchronous PostgreSQL replication system, allowing for both multi-master and multi-slave operations. It was developed at Backcountry.com by Jon Jensen and Greg Sabino Mullane of End Point Corporation, and is now in use at many other organizations. Bucardo is free and open source software released under the BSD license.

Bucardo is at its heart a Perl daemon that listens for NOTIFY requests and acts on them, by connecting to remote databases and copying data back and forth. All the specific information that the daemon needs is stored in the main bucardo database, including a list of all the databases involved in the replication and how to reach them, all the tables that are to be replicated, and how each is to be replicated.

The first step in running Bucardo is to add two or more databases to the main bucardo database. Once this is done, information on which tables are to be replicated are added, as well as any groupings of tables. Then the syncs are added. Syncs are named replication actions, copying a specific set of tables from one server to another server or group of servers.

via Bucardo/Documentation/Overview – Bucardo.

Linux: How to Encrypt and decrypt files with a password

Encrypting a file in linux

http://www.syncroknight.com/img/encrypt.png

To encrypt single file, use command gpg as follows:

$ gpg -c filename

To encrypt myfinancial.info file, type the command:

$ gpg -c myfinancial.info

Output:

Enter passphrase:<YOUR-PASSWORD>

Repeat passphrase:<YOUR-PASSWORD>

This will create a myfinancial.info.gpg file.

Option:

* -c : Encrypt with symmetric cipher.

Caution if you ever forgot your password aka passphrase, you cannot recover the data as it use very strong encryption.

Task: decrypt file

To decrypt file use gpg command:

$ gpg myfinancial.info.gpg

Output:

gpg myfinancial.info.gpg

gpg: CAST5 encrypted data

Enter passphrase:<YOUR-PASSWORD>

Decrypt file and write output to file vivek.info.txt you can run command:

$ gpg myfinancial.info.gpg –o vivek.info.txt

Remember if file extension is .asc, it is a ASCII encrypted file and if file extension is .gpg, it is a binary encrypted file.

via Linux: How to Encrypt and decrypt files with a password.

HowTo – Tomcat Wiki

How do I obtain a thread dump of my running webapp ?

You can only get a thread dump of the entire JVM, not just your webapp. This shouldn’t be a big deal, but should be made clear: you are getting a dump of all JVM threads, not just those “for your application”, whatever that means.

Getting a thread dump depends a lot on your environment. Please choose the section below that matches your environment best. The more universal and convenient options are presented first, while the more difficult ones or those for specific setups are provided later. Generally, you should start at the top of the list and work your way down until you find a technique that works for you.

If you are running Sun JDK 1.6 or higher

Sun’s JDK (not the JRE) ships with a program called jstack (or jstack.exe on Microsoft Windows) which will give you a thread dump on standard output. Pipe the output into a file and you have your thread dump. You will need the process id (“pid”) of the process to dump. Use of the program jps (jps.exe on Microsoft Windows) can help you determine the pid of a specific Java process.

If you are on *NIX running Sun JDK

Sun provides jstack on *nix systems from version 1.4 onward. See the above tip if you have such an environnment.

If you are running on *NIX

Send a SIGQUIT to the process. The thread dump will be sent to stdout which is likely to be redirected to CATALINA_BASE/logs/catalina.out.

To send a SIGQUIT, use kill -3 <pid> from the command line.

If you are running Tomcat as a service on Microsoft Windows

Edit your service to add the “//MS//” option to the command line. This enabled the “Monitor Service” which puts an icon in the system tray while Tomcat is running. Right-clicking the Tomcat monitor in the system tray allows you to produce a thread dump in stdout.

If you have Tomcat running in a console

*NIX: Press CRTL- Microsoft Windows: press CRTL-BREAK

This will produce a thread dump on standard output, but may not be possible to capture to a file.

How do I use Hibernate and database connection pooling with Tomcat?

See TomcatHibernate

How do I set up Tomcat virtual hosts in a development environment?

See TomcatDevelopmentVirtualHosts

via HowTo – Tomcat Wiki.