Project

General

Profile

Test Environment - Virtual Machine description » History » Version 1

Herve Ballans, 19/06/2015 14:37

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 1 Herve Ballans
VM Name : idoc-netdrms
10 1 Herve Ballans
VM id : 130
11 1 Herve Ballans
memory : 4.00GB
12 1 Herve Ballans
CPU : 4 CPUs
13 1 Herve Ballans
Hard Disk 1 : 64 GB (OS + NetDRMS software)
14 1 Herve Ballans
Hard Disk 2 : 1 TB (Databases)
15 1 Herve Ballans
16 1 Herve Ballans
Not in HA configuration. VM Backup each day.
17 1 Herve Ballans
18 1 Herve Ballans
Guest OS : Debian 7.7
19 1 Herve Ballans
Guest kernel : Linux idoc-netdrms 3.2.0-4-amd64 #1 SMP Debian 3.2.63-2+deb7u2 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
</pre>
28 1 Herve Ballans
29 1 Herve Ballans
The following packages will be REMOVED:
30 1 Herve Ballans
  postgresql-9.1* postgresql-client-9.1* postgresql-client-common* postgresql-common*
31 1 Herve Ballans
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
32 1 Herve Ballans
After this operation, 21.9 MB disk space will be freed.
33 1 Herve Ballans
Do you want to continue [Y/n]?
34 1 Herve Ballans
(Reading database ... 25241 files and directories currently installed.)
35 1 Herve Ballans
Removing postgresql-9.1 ...
36 1 Herve Ballans
[ ok ] Stopping PostgreSQL 9.1 database server: main.
37 1 Herve Ballans
Purging configuration files for postgresql-9.1 ...
38 1 Herve Ballans
Dropping cluster main...
39 1 Herve Ballans
Removing postgresql-client-9.1 ...
40 1 Herve Ballans
Removing postgresql-common ...
41 1 Herve Ballans
Removing 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
42 1 Herve Ballans
Purging configuration files for postgresql-common ...
43 1 Herve Ballans
Removing postgresql-client-common ...
44 1 Herve Ballans
Purging configuration files for postgresql-client-common ...
45 1 Herve Ballans
Processing triggers for man-db ...
46 1 Herve Ballans
47 1 Herve Ballans
<pre>
48 1 Herve Ballans
49 1 Herve Ballans
# wget https://ftp.postgresql.org/pub/source/v9.3.5/postgresql-9.3.5.tar.gz
50 1 Herve Ballans
51 1 Herve Ballans
# tar -xzvf postgresql-9.3.5.tar.gz
52 1 Herve Ballans
</pre>
53 1 Herve Ballans
54 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 :
55 1 Herve Ballans
56 1 Herve Ballans
_src/backend/utils/misc/guc.c_ and _src/bin/pg_dump/pg_dump.c_
57 1 Herve Ballans
58 1 Herve Ballans
<pre>
59 1 Herve Ballans
# apt-get update
60 1 Herve Ballans
# apt-get upgrade
61 1 Herve Ballans
# apt-get install gcc make libreadline-dev zlib-bin zlib1g*
62 1 Herve Ballans
</pre>
63 1 Herve Ballans
64 1 Herve Ballans
h3. Installation
65 1 Herve Ballans
66 1 Herve Ballans
<pre>
67 1 Herve Ballans
# ./configure
68 1 Herve Ballans
# make
69 1 Herve Ballans
# su
70 1 Herve Ballans
# make install
71 1 Herve Ballans
# adduser postgres
72 1 Herve Ballans
</pre>
73 1 Herve Ballans
74 1 Herve Ballans
h3. Test database
75 1 Herve Ballans
76 1 Herve Ballans
<pre>
77 1 Herve Ballans
# mkdir /usr/local/pgsql/data
78 1 Herve Ballans
# chown postgres /usr/local/pgsql/data
79 1 Herve Ballans
# su - postgres
80 1 Herve Ballans
# /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
81 1 Herve Ballans
# /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
82 1 Herve Ballans
# /usr/local/pgsql/bin/createdb test
83 1 Herve Ballans
# /usr/local/pgsql/bin/psql test
84 1 Herve Ballans
</pre>
85 1 Herve Ballans
86 1 Herve Ballans
h3. Shared postgresql library
87 1 Herve Ballans
88 1 Herve Ballans
<pre>
89 1 Herve Ballans
# vi /etc/ld.so.conf/libc.conf
90 1 Herve Ballans
</pre>
91 1 Herve Ballans
add :
92 1 Herve Ballans
<pre>
93 1 Herve Ballans
/usr/local/pgsql/lib
94 1 Herve Ballans
</pre>
95 1 Herve Ballans
96 1 Herve Ballans
h3. Boot start-up
97 1 Herve Ballans
98 1 Herve Ballans
We create an init script in order to start postgresql on boot
99 1 Herve Ballans
100 1 Herve Ballans
<pre>
101 1 Herve Ballans
# vi /etc/init.d/postgresql
102 1 Herve Ballans
</pre>
103 1 Herve Ballans
104 1 Herve Ballans
Content :
105 1 Herve Ballans
106 1 Herve Ballans
<pre>
107 1 Herve Ballans
#! /bin/sh
108 1 Herve Ballans
109 1 Herve Ballans
# chkconfig: 2345 98 02
110 1 Herve Ballans
# description: PostgreSQL RDBMS
111 1 Herve Ballans
112 1 Herve Ballans
# This is an example of a start/stop script for SysV-style init, such
113 1 Herve Ballans
# as is used on Linux systems.  You should edit some of the variables
114 1 Herve Ballans
# and maybe the 'echo' commands.
115 1 Herve Ballans
#
116 1 Herve Ballans
# Place this file at /etc/init.d/postgresql (or
117 1 Herve Ballans
# /etc/rc.d/init.d/postgresql) and make symlinks to
118 1 Herve Ballans
#   /etc/rc.d/rc0.d/K02postgresql
119 1 Herve Ballans
#   /etc/rc.d/rc1.d/K02postgresql
120 1 Herve Ballans
#   /etc/rc.d/rc2.d/K02postgresql
121 1 Herve Ballans
#   /etc/rc.d/rc3.d/S98postgresql
122 1 Herve Ballans
#   /etc/rc.d/rc4.d/S98postgresql
123 1 Herve Ballans
#   /etc/rc.d/rc5.d/S98postgresql
124 1 Herve Ballans
# Or, if you have chkconfig, simply:
125 1 Herve Ballans
# chkconfig --add postgresql
126 1 Herve Ballans
#
127 1 Herve Ballans
# Proper init scripts on Linux systems normally require setting lock
128 1 Herve Ballans
# and pid files under /var/run as well as reacting to network
129 1 Herve Ballans
# settings, so you should treat this with care.
130 1 Herve Ballans
131 1 Herve Ballans
# Original author:  Ryan Kirkpatrick <pgsql@rkirkpat.net>
132 1 Herve Ballans
133 1 Herve Ballans
# $PostgreSQL: pgsql/contrib/start-scripts/linux,v 1.8 2006/07/13 14:44:33 petere Exp $
134 1 Herve Ballans
135 1 Herve Ballans
## EDIT FROM HERE
136 1 Herve Ballans
137 1 Herve Ballans
# Installation prefix
138 1 Herve Ballans
prefix=/usr/local/pgsql
139 1 Herve Ballans
140 1 Herve Ballans
# Data directory
141 1 Herve Ballans
PGDATA="/usr/local/pgsql/data"
142 1 Herve Ballans
143 1 Herve Ballans
# Who to run the postmaster as, usually "postgres".  (NOT "root")
144 1 Herve Ballans
PGUSER=postgres
145 1 Herve Ballans
146 1 Herve Ballans
# Where to keep a log file
147 1 Herve Ballans
PGLOG="$PGDATA/serverlog"
148 1 Herve Ballans
149 1 Herve Ballans
## STOP EDITING HERE
150 1 Herve Ballans
151 1 Herve Ballans
# The path that is to be used for the script
152 1 Herve Ballans
PATH=/usr/local/sbin:/usr/local/bin:/usr/local/pgsql/bin:/sbin:/bin:/usr/sbin:/usr/bin
153 1 Herve Ballans
154 1 Herve Ballans
# What to use to start up the postmaster (we do NOT use pg_ctl for this,
155 1 Herve Ballans
# as it adds no value and can cause the postmaster to misrecognize a stale
156 1 Herve Ballans
# lock file)
157 1 Herve Ballans
DAEMON="$prefix/bin/postmaster"
158 1 Herve Ballans
159 1 Herve Ballans
# What to use to shut down the postmaster
160 1 Herve Ballans
PGCTL="$prefix/bin/pg_ctl"
161 1 Herve Ballans
162 1 Herve Ballans
set -e
163 1 Herve Ballans
164 1 Herve Ballans
# Only start if we can find the postmaster.
165 1 Herve Ballans
test -x $DAEMON || exit 0
166 1 Herve Ballans
167 1 Herve Ballans
# Parse command line parameters.
168 1 Herve Ballans
case $1 in
169 1 Herve Ballans
  start)
