Skip to content

Instantly share code, notes, and snippets.

@sunfmin
Created September 19, 2008 04:35
Show Gist options
  • Save sunfmin/11536 to your computer and use it in GitHub Desktop.
Save sunfmin/11536 to your computer and use it in GitHub Desktop.
Upgrade to PostgreSQL 8.3 on Joyent
svcadm disable postgresql
svcadm disable mongrel/facts
curl -O http://ftp7.us.postgresql.org/pub/postgresql//source/v8.3.3/postgresql-8.3.3.tar.gz
gunzip postgresql-8.3.3.tar.gz
tar -xvf postgresql-8.3.3.tar
cd postgresql-8.3.3/
export LDFLAGS="-R/opt/csw/lib/:/usr/lib/"
./configure --with-libraries=/opt/csw/lib/:/usr/lib/ --with-includes=/opt/csw/include/:/usr/include/
sudo make install
/usr/local/pgsql/bin/psql --version
sudo mkdir /usr/local/pgsql/data
sudo chown postgres:postgres /usr/local/pgsql/data/
sudo su postgres -c "/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data"
svccfg export postgresql>postgresql833.smf
less postgresql833.smf
cp /opt/csw/lib/svc/method/postgresql /opt/csw/lib/svc/method/postgresql83
vim /opt/csw/lib/svc/method/postgresql83
chown root:bin /opt/csw/lib/svc/method/postgresql83*
svccfg import postgresql833.smf
svcs
svcadm enable postgresql83
du -h /home/postgres/data/
df -hla
sudo vim /usr/local/pgsql/data/postgresql.conf
svcadm enable postgresql83
sudo su postgres -c "/usr/local/pgsql/bin/pg_dumpall -h localhost -U postgres -p 5432 | /usr/local/pgsql/bin/psql -U postgres -h localhost -p 9999"
svcadm enable postgresql83
svcadm enable mongrel/facts
shared_buffers = 1024MB # default/32MB # min 128kB or max_connections*16kB
maintenance_work_mem = 128MB # default 16MB # min 1MB
wal_buffers = 1MB #default 64kB # min 32kB
checkpoint_segments = 128 #default 3 # in logfile segments, min 1, 16MB each
checkpoint_completion_target = 0.9 #default 0.5 # checkpoint target duration, 0.0 - 1.0
effective_cache_size = 2048MB # default 128MB
#!/sbin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#PGPORT=9999
#export PGPORT
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E SMI"
. /lib/svc/share/smf_include.sh
# SMF_FMRI is the name of the target service. This allows multiple instances
# to use the same script.
getproparg()
{ val=`svcprop -p $1 $SMF_FMRI`
[ -n "$val" ] && echo $val
}
PGBIN=/usr/local/pgsql/bin
PGDATA=`getproparg postgresql/data`
PGLOG=`getproparg postgresql/log`
if [ -z $SMF_FMRI ]; then
echo "SMF framework variables are not initialized."
exit $SMF_EXIT_ERR
fi
if [ -z $PGDATA ]; then
echo "postgresql/data property not set"
exit $SMF_EXIT_ERR_CONFIG
fi
if [ -z $PGLOG ]; then
echo "postgresql/log property not set"
exit $SMF_EXIT_ERR_CONFIG
fi
case "$1" in
'start')
$PGBIN/pg_ctl -D $PGDATA -l $PGDATA/$PGLOG start
;;
'stop')
$PGBIN/pg_ctl -D $PGDATA stop
;;
'refresh')
$PGBIN/pg_ctl -D $PGDATA reload
;;
*)
echo $"Usage: $0 {start|refresh}"
exit 1
;;
esac
exit $SMF_EXIT_OK
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
<service name='application/database/postgresql83' type='service' version='0'>
<dependency name='network' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/milestone/network:default'/>
</dependency>
<dependency name='filesystem-local' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/system/filesystem/local:default'/>
</dependency>
<exec_method name='start' type='method' exec='/opt/csw/lib/svc/method/postgresql83 start' timeout_seconds='300'>
<method_context/>
</exec_method>
<exec_method name='stop' type='method' exec='/opt/csw/lib/svc/method/postgresql83 stop' timeout_seconds='300'>
<method_context/>
</exec_method>
<exec_method name='refresh' type='method' exec='/opt/csw/lib/svc/method/postgresql83 refresh' timeout_seconds='60'>
<method_context/>
</exec_method>
<instance name='facts' enabled='true'>
<method_context project=':default' resource_pool=':default' working_directory=':default'>
<method_credential group='postgres' limit_privileges=':default' privileges=':default' supp_groups=':default' user='postgres'/>
</method_context>
<property_group name='postgresql' type='application'>
<propval name='data' type='astring' value='/usr/local/pgsql/data'/>
<propval name='log' type='astring' value='postgres83.log'/>
</property_group>
</instance>
<stability value='Evolving'/>
<template>
<common_name>
<loctext xml:lang='C'>PostgreSQL RDBMS</loctext>
</common_name>
<documentation>
<manpage title='postgres' section='1M'/>
<doc_link name='postgresql.org' uri='http://postgresql.org'/>
</documentation>
</template>
</service>
</service_bundle>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment