-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp-pgcreatesubscriber.html
More file actions
587 lines (586 loc) · 52.8 KB
/
app-pgcreatesubscriber.html
File metadata and controls
587 lines (586 loc) · 52.8 KB
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_createsubscriber</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pgcontroldata.html" title="pg_controldata" /><link rel="next" href="app-pg-ctl.html" title="pg_ctl" /><meta name="viewport" content="width=device-width,initial-scale=1.0" /></head><body id="docContent" class="container-fluid col-10"><div class="other_version"><a href="https://www.postgresql.jp/document/">バージョンごとのドキュメント一覧</a></div><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="4" align="center"><a accesskey="h" href="index.html">PostgreSQL 18.3文書</a></th></tr><tr><td width="10%" align="left"></td><td width="10%" align="left"></td><td width="60%" align="center"><a href="reference-server.html" title="PostgreSQLサーバアプリケーション">PostgreSQLサーバアプリケーション</a></td><td width="20%" align="right"><div class="actions"><a class="issue" title="github" href="https://github.com/pgsql-jp/jpug-doc/issues/new?template=bug_report.yml&what-happened=version 18.3 : app-pgcreatesubscriber.html">誤訳等の報告
</a></div></td></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgcontroldata.html" title="pg_controldata">前へ</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-server.html" title="PostgreSQLサーバアプリケーション">上へ</a></td><td width="60%" align="center"><span class="application">pg_createsubscriber</span></td><td width="20%" align="right"> <a accesskey="n" href="app-pg-ctl.html" title="pg_ctl">次へ</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGCREATESUBSCRIBER"><div class="titlepage"></div><a id="id-1.9.5.7.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_createsubscriber</span></span></h2><p>pg_createsubscriber<span class="original">
<refpurpose>convert a physical replica into a new logical replica</refpurpose>
</span> — 物理レプリカを新しい論理レプリカに変換する</p></div><div class="refsynopsisdiv"><h2>概要</h2><div class="cmdsynopsis"><p id="id-1.9.5.7.4.1"><code class="command">pg_createsubscriber</code> [<em class="replaceable"><code>option</code></em>...] { <code class="option">-d</code> | <code class="option">--database</code> }<em class="replaceable"><code>dbname</code></em> { <code class="option">-D</code> | <code class="option">--pgdata</code> }<em class="replaceable"><code>datadir</code></em> { <code class="option">-P</code> | <code class="option">--publisher-server</code> }<em class="replaceable"><code>connstr</code></em> </p></div></div><div class="refsect1" id="id-1.9.5.7.5"><h2>説明</h2><span class="original">
<title>Description</title>
</span><p>
<span class="original">
<application>pg_createsubscriber</application> creates a new logical
replica from a physical standby server. All tables in the specified
database are included in the <link linkend="logical-replication">logical
replication</link> setup. A pair of
publication and subscription objects are created for each database. It
must be run at the target server.
</span>
<span class="application">pg_createsubscriber</span>は、物理スタンバイサーバから新しい論理レプリカを作成します。
指定されたデータベース内のすべてのテーブルが<a class="link" href="logical-replication.html" title="第29章 論理レプリケーション">論理レプリケーション</a>設定に含まれます。
各データベースに対して、パブリケーションとサブスクリプションのオブジェクトのペアが作成されます。
ターゲットサーバで実行する必要があります。
</p><p>
<span class="original">
After a successful run, the state of the target server is analogous to a
fresh logical replication setup. The main difference between the logical
replication setup and <application>pg_createsubscriber</application> is how
the data synchronization is done. <application>pg_createsubscriber</application>
does not copy the initial table data. It does only the synchronization phase,
which ensures each table is brought up to a synchronized state.
</span>
実行が成功した後のターゲットサーバの状態は、新しい論理レプリケーションセットアップに似ています。
論理レプリケーションセットアップと<span class="application">pg_createsubscriber</span>の間の主な差は、データ同期化が行われる方法です。
<span class="application">pg_createsubscriber</span>は初期テーブルデータをコピーしません。
各テーブルが同期化された状態になることを保証する同期化フェーズのみを行います。
</p><p>
<span class="original">
<application>pg_createsubscriber</application> targets large database
systems because in logical replication setup, most of the time is spent
doing the initial data copy. Furthermore, a side effect of this long time
spent synchronizing data is usually a large amount of changes to be applied
(that were produced during the initial data copy), which increases even
more the time when the logical replica will be available. For smaller
databases, it is recommended to set up logical replication with initial data
synchronization. For details, see the <command>CREATE SUBSCRIPTION</command>
<link linkend="sql-createsubscription-params-with-copy-data">
<literal>copy_data</literal></link> option.
</span>
<span class="application">pg_createsubscriber</span>は大きなデータベースシステムを対象としています。
これは、論理レプリケーションセットアップではほとんどの時間が最初のデータコピーに費やされるためです。
さらに、データの同期に費やされるこの長い時間の副作用は、通常、適用される変更が大きな量になること(最初のデータコピー中に生成されたもの)であり、これは、ロジカルレプリカが利用可能になるまでの時間をさらに増加させます。
小規模なデータベースの場合は、最初のデータ同期付きで論理レプリケーションを設定することをお勧めします。
詳細については、<code class="command">CREATE SUBSCRIPTION</code><a class="link" href="sql-createsubscription.html#SQL-CREATESUBSCRIPTION-PARAMS-WITH-COPY-DATA"><code class="literal">copy_data</code></a>オプションを参照してください。
</p></div><div class="refsect1" id="id-1.9.5.7.6"><h2>オプション</h2><span class="original">
<title>Options</title>
</span><p>
<span class="original">
<application>pg_createsubscriber</application> accepts the following
command-line arguments:
</span>
<span class="application">pg_createsubscriber</span>は、以下のコマンドライン引数を受け付けます。
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-a</code><br /></span><span class="term"><code class="option">--all</code></span></dt><dd><p>
<span class="original">
Create one subscription per database on the target server. Exceptions
are template databases and databases that don't allow connections.
To discover the list of all databases, connect to the source server
using the database name specified in the <option>&#45;-publisher-server</option>
connection string, or if not specified, the <literal>postgres</literal>
database will be used, or if that does not exist, <literal>template1</literal>
will be used.
Automatically generated names for subscriptions, publications, and
replication slots are used when this option is specified.
This option cannot be used along with <option>&#45;-database</option>,
<option>&#45;-publication</option>, <option>&#45;-replication-slot</option>, or
<option>&#45;-subscription</option>.
</span>
ターゲットサーバのデータベースごとに1つのサブスクリプションを作成します。
例外はテンプレートデータベースと、接続を許可していないデータベースです。
すべてのデータベースの一覧を得る際には、<code class="option">--publisher-server</code>接続文字列で指定されたデータベース名を用いてソースサーバに接続します。指定されていない場合は<code class="literal">postgres</code>データベースが使用されます。これが存在しない場合は、<code class="literal">template1</code>が使用されます。
このオプションが指定された場合、サブスクリプション、パブリケーション、そしてレプリケーションスロットに対して、自動的に生成された名前が使用されます。
このオプションは<code class="option">--database</code>、<code class="option">--publication</code>、<code class="option">--replication-slot</code>、または<code class="option">--subscription</code>とは併用できません。
</p></dd><dt><span class="term"><code class="option">-d <em class="replaceable"><code>dbname</code></em></code><br /></span><span class="term"><code class="option">--database=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
<span class="original">
The name of the database in which to create a subscription. Multiple
databases can be selected by writing multiple <option>-d</option>
switches. This option cannot be used together with <option>-a</option>.
If <option>-d</option> option is not provided, the database name will be
obtained from <option>-P</option> option. If the database name is not
specified in either the <option>-d</option> option, or the
<option>-P</option> option, and <option>-a</option> option is not
specified, an error will be reported.
</span>
サブスクリプションを作成するデータベースの名前。
複数の<code class="option">-d</code>を記述することによって、複数のデータベースを選択できます。
このオプションと<code class="option">-a</code>は併用できません。
<code class="option">-d</code>が指定されていない場合、データベース名は<code class="option">-P</code>オプションから取得されます。
データベース名が<code class="option">-d</code>オプションと<code class="option">-P</code>のどちらにも指定されず、<code class="option">-a</code>オプションも指定されていない場合は、エラーが報告されます。
</p></dd><dt><span class="term"><code class="option">-D <em class="replaceable"><code>directory</code></em></code><br /></span><span class="term"><code class="option">--pgdata=<em class="replaceable"><code>directory</code></em></code></span></dt><dd><p>
<span class="original">
The target directory that contains a cluster directory from a physical
replica.
</span>
物理レプリカのクラスタディレクトリを含むターゲットディレクトリ。
</p></dd><dt><span class="term"><code class="option">-n</code><br /></span><span class="term"><code class="option">--dry-run</code></span></dt><dd><p>
<span class="original">
Do everything except actually modifying the target directory.
</span>
ターゲットディレクトリを実際に更新する以外はすべてのことを行います。
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--subscriber-port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
<span class="original">
The port number on which the target server is listening for
connections. Defaults to running the target server on port 50432 to
avoid unintended client connections.
</span>
ターゲットサーバが接続をリスニングするポート番号。
デフォルトでは、ターゲットサーバはポート50432で実行され、意図しないクライアント接続を回避します。
</p></dd><dt><span class="term"><code class="option">-P <em class="replaceable"><code>connstr</code></em></code><br /></span><span class="term"><code class="option">--publisher-server=<em class="replaceable"><code>connstr</code></em></code></span></dt><dd><p>
<span class="original">
The connection string to the publisher. For details see <xref
linkend="libpq-connstring"/>.
</span>
パブリッシャーへの接続文字列。
詳細は<a class="xref" href="libpq-connect.html#LIBPQ-CONNSTRING" title="32.1.1. 接続文字列">32.1.1</a>を参照してください。
</p></dd><dt><span class="term"><code class="option">-s <em class="replaceable"><code>dir</code></em></code><br /></span><span class="term"><code class="option">--socketdir=<em class="replaceable"><code>dir</code></em></code></span></dt><dd><p>
<span class="original">
The directory to use for postmaster sockets on target server. The
default is current directory.
</span>
ターゲットサーバ上のpostmasterソケットに使用するディレクトリ。
デフォルトは現在のディレクトリです。
</p></dd><dt><span class="term"><code class="option">-t <em class="replaceable"><code>seconds</code></em></code><br /></span><span class="term"><code class="option">--recovery-timeout=<em class="replaceable"><code>seconds</code></em></code></span></dt><dd><p>
<span class="original">
The maximum number of seconds to wait for recovery to end. Setting to
0 disables. The default is 0.
</span>
リカバリーが終了するまでの最大待ち時間(秒)。
0に設定すると無効になります。
デフォルトは0です。
</p></dd><dt><span class="term"><code class="option">-T</code><br /></span><span class="term"><code class="option">--enable-two-phase</code></span></dt><dd><p>
<span class="original">
Enables <link linkend="sql-createsubscription-params-with-two-phase"><literal>two_phase</literal></link>
commit for the subscription. When multiple databases are specified, this
option applies uniformly to all subscriptions created on those databases.
The default is <literal>false</literal>.
</span>
サブスクリプションの<a class="link" href="sql-createsubscription.html#SQL-CREATESUBSCRIPTION-PARAMS-WITH-TWO-PHASE"><code class="literal">two_phase</code></a>コミットを有効にします。
複数のデータベースが指定された場合、このオプションはこれらのデータベース上に作成されたすべてのサブスクリプションに対して一律に適用されます。
デフォルトは<code class="literal">false</code>です。
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--subscriber-username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
<span class="original">
The user name to connect as on target server. Defaults to the current
operating system user name.
</span>
ターゲットサーバに接続するためのユーザ名。
デフォルトは、現在のオペレーティングシステムユーザ名です。
</p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>
<span class="original">
Enables verbose mode. This will cause
<application>pg_createsubscriber</application> to output progress
messages and detailed information about each step to standard error.
Repeating the option causes additional debug-level messages to appear
on standard error.
</span>
冗長モードを有効にします。
これにより<span class="application">pg_createsubscriber</span>は進捗メッセージと各ステップの詳細情報を標準エラーに出力します。
オプションを繰り返すと、追加のデバッグレベルメッセージが標準エラーに出力されます。
</p></dd><dt><span class="term"><code class="option">--clean=<em class="replaceable"><code>objtype</code></em></code></span></dt><dd><p>
<span class="original">
Drop all objects of the specified type from specified databases on the
target server.
</span>
ターゲットサーバ上の指定されたデータベースから、指定されたタイプのオブジェクトをすべて削除します。
</p><p>
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
<span class="original">
<literal>publications</literal>:
The <literal>FOR ALL TABLES</literal> publications established for this
subscriber are always dropped; specifying this object type causes all
other publications replicated from the source server to be dropped as
well.
</span>
<code class="literal">publications</code>:
このサブスクライバーに作成された<code class="literal">FOR ALL TABLES</code>パブリケーションは常に削除されます。このオブジェクトタイプを指定すると、ソースサーバから複製されたほかのすべてのパブリケーションも削除されます。
</p></li></ul></div><p>
</p><p>
<span class="original">
The objects selected to be dropped are individually logged, including during
a <option>&#45;-dry-run</option>. There is no opportunity to affect or stop the
dropping of the selected objects, so consider taking a backup of them
using <application>pg_dump</application>.
</span>
削除対象として選択されたオブジェクトは、<code class="option">--dry-run</code>中も含めて個別に記録されます。
選択されたオブジェクトの削除に影響を与えたり、停止したりすることはできません。
そのため<span class="application">pg_dump</span>を用いてそれらのバックアップを取得することを検討してください。
</p></dd><dt><span class="term"><code class="option">--config-file=<em class="replaceable"><code>filename</code></em></code></span></dt><dd><p>
<span class="original">
Use the specified main server configuration file for the target data
directory. <application>pg_createsubscriber</application> internally uses
the <application>pg_ctl</application> command to start and
stop the target server. It allows you to specify the actual
<filename>postgresql.conf</filename> configuration file if it is stored
outside the data directory.
</span>
ターゲットデータディレクトリ用に指定されたメインサーバの設定ファイルを使用します。
<span class="application">pg_createsubscriber</span>は、内部的に<span class="application">pg_ctl</span>コマンドをスタートに使用し、ターゲットサーバを起動、停止します。
データディレクトリ外に保存されている場合は、実際の<code class="filename">postgresql.conf</code>設定ファイルを指定できます。
</p></dd><dt><span class="term"><code class="option">--publication=<em class="replaceable"><code>name</code></em></code></span></dt><dd><p>
<span class="original">
The publication name to set up the logical replication. Multiple
publications can be specified by writing multiple
<option>&#45;-publication</option> switches. The number of publication
names must match the number of specified databases, otherwise an error
is reported. The order of the multiple publication name switches must
match the order of database switches. If this option is not specified,
a generated name is assigned to the publication name. This option cannot
be used together with <option>&#45;-all</option>.
</span>
論理レプリケーションを設定するパブリケーション名。
複数の<code class="option">--publication</code>スイッチを指定することで、複数のパブリケーションを指定できます。
パブリケーション名の数は、指定されたデータベースの数と一致する必要があります。
一致しない場合、エラーが報告されます。
パブリケーション名のスイッチの順序は、データベースのスイッチの順序と一致する必要があります。
このオプションを指定しない場合、生成された名前がパブリケーション名に割り当てられます。
このオプションと<code class="option">--all</code>は併用できません。
</p></dd><dt><span class="term"><code class="option">--replication-slot=<em class="replaceable"><code>name</code></em></code></span></dt><dd><p>
<span class="original">
The replication slot name to set up the logical replication. Multiple
replication slots can be specified by writing multiple
<option>&#45;-replication-slot</option> switches. The number of
replication slot names must match the number of specified databases,
otherwise an error is reported. The order of the multiple replication
slot name switches must match the order of database switches. If this
option is not specified, the subscription name is assigned to the
replication slot name. This option cannot be used together with
<option>&#45;-all</option>.
</span>
論理レプリケーションを設定するレプリケーションスロット名。
複数の<code class="option">--replication-slot</code>スイッチを書くことで、複数のレプリケーションスロットを指定できます。
レプリケーションスロット名の数は、指定されたデータベースの数と一致する必要があります。
一致しない場合、エラーが報告されます。
複数のレプリケーションスロット名スイッチの順序は、データベーススイッチの順序と一致する必要があります。
このオプションを指定しない場合、サブスクリプション名がレプリケーションスロット名に割り当てられます。
このオプションと<code class="option">--all</code>は併用できません。
</p></dd><dt><span class="term"><code class="option">--subscription=<em class="replaceable"><code>name</code></em></code></span></dt><dd><p>
<span class="original">
The subscription name to set up the logical replication. Multiple
subscriptions can be specified by writing multiple
<option>&#45;-subscription</option> switches. The number of subscription
names must match the number of specified databases, otherwise an error
is reported. The order of the multiple subscription name switches must
match the order of database switches. If this option is not specified,
a generated name is assigned to the subscription name. This option cannot
be used together with <option>&#45;-all</option>.
</span>
論理レプリケーションを設定するサブスクリプション名。
複数の<code class="option">--subscription</code>スイッチを指定することで、複数のサブスクリプションを指定できます。
サブスクリプション名の数は、指定されたデータベースの数と一致する必要があります。
一致しない場合、エラーが報告されます。
複数のサブスクリプション名スイッチの順序は、データベーススイッチの順序と一致する必要があります。
このオプションを指定しない場合、生成された名前がサブスクリプション名に割り当てられます。
このオプションと<code class="option">--all</code>は併用できません。
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
<span class="original">
Print the <application>pg_createsubscriber</application> version and exit.
</span>
<span class="application">pg_createsubscriber</span>のバージョンを表示し、終了します。
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
<span class="original">
Show help about <application>pg_createsubscriber</application> command
line arguments, and exit.
</span>
<span class="application">pg_createsubscriber</span>コマンドライン引数についてのヘルプを表示し、終了します。
</p></dd></dl></div><p>
</p></div><div class="refsect1" id="id-1.9.5.7.7"><h2>注釈</h2><span class="original">
<title>Notes</title>
</span><div class="refsect2" id="id-1.9.5.7.7.2"><h3>前提条件</h3><span class="original">
<title>Prerequisites</title>
</span><p>
<span class="original">
There are some prerequisites for
<application>pg_createsubscriber</application> to convert the target server
into a logical replica. If these are not met, an error will be reported.
The source and target servers must have the same major version as the
<application>pg_createsubscriber</application>. The given target data
directory must have the same system identifier as the source data
directory. The given database user for the target data directory must have
privileges for creating <link
linkend="sql-createsubscription">subscriptions</link> and using <link
linkend="pg-replication-origin-advance"><function>pg_replication_origin_advance()</function></link>.
</span>
<span class="application">pg_createsubscriber</span>がターゲットサーバを論理レプリカに変換するためには、いくつかの前提条件があります。
これらの条件が満たされない場合、エラーが報告されます。
ソースサーバとターゲットサーバは<span class="application">pg_createsubscriber</span>と同じメジャーバージョンでなければなりません。
指定されたターゲットデータディレクトリは、ソースデータディレクトリと同じシステム識別子を持つ必要があります。
指定されたターゲットデータディレクトリのデータベースユーザは、<a class="link" href="sql-createsubscription.html" title="CREATE SUBSCRIPTION">サブスクリプションの作成</a>と<a class="link" href="functions-admin.html#PG-REPLICATION-ORIGIN-ADVANCE"><code class="function">pg_replication_origin_advance()</code></a>を使用するための権限を持たなければなりません。
</p><p>
<span class="original">
The target server must be used as a physical standby. The target server
must have <xref linkend="guc-max-active-replication-origins"/> and <xref
linkend="guc-max-logical-replication-workers"/> configured to a value
greater than or equal to the number of specified databases. The target
server must have <xref linkend="guc-max-worker-processes"/> configured to a
value greater than the number of specified databases. The target server
must accept local connections. If you are planning to use the
<option>&#45;-enable-two-phase</option> switch then you will also need to set
the <xref linkend="guc-max-prepared-transactions"/> appropriately.
</span>
ターゲットサーバは、物理スタンバイとして使用する必要があります。
ターゲットサーバの<a class="xref" href="runtime-config-replication.html#GUC-MAX-ACTIVE-REPLICATION-ORIGINS">max_active_replication_origins</a>と<a class="xref" href="runtime-config-replication.html#GUC-MAX-LOGICAL-REPLICATION-WORKERS">max_logical_replication_workers</a>は、指定されたデータベースの数以上の値に設定されている必要があります。
ターゲットサーバの<a class="xref" href="runtime-config-resource.html#GUC-MAX-WORKER-PROCESSES">max_worker_processes</a>は、指定されたデータベースの数以上の値に設定されている必要があります。
ターゲットサーバは、ローカル接続を受け入れる必要があります。
<code class="option">--enable-two-phase</code>スイッチと併用することを検討している場合は、同様に<a class="xref" href="runtime-config-resource.html#GUC-MAX-PREPARED-TRANSACTIONS">max_prepared_transactions</a>も適切に設定する必要があります。
</p><p>
<span class="original">
The source server must accept connections from the target server. The
source server must not be in recovery. The source server must have <xref
linkend="guc-wal-level"/> as <literal>logical</literal>. The source server
must have <xref linkend="guc-max-replication-slots"/> configured to a value
greater than or equal to the number of specified databases plus existing
replication slots. The source server must have <xref
linkend="guc-max-wal-senders"/> configured to a value greater than or equal
to the number of specified databases and existing WAL sender processes.
</span>
ソースサーバはターゲットサーバからの接続を受け入れなければなりません。
ソースサーバはリカバリ状態であってはなりません。
ソースサーバは<a class="xref" href="runtime-config-wal.html#GUC-WAL-LEVEL">wal_level</a>を<code class="literal">logical</code>にする必要があります。
ソースサーバは、指定されたデータベースの数に既存のレプリケーションスロットを加えた値以上に<a class="xref" href="runtime-config-replication.html#GUC-MAX-REPLICATION-SLOTS">max_replication_slots</a>を設定する必要があります。
ソースサーバは、指定されたデータベースの数と既存のWAL送信プロセス以上の値に<a class="xref" href="runtime-config-replication.html#GUC-MAX-WAL-SENDERS">max_wal_senders</a>を設定する必要があります。
</p></div><div class="refsect2" id="id-1.9.5.7.7.3"><h3>警告</h3><span class="original">
<title>Warnings</title>
</span><p>
<span class="original">
If <application>pg_createsubscriber</application> fails after the target
server was promoted, then the data directory is likely not in a state that
can be recovered. In such case, creating a new standby server is
recommended.
</span>
ターゲットサーバの昇格後に<span class="application">pg_createsubscriber</span>が失敗した場合、データディレクトリはリカバリ可能な状態ではない可能性が高いです。
このような場合は、新しいスタンバイサーバを作成することをお勧めします。
</p><p>
<span class="original">
<application>pg_createsubscriber</application> usually starts the target
server with different connection settings during transformation. Hence,
connections to the target server should fail.
</span>
<span class="application">pg_createsubscriber</span>は通常、変換中に異なる接続設定でターゲットサーバを起動します。
したがって、ターゲットサーバへの接続は失敗するはずです。
</p><p>
<span class="original">
Since DDL commands are not replicated by logical replication, avoid
executing DDL commands that change the database schema while running
<application>pg_createsubscriber</application>. If the target server has
already been converted to logical replica, the DDL commands might not be
replicated, which might cause an error.
</span>
DDLコマンドは論理レプリケーションではレプリケートされないため、<span class="application">pg_createsubscriber</span>の実行中にデータベーススキーマを変更するDDLコマンドは実行しないでください。
ターゲットサーバがすでに論理レプリカに変換されている場合、DDLコマンドはレプリケートされない可能性があり、エラーが発生する可能性があります。
</p><p>
<span class="original">
If <application>pg_createsubscriber</application> fails while processing,
objects (publications, replication slots) created on the source server are
removed. The removal might fail if the target server cannot connect to
the source server. In such a case, a warning message will inform the
objects left. If the target server is running, it will be stopped.
</span>
処理中に<span class="application">pg_createsubscriber</span>が失敗した場合、ソースサーバ上に作成されたオブジェクト(パブリケーション、レプリケーションスロット)は削除されます。
ターゲットサーバがソースサーバに接続できない場合、削除は失敗する可能性があります。
このような場合、警告メッセージが残されたオブジェクトを通知します。
ターゲットサーバが実行中の場合は、停止されます。
</p><p>
<span class="original">
If the replication is using <xref linkend="guc-primary-slot-name"/>, it
will be removed from the source server after the logical replication
setup.
</span>
レプリケーションが<a class="xref" href="runtime-config-replication.html#GUC-PRIMARY-SLOT-NAME">primary_slot_name</a>を使用している場合、論理レプリケーション設定後にソースサーバから削除されます。
</p><p>
<span class="original">
If the target server is a synchronous replica, transaction commits on the
primary might wait for replication while running
<application>pg_createsubscriber</application>.
</span>
ターゲットサーバが同期レプリカの場合、<span class="application">pg_createsubscriber</span>の実行中にプライマリでのトランザクションコミットがレプリケーションを待つことがあります。
</p><p>
<span class="original">
Unless the <option>&#45;-enable-two-phase</option> switch is specified,
<application>pg_createsubscriber</application> sets up logical
replication with two-phase commit disabled. This means that any
prepared transactions will be replicated at the time
of <command>COMMIT PREPARED</command>, without advance preparation.
Once setup is complete, you can manually drop and re-create the
subscription(s) with
the <link linkend="sql-createsubscription-params-with-two-phase"><literal>two_phase</literal></link>
option enabled.
</span>
<code class="option">--enable-two-phase</code>スイッチを指定しない限り、<span class="application">pg_createsubscriber</span>は二相コミットを無効にして論理レプリケーションを設定します。
これは、準備されたトランザクションが事前の準備なしに<code class="command">COMMIT PREPARED</code>の時点で複製されることを意味します。
セットアップが完了したら、<a class="link" href="sql-createsubscription.html#SQL-CREATESUBSCRIPTION-PARAMS-WITH-TWO-PHASE"><code class="literal">two_phase</code></a>オプションを有効にしてサブスクリプションを手動で削除し、再作成することができます。
</p><p>
<span class="original">
<application>pg_createsubscriber</application> changes the system
identifier using <application>pg_resetwal</application>. It would avoid
situations in which the target server might use WAL files from the source
server. If the target server has a standby, replication will break and a
fresh standby should be created.
</span>
<span class="application">pg_createsubscriber</span>は<span class="application">pg_resetwal</span>を使用してシステム識別子を変更します。
これは、ターゲットサーバがソースサーバからのWALファイルを使用する可能性がある状況を回避します。
ターゲットサーバにスタンバイがある場合、レプリケーションが中断され、新しいスタンバイを作成する必要があります。
</p><p>
<span class="original">
Replication failures can occur if required WAL files are missing. To prevent
this, the source server must set
<xref linkend="guc-max-slot-wal-keep-size"/> to <literal>-1</literal> to
ensure that required WAL files are not prematurely removed.
</span>
必要なWALファイルが存在しない場合、レプリケーションが失敗することがあります。
これを防ぐためには、ソースサーバで<a class="xref" href="runtime-config-replication.html#GUC-MAX-SLOT-WAL-KEEP-SIZE">max_slot_wal_keep_size</a>を<code class="literal">-1</code>に指定し、必要なWALファイルが早期に削除されないようにする必要があります。
</p></div><div class="refsect2" id="id-1.9.5.7.7.4"><h3>どうやって動くのか</h3><span class="original">
<title>How It Works</title>
</span><p>
<span class="original">
The basic idea is to have a replication start point from the source server
and set up a logical replication to start from this point:
</span>
基本的な考え方は、ソースサーバからレプリケーションの開始ポイントを設定し、このポイントから開始する論理レプリケーションをセットアップすることです。
</p><div class="procedure"><ol class="procedure" type="1"><li class="step"><p>
<span class="original">
Start the target server with the specified command-line options. If the
target server is already running,
<application>pg_createsubscriber</application> will terminate with an
error.
</span>
指定したコマンドラインオプションでターゲットサーバを起動します。
ターゲットサーバがすでに実行中の場合、<span class="application">pg_createsubscriber</span>はエラーで終了します。
</p></li><li class="step"><p>
<span class="original">
Check if the target server can be converted. There are also a few
checks on the source server. If any of the prerequisites are not met,
<application>pg_createsubscriber</application> will terminate with an
error.
</span>
ターゲットサーバを変換できるかどうかをチェックします。
ソースサーバに対してもいくつかのチェックが行われます。
前提条件のいずれかが満たされていない場合、<span class="application">pg_createsubscriber</span>はエラーで終了します。
</p></li><li class="step"><p>
<span class="original">
Create a publication and replication slot for each specified database on
the source server. Each publication is created using <link
linkend="sql-createpublication-params-for-all-tables"><literal>FOR ALL
TABLES</literal></link>. If the <option>&#45;-publication</option> option
is not specified, the publication has the following name pattern:
<quote><literal>pg_createsubscriber_%u_%x</literal></quote> (parameter:
database <parameter>oid</parameter>, random <parameter>int</parameter>).
If the <option>&#45;-replication-slot</option> option is not specified, the
replication slot has the following name pattern:
<quote><literal>pg_createsubscriber_%u_%x</literal></quote> (parameters:
database <parameter>oid</parameter>, random <parameter>int</parameter>).
These replication slots will be used by the subscriptions in a future
step. The last replication slot LSN is used as a stopping point in the
<xref linkend="guc-recovery-target-lsn"/> parameter and by the
subscriptions as a replication start point. It guarantees that no
transaction will be lost.
</span>
ソースサーバ上の指定されたデータベースごとに、パブリケーションとレプリケーションスロットを作成します。
各パブリケーションは<a class="link" href="sql-createpublication.html#SQL-CREATEPUBLICATION-PARAMS-FOR-ALL-TABLES"><code class="literal">FOR ALL TABLES</code></a>を使用して作成されます。
<code class="option">--publication</code>オプションが指定されていない場合、パブリケーションは次のような名前のパターンになります。
<span class="quote">「<span class="quote"><code class="literal">pg_createsubscriber_%u_%x</code></span>」</span>(パラメータ: データベース<em class="parameter"><code>oid</code></em>、ランダム<em class="parameter"><code>int</code></em>)。
<code class="option">--replication-slot</code>が指定されない場合、レプリケーションスロットは次のような名前のパターンになります。
<span class="quote">「<span class="quote"><code class="literal">pg_createsubscriber_%u_%x</code></span>」</span>(パラメータ: データベース<em class="parameter"><code>oid</code></em>、ランダム<em class="parameter"><code>int</code></em>)。
これらのレプリケーションスロットは、今後の手順でサブスクリプションによって使用されます。
最後のレプリケーションスロットLSNは、<a class="xref" href="runtime-config-wal.html#GUC-RECOVERY-TARGET-LSN">recovery_target_lsn</a>パラメータの停止点として、また、サブスクリプションによってレプリケーション開始点として使用されます。
これにより、トランザクションが失われることがなくなります。
</p></li><li class="step"><p>
<span class="original">
Write recovery parameters into the target data directory and restart the
target server. It specifies an LSN (<xref
linkend="guc-recovery-target-lsn"/>) of the write-ahead log location up
to which recovery will proceed. It also specifies
<literal>promote</literal> as the action that the server should take
once the recovery target is reached. Additional <link
linkend="runtime-config-wal-recovery-target">recovery parameters</link>
are added to avoid unexpected behavior during the recovery process such
as end of the recovery as soon as a consistent state is reached (WAL
should be applied until the replication start location) and multiple
recovery targets that can cause a failure. This step finishes once the
server ends standby mode and is accepting read-write transactions. If
<option>&#45;-recovery-timeout</option> option is set,
<application>pg_createsubscriber</application> terminates if recovery
does not end until the given number of seconds.
</span>
ターゲットデータディレクトリにリカバリパラメータを書き込み、ターゲットサーバを再起動します。
リカバリが進行するまでの先行書き込みログの場所のLSN(<a class="xref" href="runtime-config-wal.html#GUC-RECOVERY-TARGET-LSN">recovery_target_lsn</a>)を指定します。
また、リカバリ対象に到達した時点でサーバが取るべきアクションとして<code class="literal">promote</code>を指定します。
整合性のある状態に到達したらすぐにリカバリを終了する(WALはレプリケーション開始位置まで適用されるべきです)、複数のリカバリターゲットが障害を引き起こす可能性があるなど、リカバリプロセス中の予期しない動作を回避するために、<a class="link" href="runtime-config-wal.html#RUNTIME-CONFIG-WAL-RECOVERY-TARGET" title="19.5.6. リカバリターゲット">リカバリパラメータ</a>が追加されます。
このステップは、サーバがスタンバイモードを終了し、読み取り/書き込みトランザクションを受け入れると完了します。
<code class="option">--recovery-timeout</code>オプションが設定されている場合、指定された秒数が経過するまでリカバリが終了しない場合、<span class="application">pg_createsubscriber</span>は終了します。
</p></li><li class="step"><p>
<span class="original">
Create a subscription for each specified database on the target server.
If the <option>&#45;-subscription</option> option is not specified, the
subscription has the following name pattern:
<quote><literal>pg_createsubscriber_%u_%x</literal></quote> (parameters:
database <parameter>oid</parameter>, random <parameter>int</parameter>).
It does not copy existing data from the source server. It does not
create a replication slot. Instead, it uses the replication slot that
was created in a previous step. The subscription is created but it is
not enabled yet. The reason is the replication progress must be set to
the replication start point before starting the replication.
</span>
ターゲットサーバ上の指定した各データベースに対してサブスクリプションを作成します。
<code class="option">--subscription</code>が指定されない場合、サブスクリプションは次のような名前のパターンになります。
<span class="quote">「<span class="quote"><code class="literal">pg_createsubscriber_%u_%x</code></span>」</span>(パラメータ: データベース<em class="parameter"><code>oid</code></em>、ランダム<em class="parameter"><code>int</code></em>)。
ソースサーバから既存のデータをコピーしません。
レプリケーションスロットは作成されません。
代わりに、前の手順で作成したレプリケーションスロットを使用します。
サブスクリプションは作成されましたが、まだ有効ではありません。
これは、レプリケーションを開始する前に、レプリケーションの進行状況をレプリケーション開始点に設定する必要があるためです。
</p></li><li class="step"><p>
<span class="original">
Drop publications on the target server that were replicated because they
were created before the replication start location. It has no use on
the subscriber.
</span>
レプリケーション開始位置より前に作成されていたために複製された、ターゲットサーバ上のパブリケーション削除します。
これはサブスクライバー側では使用されません。
</p></li><li class="step"><p>
<span class="original">
Set the replication progress to the replication start point for each
subscription. When the target server starts the recovery process, it
catches up to the replication start point. This is the exact LSN to be
used as a initial replication location for each subscription. The
replication origin name is obtained since the subscription was created.
The replication origin name and the replication start point are used in
<link
linkend="pg-replication-origin-advance"><function>pg_replication_origin_advance()</function></link>
to set up the initial replication location.
</span>
各サブスクリプションのレプリケーション開始点にレプリケーションの進行状況を設定します。
ターゲットサーバがリカバリプロセスを開始すると、レプリケーションの開始時点まで追いつきます。
これは、各サブスクリプションの初期レプリケーションの場所として使用される正確なLSNです。
サブスクリプションが作成されたため、レプリケーションオリジン名が取得されます。
レプリケーションオリジン名とレプリケーション開始点は、<a class="link" href="functions-admin.html#PG-REPLICATION-ORIGIN-ADVANCE"><code class="function">pg_replication_origin_advance()</code></a>で初期レプリケーション場所を設定するために使用されます。
</p></li><li class="step"><p>
<span class="original">
Enable the subscription for each specified database on the target server.
The subscription starts applying transactions from the replication start
point.
</span>
ターゲットサーバ上の指定した各データベースのサブスクリプションを使用可能にします。
サブスクリプションは、レプリケーション開始ポイントからトランザクションを適用し始めます。
</p></li><li class="step"><p>
<span class="original">
If the standby server was using <xref linkend="guc-primary-slot-name"/>,
it has no use from now on so drop it.
</span>
スタンバイサーバが<a class="xref" href="runtime-config-replication.html#GUC-PRIMARY-SLOT-NAME">primary_slot_name</a>を使用していた場合、それは今後は使用されないので削除します。
</p></li><li class="step"><p>
<span class="original">
If the standby server contains <link
linkend="logicaldecoding-replication-slots-synchronization">failover
replication slots</link>, they cannot be synchronized anymore, so drop
them.
</span>
スタンバイサーバに<a class="link" href="logicaldecoding-explanation.html#LOGICALDECODING-REPLICATION-SLOTS-SYNCHRONIZATION" title="47.2.3. レプリケーションスロットの同期">フェイルオーバーレプリケーションスロット</a>がある場合、もはや同期できないので削除します。
</p></li><li class="step"><p>
<span class="original">
Update the system identifier on the target server. The
<xref linkend="app-pgresetwal"/> is run to modify the system identifier.
The target server is stopped as a <command>pg_resetwal</command> requirement.
</span>
ターゲットサーバのシステム識別子を更新します。
<a class="xref" href="app-pgresetwal.html" title="pg_resetwal"><span class="refentrytitle"><span class="application">pg_resetwal</span></span></a>が実行され、システム識別子が変更されます。
<code class="command">pg_resetwal</code>の必要条件なので、ターゲットサーバは停止されます。
</p></li></ol></div></div></div><div class="refsect1" id="id-1.9.5.7.8"><h2>例</h2><span class="original">
<title>Examples</title>
</span><p>
<span class="original">
To create a logical replica for databases <literal>hr</literal> and
<literal>finance</literal> from a physical replica at
<literal>foo</literal>:
</span>
<code class="literal">foo</code>での物理レプリカからデータベース<code class="literal">hr</code>と<code class="literal">finance</code>の論理レプリカを作成するには、次のようにします。
</p><pre class="screen">
<code class="prompt">$</code> <strong class="userinput"><code>pg_createsubscriber -D /usr/local/pgsql/data -P "host=foo" -d hr -d finance</code></strong>
</pre><p>
</p></div><div class="refsect1" id="id-1.9.5.7.9"><h2>関連項目</h2><span class="original">
<title>See Also</title>
</span><span class="simplelist"><a class="xref" href="app-pgbasebackup.html" title="pg_basebackup"><span class="refentrytitle"><span class="application">pg_basebackup</span></span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgcontroldata.html" title="pg_controldata">前へ</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-server.html" title="PostgreSQLサーバアプリケーション">上へ</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pg-ctl.html" title="pg_ctl">次へ</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_controldata</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.3文書">ホーム</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_ctl</span></td></tr></table></div></body></html>