Startups : Rajesh Ramchandani's Weblog

Wednesday Jul 13, 2005

Installing PostgreSQL in Solaris Zone

You have probably read a lot about very cool features in Solaris 10 including Containers and zones. If you haven't yet, check out Joost Pronk's blog Here

Solaris containers have several advantages and can help you with:

1. Server consolidation

2. Resource management by using Resource Pools

3. Application or system partitions to run several instances of applications isolated from each other in seperate zones.

If you are in process of migration from commerical database to any Open source databases, you may want to run both the database servers parallely on the same server until migration is completed and workload has been moved from one DB to open source DB. By running both the dabase servers' simultaneously on the same server but in different zones, you can do a thorough workload and comparative analysis.

Here's a step by step instructions for installing and configuring PostgreSQL server in a Solaris zone.

Creating the First zone (Postgresql zone)

zonedemo# mkdir -p /export/zones/postgresql
zonedemo#chmod 700 /export/zones/postgresql

Zone is created by using a default template that defines resources in a typical zone

Configuring the zone:

zonedemo#zonecfg -z postgresqlzone

postgresqlzone: No such zone configured
Use ‘create’ to begin configuring a new zone.
zonecfg:postgresqlzone>
zonecfg:postgresqlzone> create
zonecfg:postgresqlzone> set zonepath=/export/zones/postgresql
zonecfg:postgresqlzone> set autoboot=true

The virtual network interface with IP address 192.9.200.1 is configured on local network interface of the global zone

zonecfg:postgresqlzone> add net
zonecfg:postgresqlzone:net> set address=192.9.200.1/24
zonecfg:postgresqlzone:net> set physical=bge0
zonecfg:postgresqlzone:net> end

The file system for Postgresql is created in Postgresql zone on the existing file system of the global zone. Add the following statements to the zone configuration to have the file system mounted in the zone automatically when the zone boots

zonecfg:postgresqlzone> add fs
zonecfg:postgresqlzone:fs> set type=ufs
zonecfg:postgresqlzone:fs> set special=/dev/md/rdsk/d100
zonecfg:postgresqlzone:fs> set raw=/dev/md/rdsk/d100
zonecfg:postgresqlzone:fs> set dir=/postgresql
zonecfg:postgresqlzone:fs> end
zonecfg:postgresqlzone> verify
zonecfg:postgresqlzone> commit
zonecfg:postgresqlzone> exit

Zone configuration is now complete. The verify and commit command verify and write the configuration to the disk respecitvely

Installing the Zone:

Zone is ready to be installed
zonedemo#zoneadm -z postgresqlzone install
Preparing to install zone .
Creating list of files to copy from the global zone.
Copying <2574> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <998> packages on the zone.
Initialized <998> packages on zone.
Zone is initialized.
Installation of <24> packages was skipped.
Installation of these packages generated warnings:
The file contains a log of the zone installation.

zonecfg:postgresqlzone:fs> set dir=/postgresql
zonecfg:postgresqlzone:fs> end
zonecfg:postgresqlzone> verify
zonecfg:postgresqlzone> commit
zonecfg:postgresqlzone> exit

Installation is now complete. The verify command verifies that the current configuration of zone is syntatically correct and commit command writes the in-memory configuration to the disk.

Booting the Zone:

Since the zone is just like a fresh Solaris installation, we will need to answer a few questions to configure the system. *zlogin(1M)* command is used to obtain access to the newly created zones console.

[NOTICE: Zone rebooting]

SunOS Release 5.10 Version Generic 64-bit
Copyright 1983-2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
Hostname: postgresqlzoneOQOQ

postgresqlzoneOQOQ console login:root

Installing Postgresql:

Download the Solaris sparc or x86 versions of PostgreSQL binaries from *“Pervasive”*:http://www.pervasivepostgresql.com

  1. ./PPG_80R2_SOL10_SPARC.bin -console

Welcome to the InstallShield’s Console driven installation for Pervasive Postgres

Pervasive Postgres 8.0 Release 2

Pervasive Postgres is our distribution of PostgreSQL, the world’s most advanced open source database. The product is free. We also offer support, training, and
related services.

To install Pervasive Postgres on your computer, please do the following:

Press 1 for Next, 3 to Cancel or 5 to Redisplay [1]

It displays the Pervasive PostgreSQl license. Please read and accept the license to continue installing Pervasive Postgresq

Pervasive Software Inc.

Pervasive Postgres License Agreement

*....details deleted*

Please choose from the following options:
[ ] 1 – I accept the terms of the license agreement.
[X] 2 – I do not accept the terms of the license agreement.

To select an item enter its number, or 0 when you are finished: [0] 1

