Project

General

Profile

Test Environment - Virtual Machine description » History » Version 4

Pablo Alingery, 04/08/2015 11:46

1 1 Herve Ballans
{{>toc}}
2 1 Herve Ballans
3 1 Herve Ballans
h1. Test Environment
4 1 Herve Ballans
5 1 Herve Ballans
h2. Virtual Machine description
6 1 Herve Ballans
7 1 Herve Ballans
Test machine is a virtual machine on a ProxMox environment.
8 1 Herve Ballans
Physically stored on inf-proxmox2
9 2 Herve Ballans
VM Name : sdo3
10 2 Herve Ballans
VM id : 801
11 2 Herve Ballans
memory : 32.00GB
12 2 Herve Ballans
CPU : 16 CPUs (4 X 4 cores)
13 2 Herve Ballans
Hard Disk 1 : 64 GB (OS + NetDRMS software) - stored on NFS-HA
14 2 Herve Ballans
Hard Disk 2 : 1 TB (Databases) - Stored localy
15 1 Herve Ballans
16 2 Herve Ballans
Not in HA configuration. VM Backup each day (for OS).
17 1 Herve Ballans
18 2 Herve Ballans
Guest OS : Debian 8.1
19 2 Herve Ballans
Guest kernel : Linux sdo3 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24) x86_64 GNU/Linux
20 1 Herve Ballans
21 1 Herve Ballans
h2. Manual install of postgresql
22 1 Herve Ballans
23 1 Herve Ballans
h3. Prerequisites
24 1 Herve Ballans
25 1 Herve Ballans
<pre>
26 1 Herve Ballans
# apt-get --purge remove postgresql*
27 1 Herve Ballans
28 2 Herve Ballans
# wget https://ftp.postgresql.org/pub/source/v9.4.4/postgresql-9.4.4.tar.gz
29 1 Herve Ballans
30 2 Herve Ballans
# tar -xzvf postgresql-9.4.4.tar.gz
31 1 Herve Ballans
</pre>
32 1 Herve Ballans
33 1 Herve Ballans
Before compiling, I verify that patch required by NetDRMS (voir [[ici|http://vso.stanford.edu/netdrms/pginst.html]]) was really present in source files :
34 1 Herve Ballans
35 1 Herve Ballans
_src/backend/utils/misc/guc.c_ and _src/bin/pg_dump/pg_dump.c_
36 1 Herve Ballans
37 1 Herve Ballans
<pre>
38 1 Herve Ballans
# apt-get update
39 1 Herve Ballans
# apt-get upgrade
40 2 Herve Ballans
# apt-get install gcc make libreadline-dev minizip
41 1 Herve Ballans
</pre>
42 1 Herve Ballans
43 1 Herve Ballans
h3. Installation
44 1 Herve Ballans
45 1 Herve Ballans
<pre>
46 1 Herve Ballans
# ./configure
47 1 Herve Ballans
# make
48 1 Herve Ballans
# su
49 1 Herve Ballans
# make install
50 1 Herve Ballans
# adduser postgres
51 1 Herve Ballans
</pre>
52 1 Herve Ballans
53 1 Herve Ballans
h3. Test database
54 1 Herve Ballans
55 1 Herve Ballans
<pre>
56 1 Herve Ballans
# mkdir /usr/local/pgsql/data
57 1 Herve Ballans
# chown postgres /usr/local/pgsql/data
58 1 Herve Ballans
# su - postgres
59 1 Herve Ballans
# /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
60 1 Herve Ballans
# /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
61 1 Herve Ballans
# /usr/local/pgsql/bin/createdb test
62 1 Herve Ballans
# /usr/local/pgsql/bin/psql test
63 1 Herve Ballans
</pre>
64 1 Herve Ballans
65 1 Herve Ballans
h3. Shared postgresql library
66 1 Herve Ballans
67 1 Herve Ballans
<pre>
68 1 Herve Ballans
# vi /etc/ld.so.conf/libc.conf
69 1 Herve Ballans
</pre>
70 1 Herve Ballans
add :
71 1 Herve Ballans
<pre>
72 1 Herve Ballans
/usr/local/pgsql/lib
73 1 Herve Ballans
</pre>
74 1 Herve Ballans
75 1 Herve Ballans
h3. Boot start-up
76 1 Herve Ballans
77 1 Herve Ballans
We create an init script in order to start postgresql on boot
78 1 Herve Ballans
79 1 Herve Ballans
<pre>
80 1 Herve Ballans
# vi /etc/init.d/postgresql
81 1 Herve Ballans
</pre>
82 1 Herve Ballans
83 1 Herve Ballans
Content :
84 1 Herve Ballans
85 1 Herve Ballans
<pre>
86 1 Herve Ballans
#! /bin/sh
87 1 Herve Ballans
88 1 Herve Ballans
# chkconfig: 2345 98 02
89 1 Herve Ballans
# description: PostgreSQL RDBMS
90 1 Herve Ballans
91 1 Herve Ballans
# This is an example of a start/stop script for SysV-style init, such
92 1 Herve Ballans
# as is used on Linux systems.  You should edit some of the variables
93 1 Herve Ballans
# and maybe the 'echo' commands.
94 1 Herve Ballans
#
95 1 Herve Ballans
# Place this file at /etc/init.d/postgresql (or
96 1 Herve Ballans
# /etc/rc.d/init.d/postgresql) and make symlinks to
97 1 Herve Ballans
#   /etc/rc.d/rc0.d/K02postgresql
98 1 Herve Ballans
#   /etc/rc.d/rc1.d/K02postgresql
99 1 Herve Ballans
#   /etc/rc.d/rc2.d/K02postgresql
100 1 Herve Ballans
#   /etc/rc.d/rc3.d/S98postgresql
101 1 Herve Ballans
#   /etc/rc.d/rc4.d/S98postgresql
102 1 Herve Ballans
#   /etc/rc.d/rc5.d/S98postgresql
103 1 Herve Ballans
# Or, if you have chkconfig, simply:
104 1 Herve Ballans
# chkconfig --add postgresql
105 1 Herve Ballans
#
106 1 Herve Ballans
# Proper init scripts on Linux systems normally require setting lock
107 1 Herve Ballans
# and pid files under /var/run as well as reacting to network
108 1 Herve Ballans
# settings, so you should treat this with care.
109 1 Herve Ballans
110 1 Herve Ballans
# Original author:  Ryan Kirkpatrick <pgsql@rkirkpat.net>
111 1 Herve Ballans
112 1 Herve Ballans
# $PostgreSQL: pgsql/contrib/start-scripts/linux,v 1.8 2006/07/13 14:44:33 petere Exp $
113 1 Herve Ballans
114 1 Herve Ballans
## EDIT FROM HERE
115 1 Herve Ballans
116 1 Herve Ballans
# Installation prefix
117 1 Herve Ballans
prefix=/usr/local/pgsql
118 1 Herve Ballans
119 1 Herve Ballans
# Data directory
120 1 Herve Ballans
PGDATA="/usr/local/pgsql/data"
121 1 Herve Ballans
122 1 Herve Ballans
# Who to run the postmaster as, usually "postgres".  (NOT "root")
123 1 Herve Ballans
PGUSER=postgres
124 1 Herve Ballans
125 1 Herve Ballans
# Where to keep a log file
126 1 Herve Ballans
PGLOG="$PGDATA/serverlog"
127 1 Herve Ballans
128 1 Herve Ballans
## STOP EDITING HERE
129 1 Herve Ballans
130 1 Herve Ballans
# The path that is to be used for the script
131 1 Herve Ballans
PATH=/usr/local/sbin:/usr/local/bin:/usr/local/pgsql/bin:/sbin:/bin:/usr/sbin:/usr/bin
132 1 Herve Ballans
133 1 Herve Ballans
# What to use to start up the postmaster (we do NOT use pg_ctl for this,
134 1 Herve Ballans
# as it adds no value and can cause the postmaster to misrecognize a stale
135 1 Herve Ballans
# lock file)
136 1 Herve Ballans
DAEMON="$prefix/bin/postmaster"
137 1 Herve Ballans
138 1 Herve Ballans
# What to use to shut down the postmaster
139 1 Herve Ballans
PGCTL="$prefix/bin/pg_ctl"
140 1 Herve Ballans
141 1 Herve Ballans
set -e
142 1 Herve Ballans
143 1 Herve Ballans
# Only start if we can find the postmaster.
144 1 Herve Ballans
test -x $DAEMON || exit 0
145 1 Herve Ballans
146 1 Herve Ballans
# Parse command line parameters.
147 1 Herve Ballans
case $1 in
148 1 Herve Ballans
  start)
149 1 Herve Ballans
        echo -n "Starting PostgreSQL: "
150 1 Herve Ballans
        su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
151 1 Herve Ballans
        echo "ok"
152 1 Herve Ballans
        ;;
153 1 Herve Ballans
  stop)
154 1 Herve Ballans
        echo -n "Stopping PostgreSQL: "
155 1 Herve Ballans
        su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"
156 1 Herve Ballans
        echo "ok"
157 1 Herve Ballans
        ;;
158 1 Herve Ballans
  restart)
