Test Environment - Virtual Machine description » History » Version 10
Herve Ballans, 14/09/2015 16:02
1 | 1 | Herve Ballans | {{>toc}} |
---|---|---|---|
2 | 1 | Herve Ballans | |
3 | 6 | Herve Ballans | h1. 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 | 10 | Herve Ballans | Guest OS : Debian 8.2 |
19 | 10 | Herve Ballans | Guest kernel : Linux sdo3 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u3 (2015-08-04) x86_64 GNU/Linux |
20 | 6 | Herve Ballans | |
21 | 6 | Herve Ballans | h2. Java installation |
22 | 6 | Herve Ballans | |
23 | 6 | Herve Ballans | <pre> |
24 | 6 | Herve Ballans | # aptitude install openjdk-7-jre |
25 | 6 | Herve Ballans | </pre> |
26 | 1 | Herve Ballans | |
27 | 1 | Herve Ballans | h2. Manual install of postgresql |
28 | 1 | Herve Ballans | |
29 | 1 | Herve Ballans | h3. Prerequisites |
30 | 1 | Herve Ballans | |
31 | 1 | Herve Ballans | <pre> |
32 | 1 | Herve Ballans | # apt-get --purge remove postgresql* |
33 | 1 | Herve Ballans | |
34 | 2 | Herve Ballans | # wget https://ftp.postgresql.org/pub/source/v9.4.4/postgresql-9.4.4.tar.gz |
35 | 1 | Herve Ballans | |
36 | 2 | Herve Ballans | # tar -xzvf postgresql-9.4.4.tar.gz |
37 | 1 | Herve Ballans | </pre> |
38 | 1 | Herve Ballans | |
39 | 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 : |
40 | 1 | Herve Ballans | |
41 | 1 | Herve Ballans | _src/backend/utils/misc/guc.c_ and _src/bin/pg_dump/pg_dump.c_ |
42 | 1 | Herve Ballans | |
43 | 1 | Herve Ballans | <pre> |
44 | 1 | Herve Ballans | # apt-get update |
45 | 1 | Herve Ballans | # apt-get upgrade |
46 | 2 | Herve Ballans | # apt-get install gcc make libreadline-dev minizip |
47 | 1 | Herve Ballans | </pre> |
48 | 1 | Herve Ballans | |
49 | 1 | Herve Ballans | h3. Installation |
50 | 1 | Herve Ballans | |
51 | 1 | Herve Ballans | <pre> |
52 | 1 | Herve Ballans | # ./configure |
53 | 1 | Herve Ballans | # make |
54 | 1 | Herve Ballans | # su |
55 | 1 | Herve Ballans | # make install |
56 | 1 | Herve Ballans | # adduser postgres |
57 | 1 | Herve Ballans | </pre> |
58 | 1 | Herve Ballans | |
59 | 1 | Herve Ballans | h3. Test database |
60 | 1 | Herve Ballans | |
61 | 1 | Herve Ballans | <pre> |
62 | 1 | Herve Ballans | # mkdir /usr/local/pgsql/data |
63 | 1 | Herve Ballans | # chown postgres /usr/local/pgsql/data |
64 | 1 | Herve Ballans | # su - postgres |
65 | 1 | Herve Ballans | # /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data |
66 | 1 | Herve Ballans | # /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 & |
67 | 1 | Herve Ballans | # /usr/local/pgsql/bin/createdb test |
68 | 1 | Herve Ballans | # /usr/local/pgsql/bin/psql test |
69 | 1 | Herve Ballans | </pre> |
70 | 1 | Herve Ballans | |
71 | 1 | Herve Ballans | h3. Shared postgresql library |
72 | 1 | Herve Ballans | |
73 | 1 | Herve Ballans | <pre> |
74 | 1 | Herve Ballans | # vi /etc/ld.so.conf/libc.conf |
75 | 1 | Herve Ballans | </pre> |
76 | 1 | Herve Ballans | add : |
77 | 1 | Herve Ballans | <pre> |
78 | 1 | Herve Ballans | /usr/local/pgsql/lib |
79 | 1 | Herve Ballans | </pre> |
80 | 1 | Herve Ballans | |
81 | 1 | Herve Ballans | h3. Boot start-up |
82 | 1 | Herve Ballans | |
83 | 1 | Herve Ballans | We create an init script in order to start postgresql on boot |
84 | 1 | Herve Ballans | |
85 | 1 | Herve Ballans | <pre> |
86 | 1 | Herve Ballans | # vi /etc/init.d/postgresql |
87 | 1 | Herve Ballans | </pre> |
88 | 1 | Herve Ballans | |
89 | 1 | Herve Ballans | Content : |
90 | 1 | Herve Ballans | |
91 | 1 | Herve Ballans | <pre> |
92 | 1 | Herve Ballans | #! /bin/sh |
93 | 1 | Herve Ballans | |
94 | 1 | Herve Ballans | # chkconfig: 2345 98 02 |
95 | 1 | Herve Ballans | # description: PostgreSQL RDBMS |
96 | 1 | Herve Ballans | |
97 | 1 | Herve Ballans | # This is an example of a start/stop script for SysV-style init, such |
98 | 1 | Herve Ballans | # as is used on Linux systems. You should edit some of the variables |
99 | 1 | Herve Ballans | # and maybe the 'echo' commands. |
100 | 1 | Herve Ballans | # |
101 | 1 | Herve Ballans | # Place this file at /etc/init.d/postgresql (or |
102 | 1 | Herve Ballans | # /etc/rc.d/init.d/postgresql) and make symlinks to |
103 | 1 | Herve Ballans | # /etc/rc.d/rc0.d/K02postgresql |
104 | 1 | Herve Ballans | # /etc/rc.d/rc1.d/K02postgresql |
105 | 1 | Herve Ballans | # /etc/rc.d/rc2.d/K02postgresql |
106 | 1 | Herve Ballans | # /etc/rc.d/rc3.d/S98postgresql |
107 | 1 | Herve Ballans | # /etc/rc.d/rc4.d/S98postgresql |
108 | 1 | Herve Ballans | # /etc/rc.d/rc5.d/S98postgresql |
109 | 1 | Herve Ballans | # Or, if you have chkconfig, simply: |
110 | 1 | Herve Ballans | # chkconfig --add postgresql |
111 | 1 | Herve Ballans | # |
112 | 1 | Herve Ballans | # Proper init scripts on Linux systems normally require setting lock |
113 | 1 | Herve Ballans | # and pid files under /var/run as well as reacting to network |
114 | 1 | Herve Ballans | # settings, so you should treat this with care. |
115 | 1 | Herve Ballans | |
116 | 1 | Herve Ballans | # Original author: Ryan Kirkpatrick <pgsql@rkirkpat.net> |
117 | 1 | Herve Ballans | |
118 | 1 | Herve Ballans | # $PostgreSQL: pgsql/contrib/start-scripts/linux,v 1.8 2006/07/13 14:44:33 petere Exp $ |
119 | 1 | Herve Ballans | |
120 | 1 | Herve Ballans | ## EDIT FROM HERE |
121 | 1 | Herve Ballans | |
122 | 1 | Herve Ballans | # Installation prefix |
123 | 1 | Herve Ballans | prefix=/usr/local/pgsql |
124 | 1 | Herve Ballans | |
125 | 1 | Herve Ballans | # Data directory |
126 | 1 | Herve Ballans | PGDATA="/usr/local/pgsql/data" |
127 | 1 | Herve Ballans | |
128 | 1 | Herve Ballans | # Who to run the postmaster as, usually "postgres". (NOT "root") |
129 | 1 | Herve Ballans | PGUSER=postgres |
130 | 1 | Herve Ballans | |
131 | 1 | Herve Ballans | # Where to keep a log file |
132 | 1 | Herve Ballans | PGLOG="$PGDATA/serverlog" |
133 | 1 | Herve Ballans | |
134 | 1 | Herve Ballans | ## STOP EDITING HERE |
135 | 1 | Herve Ballans | |
136 | 1 | Herve Ballans | # The path that is to be used for the script |
137 | 1 | Herve Ballans | PATH=/usr/local/sbin:/usr/local/bin:/usr/local/pgsql/bin:/sbin:/bin:/usr/sbin:/usr/bin |
138 | 1 | Herve Ballans | |
139 | 1 | Herve Ballans | # What to use to start up the postmaster (we do NOT use pg_ctl for this, |
140 | 1 | Herve Ballans | # as it adds no value and can cause the postmaster to misrecognize a stale |
141 | 1 | Herve Ballans | # lock file) |
142 | 1 | Herve Ballans | DAEMON="$prefix/bin/postmaster" |
143 | 1 | Herve Ballans | |
144 | 1 | Herve Ballans | # What to use to shut down the postmaster |
145 | 1 | Herve Ballans | PGCTL="$prefix/bin/pg_ctl" |
146 | 1 | Herve Ballans | |
147 | 1 | Herve Ballans | set -e |
148 | 1 | Herve Ballans | |
149 | 1 | Herve Ballans | # Only start if we can find the postmaster. |
150 | 1 | Herve Ballans | test -x $DAEMON || exit 0 |
151 | 1 | Herve Ballans | |
152 | 1 | Herve Ballans | # Parse command line parameters. |
153 | 1 | Herve Ballans | case $1 in |
154 | 1 | Herve Ballans | start) |
155 | 1 | Herve Ballans | echo -n "Starting PostgreSQL: " |
156 | 1 | Herve Ballans | su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 |
157 | 1 | Herve Ballans | echo "ok" |
158 | 1 | Herve Ballans | ;; |
159 | 1 | Herve Ballans | stop) |
160 | 1 | Herve Ballans | echo -n "Stopping PostgreSQL: " |
161 | 1 | Herve Ballans | su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast" |
162 | 1 | Herve Ballans | echo "ok" |
163 | 1 | Herve Ballans | ;; |
164 | 1 | Herve Ballans | restart) |
165 | 1 | Herve Ballans | echo -n "Restarting PostgreSQL: " |
166 | 1 | Herve Ballans | su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w" |
167 | 1 | Herve Ballans | su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 |
168 | 1 | Herve Ballans | echo "ok" |
169 | 1 | Herve Ballans | ;; |
170 | 1 | Herve Ballans | reload) |
171 | 1 | Herve Ballans | echo -n "Reload PostgreSQL: " |
172 | 1 | Herve Ballans | su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s" |
173 | 1 | Herve Ballans | echo "ok" |
174 | 1 | Herve Ballans | ;; |
175 | 1 | Herve Ballans | status) |
176 | 1 | Herve Ballans | su - $PGUSER -c "$PGCTL status -D '$PGDATA'" |
177 | 1 | Herve Ballans | ;; |
178 | 1 | Herve Ballans | *) |
179 | 1 | Herve Ballans | # Print help |
180 | 1 | Herve Ballans | echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2 |
181 | 1 | Herve Ballans | exit 1 |
182 | 1 | Herve Ballans | ;; |
183 | 1 | Herve Ballans | esac |
184 | 1 | Herve Ballans | |
185 | 1 | Herve Ballans | exit 0 |
186 | 1 | Herve Ballans | </pre> |
187 | 3 | Pablo Alingery | |
188 | 4 | Pablo Alingery | h3. Install additional modules |
189 | 3 | Pablo Alingery | |
190 | 3 | Pablo Alingery | Nous avons besoin de dblink pour les trigger entre bases de données |
191 | 7 | Pablo Alingery | <pre> |
192 | 7 | Pablo Alingery | root@sdo3:~# cd /Downloads/postgresql-9.4.4/contrib/dblink |
193 | 7 | Pablo Alingery | make install |
194 | 7 | Pablo Alingery | </pre> |
195 | 7 | Pablo Alingery | |
196 | 7 | Pablo Alingery | h4. ias_sdo |
197 | 7 | Pablo Alingery | |
198 | 7 | Pablo Alingery | <pre> |
199 | 7 | Pablo Alingery | root@sdo3:~/Downloads/postgresql-9.4.4/contrib/dblink# /usr/local/pgsql/bin/psql ias_sdo -p5432 -U postgres < dblink--1.1.sql |
200 | 7 | Pablo Alingery | Use "CREATE EXTENSION dblink" to load this file. |
201 | 7 | Pablo Alingery | root@sdo3:~/Downloads/postgresql-9.4.4/contrib/dblink# /usr/local/pgsql/bin/psql ias_sdo -p5432 -U postgres |
202 | 7 | Pablo Alingery | psql (9.4.4) |
203 | 7 | Pablo Alingery | Type "help" for help. |
204 | 7 | Pablo Alingery | |
205 | 7 | Pablo Alingery | ias_sdo_monitor=# CREATE EXTENSION dblink ; |
206 | 8 | Pablo Alingery | CREATE EXTENSION |
207 | 8 | Pablo Alingery | |
208 | 8 | Pablo Alingery | </pre> |
209 | 8 | Pablo Alingery | |
210 | 8 | Pablo Alingery | h4. ias_sdo_sums |
211 | 8 | Pablo Alingery | |
212 | 8 | Pablo Alingery | <pre> |
213 | 8 | Pablo Alingery | root@sdo3:~/Downloads/postgresql-9.4.4/contrib/dblink# /usr/local/pgsql/bin/psql ias_sdo_sums -p5434 -U postgres < dblink--1.1.sql |
214 | 8 | Pablo Alingery | Use "CREATE EXTENSION dblink" to load this file. |
215 | 8 | Pablo Alingery | root@sdo3:~/Downloads/postgresql-9.4.4/contrib/dblink# /usr/local/pgsql/bin/psql ias_sdo_sums -p5434 -U postgres |
216 | 8 | Pablo Alingery | psql (9.4.4) |
217 | 8 | Pablo Alingery | Type "help" for help. |
218 | 8 | Pablo Alingery | |
219 | 1 | Herve Ballans | ias_sdo_monitor=# CREATE EXTENSION dblink ; |
220 | 1 | Herve Ballans | CREATE EXTENSION |
221 | 7 | Pablo Alingery | |
222 | 7 | Pablo Alingery | </pre> |
223 | 7 | Pablo Alingery | |
224 | 7 | Pablo Alingery | h4. ias_sdo_monitor |
225 | 3 | Pablo Alingery | |
226 | 3 | Pablo Alingery | <pre> |
227 | 5 | Pablo Alingery | root@sdo3:~# cd /Downloads/postgresql-9.4.4/contrib/dblink |
228 | 5 | Pablo Alingery | make install |
229 | 5 | Pablo Alingery | |
230 | 5 | Pablo Alingery | root@sdo3:~/Downloads/postgresql-9.4.4/contrib/dblink# /usr/local/pgsql/bin/psql ias_sdo_monitor -p5436 -U postgres < dblink--1.1.sql |
231 | 5 | Pablo Alingery | Use "CREATE EXTENSION dblink" to load this file. |
232 | 5 | Pablo Alingery | root@sdo3:~/Downloads/postgresql-9.4.4/contrib/dblink# /usr/local/pgsql/bin/psql ias_sdo_monitor -p5436 -U postgres |
233 | 5 | Pablo Alingery | psql (9.4.4) |
234 | 5 | Pablo Alingery | Type "help" for help. |
235 | 5 | Pablo Alingery | |
236 | 5 | Pablo Alingery | ias_sdo_monitor=# CREATE EXTENSION dblink ; |
237 | 5 | Pablo Alingery | ERROR: type "dblink_pkey_results" already exists |
238 | 5 | Pablo Alingery | ias_sdo_monitor=# drop table pgWatch; |
239 | 5 | Pablo Alingery | ERROR: table "pgwatch" does not exist |
240 | 5 | Pablo Alingery | ias_sdo_monitor=# drop type dblink_pkey_results ; |
241 | 5 | Pablo Alingery | DROP TYPE |
242 | 5 | Pablo Alingery | ias_sdo_monitor=# CREATE EXTENSION dblink ; |
243 | 5 | Pablo Alingery | CREATE EXTENSION |
244 | 5 | Pablo Alingery | ias_sdo_monitor=# \q |
245 | 5 | Pablo Alingery | |
246 | 3 | Pablo Alingery | </pre> |