Enter 0 to continue or 1 to make another selection: [0] 0

Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1]

Pervasive Postgres

Select the features for “pervasivepostgres” you would like to install:

pervasivepostgres To select/deselect a feature or to view its children, type its number: 1. +[x] Server Components 2. +[x] Optional Packages 3. +[x] Tools Other options: 0. Continue installing Enter command [0] 0

Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] 1

/opt/pervasivepostgres

with the following features:

Server Components

Pervasive Postgres Core Initialize Database Cluster
Optional Packages JDBC Client Library ODBC PostgreSQL documentation DBD-Pg
Tools Pervasive Postgres Config Tool phpPgAdmin

for a total size:

Press ENTER to read the text [Type q to quit]

60.4 MB

Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1]

Pervasive Postgres

Installing pervasivepostgres. Please wait…

0 % complete
20 % complete
30 % complete
40 % complete
50 % complete
60 % complete
70 % complete
80 % complete
90 % complete
100 % complete

Creating uninstaller…

Make libpath to ODBC libs (Only for Admins)

The InstallShield Wizard has successfully installed pervasivepostgres. Choose Finish to exit the wizard.

Press 3 to Finish or 5 to Redisplay [3] 3

Installation is completed and configuration part begins:

bash-3.00$ LD_LIBRARY_PATH=/opt/pervasivepostgres/lib:$LD_LIBRARY_PATH
bash-3.00$ export LD_LIBRARY_PATH

bash-3.00$ PGDATA=/opt/pervasivepostgres/data;export PGDATA

-bash-3.00$ pwd
/opt/pervasivepostgres/bin

-bash-3.00$ ./initdb
The files belonging to this database system will be owned by user “postgres”.
This user must also own the server process.

The database cluster will be initialized with locale C.

fixing permissions on existing directory /opt/pervasivepostgres/data … ok
creating directory /opt/pervasivepostgres/data/global … ok
creating directory /opt/pervasivepostgres/data/pg_xlog … ok
creating directory /opt/pervasivepostgres/data/pg_xlog/archive_status … ok
creating directory /opt/pervasivepostgres/data/pg_clog … ok
creating directory /opt/pervasivepostgres/data/pg_subtrans … ok
creating directory /opt/pervasivepostgres/data/base … ok
creating directory /opt/pervasivepostgres/data/base/1 … ok
creating directory /opt/pervasivepostgres/data/pg_tblspc … ok
selecting default max_connections … 100
selecting default shared_buffers … 1000
creating configuration files … ok
creating template1 database in /opt/pervasivepostgres/data/base/1 … ok
initializing pg_shadow … ok
enabling unlimited row size for system tables … ok
initializing pg_depend … ok
creating system views … ok
loading pg_description … ok
creating conversions … ok
setting privileges on built-in objects … ok
creating information schema … ok
vacuuming database template1 … ok
copying template1 to template0 … ok

WARNING: enabling “trust” authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

Success. You can now start the database server using:

./postmaster -D /opt/pervasivepostgres/data
or ./pg_ctl -D /opt/pervasivepostgres/data -l logfile start

bash-3.00$ ./pg_ctl -l /opt/pervasivepostgres/logs/pg_log start
postmaster starting
bash-3.00$ ./pg_ctl status
pg_ctl: postmaster is running (PID: 1909)
/opt/pervasivepostgres/bin/postmaster

I have done some minimal validation of PostgreSQL server inside a Solaris zone. So far I haven’t found any issues and will continue with more rigorous testing.

Comments:

Just a note: with my clients, they usually want to have full control over their PG database and they are running within a zone. So, I install PG under /usr in the global zone which then ends up mounted read-only inside each zone, say /usr/local/pgsql/ . Then, when each zone is created, I create a pgsql user which will own the specific database files for that zone (using initdb and the environment variable PGDATA we can use any directory). Since the data files are inside the zone, the customer can access it and is happy - but the PG binaries are under my control in the global zone. Fixing a problem with a patch or whatnot automatically fixes the problem in every zone once PG is restarted.

Posted by PatrickG on July 13, 2005 at 10:56 PM PDT #

Patrick, Thanks for your comments. This is good way to keep management of PG simple. I would like to know if you have seen any other issues by running inside the zones.

Posted by Rajesh Ramchandani on July 14, 2005 at 08:55 AM PDT #

The link is http://www.pervasive-postgres.com/

Posted by Filip Krikava on February 27, 2006 at 04:28 PM PST #

Great post and draw. Thank you for sharing.

Posted by links of london jewellery on November 23, 2009 at 06:35 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed

Calendar

Feeds

Search

Links

Navigation

Referrers