159 1 Herve Ballans
        echo -n "Restarting PostgreSQL: "
160 1 Herve Ballans
        su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"
161 1 Herve Ballans
        su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
162 1 Herve Ballans
        echo "ok"
163 1 Herve Ballans
        ;;
164 1 Herve Ballans
  reload)
165 1 Herve Ballans
        echo -n "Reload PostgreSQL: "
166 1 Herve Ballans
        su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"
167 1 Herve Ballans
        echo "ok"
168 1 Herve Ballans
        ;;
169 1 Herve Ballans
  status)
170 1 Herve Ballans
        su - $PGUSER -c "$PGCTL status -D '$PGDATA'"
171 1 Herve Ballans
        ;;
172 1 Herve Ballans
  *)
173 1 Herve Ballans
        # Print help
174 1 Herve Ballans
        echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2
175 1 Herve Ballans
        exit 1
176 1 Herve Ballans
        ;;
177 1 Herve Ballans
esac
178 1 Herve Ballans
179 1 Herve Ballans
exit 0
180 1 Herve Ballans
</pre>
181 3 Pablo Alingery
182 4 Pablo Alingery
h3. Install additional modules
183 3 Pablo Alingery
184 3 Pablo Alingery
Nous avons besoin de dblink pour les trigger entre bases de données
185 3 Pablo Alingery
186 3 Pablo Alingery
<pre>
187 3 Pablo Alingery
apt-get install postgresql-contrib 
188 3 Pablo Alingery
</pre>