Posts

Some Oracle Workarounds in Postgres Plus Advanced Server 9.0

Image
Today, I though to mention some of Oracle workarounds which can be use for Migration of Oracle Database to PPAS 9.0(EnterpriseDB). 1. UTL_RAW.CAST_TO_RAW This is a Oracle Packaged Function, which can be use to convert VARCHAR2 value into RAW Value. Lets see its example in Oracle: SQL> select utl_raw.cast_to_raw('TESTING TESTING') from dual; UTL_RAW.CAST_TO_RAW('TESTINGTESTING') -------------------------------------------------------------------------------- 54455354494E472054455354494E47 Since PPAS 9.0, doesn't have this package in 9.0, therefore user can use postgresql function decode() for converting of varchar datatype to RAW/bytea data. Following is an example: edb=# select decode('TESTING TESTING','escape') from dual; decode ---------------------------------- \x54455354494e472054455354494e47 (1 row) which is a same output. 2. UTL_RAW.CAST_TO_VARCHAR2 Using this packaged function user can conver

How to enable SSL in PostgreSQL/PPAS

This has been asked many times, so I thought to write steps for enabling ssl: Following are steps, which can be use to enable ssl in postgreSQL: 1. Generate a passphrase protected certificate using following command: openssl req -new -text -out cert.req Snapshot is given below: Generating a 1024 bit RSA private key ....................++++++ ...................................................++++++ writing new private key to 'privkey.pem' Enter PEM pass phrase: Verifying - Enter PEM pass phrase: ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]: State or Province Name (full name) [Some-State]: Locality Name (eg, city) []: Organization Name

Install and Configure Nagios for PostgreSQL/PPAS on Linux

Image
One of my Colleague had asked how he can use Nagios for PostgreSQL Monitoring. So, I thought of writing steps to show the blog readers about nagios Configuration for PostgreSQL/PPAS. Following are the steps: 1. Download Nagios Core wget http://nagios.sourceforge.net/download/cvs/nagios-HEAD.tar.gz 2. For Installing Nagios, following packages would be required,so make sure you have them installed on your server. gcc make binutils cpp libpq-dev libmysqlclient15-dev libssl0.9.8 libssl-dev pkg-config apache2 libgd2-xpm libgd2-xpm-dev libgd-tools libpng12-dev libjpeg62-dev perl libperl-dev libperl5.8 libnet-snmp-perl 3. Create nagios user and group as given below: [root@localhost]# useradd nagios [root@localhost]# passwd nagios [root@localhost]# groupadd nagcmd [root@localhost]# usermod -G nagcmd nagios [root@localhost]# usermod -G nagcmd apache 4. Now, untar Nagios Core/Nagios Plugin using following command: tar -xvf nagios-HEAD.tar.gz 5. Now configure Nagios

Remote Log Reading in PostgreSQL 8.4 and 9.0.

I was going through the one of the important feature (SQL/MED) which is coming feature of PostgreSQL 9.1. This feature enables user to access any external file, using SQL, from PostgreSQL Terminal. Magnus hagander's has also blogged about this feature and he has shown "How to access the PostgreSQL logfile using SQL/Med" . After going through his blog, I thought to do same with PostgreSQL 8.4/9.0 using plperl program. Following are the steps, which can be use to access the postgreSQL csv log file: 1. Change the log_destination parameter in postgresql.conf file of PG Instance Directory, to create csvlog of postgreSQL log. As given below. log_destination = 'stderr,csvlog' 2. Reload the changes in PostgreSQL, using following command: postgres=# select pg_reload_conf(); pg_reload_conf ---------------- t (1 row) 3. Connect to PostgreSQL database using psql command and Create following data type CREATE type pg_log_type as ( log_time timestamp(3) with ti

PostgreSQL Database Link to Oracle Database on Linux

I have seen question, like "How to make Database Link from PostgreSQL to Oracle?", always floats in PostgreSQL Community Forum. So, I thought to do some research on it and write a Blog. Cybertec (One of The PostgreSQL Database Company) has released a PostgreSQL Module ODBC Link, using which user can make Database link to any other database, including Oracle, MS SQL Server, PostgreSQL etc, which have ODBC compliant Data source. Lets see how you can make ODBC Connection from PostgreSQL to any ODBC compliant data source and fetch data. Installation of this module is very simple. Following are the steps which user can follow: 1. Install the unixODBC driver on your linux machine. user can use following useful link for Downloading and Installing the unixODBC Driver: http://www.unixodbc.org/ 2. Download ODBC-Link from following location: http://www.cybertec.at/download/odbc_link/ODBC-Link-1.0.4.tar.gz 3. Untar the downloaded file as given below: tar -zxvf ODBC-Link-1.0.4.

First Interaction with NOSQL Database (MongoDB)

I heard a lot about NoSQL Databases. So, I thought to try out this database. I found it simple to use and easy to configure. To Download MongoDB, user can use following link: http://www.mongodb.org/downloads Installation is easy. If you are planning to use pre-built binaries, then you can untar the binaries and can start using it. To start. First Create a data directory as given below: mkdir -p mongodb/data Initialize the Mongodb as given below: "MongoDB Installation Directory"/bin/mongod --dbpath mongodb/data --logpath mongodb.log Default port on which MonogoDB runs is 27017 To Connect with MongoDB instance, user can use following command: ./mongo 127.0.0.1:27017/foo Or you can use following options: usage: ./mongo [options] [db address] [file names (ending in .js)] db address can be: foo foo database on local machine 192.169.0.5/foo foo database on 192.168.0.5 machine 192.169.0.5:9999/foo foo database on 192.168.0.5 machine on p

Get Number of Segments in PostgreSQL 9.0 (PL/Perl)

In my Blog on get_number_of_segments, I had used the simple query to find the number of segments. Since, from PostgreSQL 9.0, system admin function pg_relation_filepath can be use to find the location of relfilenode, therefore I thought to reduce the code of get_number_function and use the pg_relation_filepath function. Following is a modified plperl function get_number_of_segments(text) using system admin function pg_relation_filepath(relation reglcass): CREATE OR REPLACE FUNCTION get_number_of_segments(text) returns table(tablename text, segments int) as $$ my $sql = spi_prepare("select 'ls -1 '||pg_relation_filepath(\$1)||'.*' as cmd",'TEXT'); my $q = spi_query_prepared($sql,$_[0]); my $rv = spi_fetchrow($q); my $cmd = $rv->{rows}[0]; my $command = $cmd -> {location}; open(CMD, "$command |"); $count = ; close(CMD); @count=split(/[\n\r]+/,$count); return_next