170 1 Herve Ballans
        echo -n "Starting PostgreSQL: "
171 1 Herve Ballans
        su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
172 1 Herve Ballans
        echo "ok"
173 1 Herve Ballans
        ;;
174 1 Herve Ballans
  stop)
175 1 Herve Ballans
        echo -n "Stopping PostgreSQL: "
176 1 Herve Ballans
        su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"
177 1 Herve Ballans
        echo "ok"
178 1 Herve Ballans
        ;;
179 1 Herve Ballans
  restart)
180 1 Herve Ballans
        echo -n "Restarting PostgreSQL: "
181 1 Herve Ballans
        su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"
182 1 Herve Ballans
        su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
183 1 Herve Ballans
        echo "ok"
184 1 Herve Ballans
        ;;
185 1 Herve Ballans
  reload)
186 1 Herve Ballans
        echo -n "Reload PostgreSQL: "
187 1 Herve Ballans
        su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"
188 1 Herve Ballans
        echo "ok"
189 1 Herve Ballans
        ;;
190 1 Herve Ballans
  status)
191 1 Herve Ballans
        su - $PGUSER -c "$PGCTL status -D '$PGDATA'"
192 1 Herve Ballans
        ;;
193 1 Herve Ballans
  *)
194 1 Herve Ballans
        # Print help
195 1 Herve Ballans
        echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2
196 1 Herve Ballans
        exit 1
197 1 Herve Ballans
        ;;
198 1 Herve Ballans
esac
199 1 Herve Ballans
200 1 Herve Ballans
exit 0
201 1 Herve Ballans
</pre>