forked from gleu/pgdocs_fr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oid2name.xml
298 lines (256 loc) · 9.14 KB
/
oid2name.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<?xml version="1.0" encoding="ISO-8859-15"?>
<!-- Dernière modification
le $Date$
par $Author$
révision $Revision$ -->
<sect1 id="oid2name">
<title>oid2name</title>
<indexterm zone="oid2name">
<primary>oid2name</primary>
</indexterm>
<para>
<application>oid2name</application> est un outil qui aide les administrateurs
à examiner la structure des fichiers utilisée par PostgreSQL. Pour l'utiliser,
vous devez être connaître la structure de fichiers utilisée de la base
de données. Elle est décrite dans <xref linkend="storage"/>.
</para>
<note>
<para>
Le nom <quote>oid2name</quote> est historique, et est maintenant plutôt
contradictoire car la plupart du temps, quand vous l'utiliserez, vous
aurez besoin de connaître les numéroes filenode des tables (qui sont le
nom des fichiers visibles dans les répertoires des bases de données).
Assurez-vous de bien comprendre la différence entre les OID des tables
et leur filenode !
</para>
</note>
<sect2>
<title>Aperçu</title>
<para>
<application>oid2name</application> se connecte à une base de données
cible et extrait OID, filenode, et/ou nom de table. Vous pouvez aussi
afficher les OID des bases et des tablespaces. Le programme est contrôlé
par un grand nombre d'options en ligne de commandes que montre
<xref linkend="oid2name-switches"/>.
</para>
<table id="oid2name-switches">
<title>Options de <application>oid2name</application></title>
<tgroup cols="2">
<thead>
<row>
<entry>Option</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>-o</literal> <replaceable>oid</replaceable></entry>
<entry>affiche des informations pour la table dont l'OID est
<replaceable>oid</replaceable></entry>
</row>
<row>
<entry><literal>-f</literal> <replaceable>filenode</replaceable></entry>
<entry>affiche des informations pour la table dont le filenode est
<replaceable>filenode</replaceable></entry>
</row>
<row>
<entry><literal>-t</literal> <replaceable>tablename_pattern</replaceable></entry>
<entry>affiche des informations pour les tables dont le nom correspond
au modèle <replaceable>tablename_pattern</replaceable></entry>
</row>
<row>
<entry><literal>-s</literal></entry>
<entry>affiche les OID des tablespaces</entry>
</row>
<row>
<entry><literal>-S</literal></entry>
<entry>inclut les objets système (ceux des schémas
<literal>information_schema</literal>, <literal>pg_toast</literal>
et <literal>pg_catalog</literal>)
</entry>
</row>
<row>
<entry><literal>-i</literal></entry>
<entry>inclut les index et les séquences dans la liste</entry>
</row>
<row>
<entry><literal>-x</literal></entry>
<entry>affiche plus d'informations sur chaque objet montré : nom
du tablespace, nom du schéma et OID
</entry>
</row>
<row>
<entry><literal>-q</literal></entry>
<entry>supprime les en-têtes (utile pour l'écriture de scripts)</entry>
</row>
<row>
<entry><literal>-d</literal> <replaceable>database</replaceable></entry>
<entry>la base de données de connexion</entry>
</row>
<row>
<entry><literal>-H</literal> <replaceable>host</replaceable></entry>
<entry>serveur</entry>
</row>
<row>
<entry><literal>-p</literal> <replaceable>port</replaceable></entry>
<entry>port du serveur</entry>
</row>
<row>
<entry><literal>-U</literal> <replaceable>username</replaceable></entry>
<entry>nom d'utilisateur pour la connexion</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
Pour afficher des tables spécifiques, sélectionnez les tables à afficher
en utilisant <literal>-o</literal>, <literal>-f</literal> et/ou
<literal>-t</literal>.
<literal>-o</literal> prend un OID,
<literal>-f</literal> prend un filenode,
et <literal>-t</literal> prend un nom de table (en fait, c'est un modèle
de type LIKE, donc vous pouvez utiliser <literal>foo%</literal> par
exemple). Vous pouvez utiliser autant d'options que vous le souhaitez, et
la liste incluera tous les objets en se basant sur chaque options. Mais
notez que ces options peuvent seulement afficher des objets appartenant
à la base de données indiquée par l'option <literal>-d</literal>.
</para>
<para>
Si vous n'utilisez pas <literal>-o</literal>, <literal>-f</literal> et
<literal>-t</literal>, mais que vous passez l'option <literal>-d</literal>,
cela listera toutes les tables dans la base nommée par l'option
<literal>-d</literal>. Dans ce mode, les options <literal>-S</literal> et
<literal>-i</literal> contrôlent ce qui est listé.
</para>
<para>
Si vous ne passez pas non plus <literal>-d</literal>, cela affichera une
liste des OID de bases de données. Autrement, vous pouvez passer l'option
<literal>-s</literal> pour obtenir une liste des tablespaces.
</para>
</sect2>
<sect2>
<title>Exemples</title>
<programlisting>
$ # quelles sont les bases disponibles ?
$ oid2name
All databases:
Oid Database Name Tablespace
----------------------------------
17228 alvherre pg_default
17255 regression pg_default
17227 template0 pg_default
1 template1 pg_default
$ oid2name -s
All tablespaces:
Oid Tablespace Name
-------------------------
1663 pg_default
1664 pg_global
155151 fastdisk
155152 bigdisk
$ # OK, jetons un ½il à la base alvherre
$ cd $PGDATA/base/17228
$ # récupérons les 10 premiers objets de la base dans le tablespace par défaut
$ # et triés par taille
$ ls -lS * | head -10
-rw------- 1 alvherre alvherre 136536064 sep 14 09:51 155173
-rw------- 1 alvherre alvherre 17965056 sep 14 09:51 1155291
-rw------- 1 alvherre alvherre 1204224 sep 14 09:51 16717
-rw------- 1 alvherre alvherre 581632 sep 6 17:51 1255
-rw------- 1 alvherre alvherre 237568 sep 14 09:50 16674
-rw------- 1 alvherre alvherre 212992 sep 14 09:51 1249
-rw------- 1 alvherre alvherre 204800 sep 14 09:51 16684
-rw------- 1 alvherre alvherre 196608 sep 14 09:50 16700
-rw------- 1 alvherre alvherre 163840 sep 14 09:50 16699
-rw------- 1 alvherre alvherre 122880 sep 6 17:51 16751
$ # à quoi correspond le fichier 155173 ?
$ oid2name -d alvherre -f 155173
From database "alvherre":
Filenode Table Name
----------------------
155173 accounts
$ # vous pouvez demander plus d'un objet à la fois
$ oid2name -d alvherre -f 155173 -f 1155291
From database "alvherre":
Filenode Table Name
-------------------------
155173 accounts
1155291 accounts_pkey
$ # vous pouvez mélanger les options et obtenir plus de détails avec -x
$ oid2name -d alvherre -t accounts -f 1155291 -x
From database "alvherre":
Filenode Table Name Oid Schema Tablespace
------------------------------------------------------
155173 accounts 155173 public pg_default
1155291 accounts_pkey 1155291 public pg_default
$ # affiche l'espace disque pour chaque objet d'une base de données
$ du [0-9]* |
> while read SIZE FILENODE
> do
> echo "$SIZE `oid2name -q -d alvherre -i -f $FILENODE`"
> done
16 1155287 branches_pkey
16 1155289 tellers_pkey
17561 1155291 accounts_pkey
...
$ # pareil, mais trié par taille
$ du [0-9]* | sort -rn | while read SIZE FN
> do
> echo "$SIZE `oid2name -q -d alvherre -f $FN`"
> done
133466 155173 accounts
17561 1155291 accounts_pkey
1177 16717 pg_proc_proname_args_nsp_index
...
$ # Si vous voulez voir ce qu'il y a dans un tablespace, utilisez le répertoire
$ # pg_tblspc
$ cd $PGDATA/pg_tblspc
$ oid2name -s
All tablespaces:
Oid Tablespace Name
-------------------------
1663 pg_default
1664 pg_global
155151 fastdisk
155152 bigdisk
$ # quelle base de données a des objets dans le tablespace "fastdisk" ?
$ ls -d 155151/*
155151/17228/ 155151/PG_VERSION
$ # Oh, quelle était la base de données 17228 ?
$ oid2name
All databases:
Oid Database Name Tablespace
----------------------------------
17228 alvherre pg_default
17255 regression pg_default
17227 template0 pg_default
1 template1 pg_default
$ # Voyons si quels objets de cette base sont dans ce tablespace.
$ cd 155151/17228
$ ls -l
total 0
-rw------- 1 postgres postgres 0 sep 13 23:20 155156
$ # OK, c'est une table très petite, mais laquelle est-ce ?
$ oid2name -d alvherre -f 155156
From database "alvherre":
Filenode Table Name
----------------------
155156 foo
</programlisting>
</sect2>
<sect2>
<title>Limites</title>
<para>
<application>oid2name</application> requiert que la serveur soit en cours
d'exécution avec des catalogues systèmes non corrompus. Son utilisation
est donc très limitée en ce qui concerne la récupération à partir de
situations catastrophiques de récupération.
</para>
</sect2>
<sect2>
<title>Auteur</title>
<para>
B. Palmer <email>bpalmer@crimelabs.net</email>
</para>
</sect2>
</sect1>