@@ -286,8 +286,8 @@ ____________________________________________________________________________-->
286
286
287
287
<!--==========================orignal english content==========================
288
288
<para>
289
- After restoring a backup, it is wise to run <xref
290
- linkend="sql-analyze"/ > on each
289
+ After restoring a backup, it is wise to run <link
290
+ linkend="sql-analyze"><command>ANALYZE</command></link > on each
291
291
database so the query optimizer has useful statistics;
292
292
see <xref linkend="vacuum-for-statistics"/>
293
293
and <xref linkend="autovacuum"/> for more information.
@@ -297,7 +297,7 @@ ____________________________________________________________________________-->
297
297
</para>
298
298
____________________________________________________________________________-->
299
299
<para>
300
- 一旦完成恢复,在每个数据库上运行<xref linkend="sql-analyze"/ >是明智的举动,这样优化器就有有用的统计数据了,更多信息参见<xref linkend="vacuum-for-statistics"/>和<xref linkend="autovacuum"/>。更多关于如何有效地向<productname>PostgreSQL</productname>里装载大量数据的建议, 请参考<xref linkend="populate"/>。
300
+ 一旦完成恢复,在每个数据库上运行<link linkend="sql-analyze"><command>ANALYZE</command></link >是明智的举动,这样优化器就有有用的统计数据了,更多信息参见<xref linkend="vacuum-for-statistics"/>和<xref linkend="autovacuum"/>。更多关于如何有效地向<productname>PostgreSQL</productname>里装载大量数据的建议, 请参考<xref linkend="populate"/>。
301
301
</para>
302
302
</sect2>
303
303
@@ -448,31 +448,48 @@ ____________________________________________________________________________-->
448
448
The <command>split</command> command
449
449
allows you to split the output into smaller files that are
450
450
acceptable in size to the underlying file system. For example, to
451
- make chunks of 1 megabyte :
451
+ make 2 gigabyte chunks :
452
452
453
453
<programlisting>
454
- pg_dump <replaceable class="parameter">dbname</replaceable> | split -b 1m - <replaceable class="parameter">filename</replaceable>
454
+ pg_dump <replaceable class="parameter">dbname</replaceable> | split -b 2G - <replaceable class="parameter">filename</replaceable>
455
455
</programlisting>
456
456
457
457
Reload with:
458
458
459
459
<programlisting>
460
460
cat <replaceable class="parameter">filename</replaceable>* | psql <replaceable class="parameter">dbname</replaceable>
461
461
</programlisting>
462
+
463
+ If using GNU <application>split</application>, it is possible to
464
+ use it and <application>gzip</application> together:
465
+
466
+ <programlisting>
467
+ pg_dump <replaceable class="parameter">dbname</replaceable> | split -b 2G -−filter='gzip > $FILE.gz'
468
+ </programlisting>
469
+
470
+ It can be restored using <command>zcat</command>.
462
471
</para>
463
472
____________________________________________________________________________-->
464
473
<para>
465
- <command>split</command>命令允许你将输出分割成较小的文件以便能够适应底层文件系统的尺寸要求。例如,让每一块的大小为1兆字节 :
474
+ <command>split</command>命令允许你将输出分割成较小的文件以便能够适应底层文件系统的尺寸要求。例如,让每一块的大小为2吉字节 :
466
475
467
476
<programlisting>
468
- pg_dump <replaceable class="parameter">dbname</replaceable> | split -b 1m - <replaceable class="parameter">filename</replaceable>
477
+ pg_dump <replaceable class="parameter">dbname</replaceable> | split -b 2G - <replaceable class="parameter">filename</replaceable>
469
478
</programlisting>
470
479
471
480
恢复:
472
481
473
482
<programlisting>
474
483
cat <replaceable class="parameter">filename</replaceable>* | psql <replaceable class="parameter">dbname</replaceable>
475
484
</programlisting>
485
+
486
+ 如果使用 GNU <application>split</application>, 可能会把它和 <application>gzip</application> 一起使用:
487
+
488
+ <programlisting>
489
+ pg_dump <replaceable class="parameter">dbname</replaceable> | split -b 2G -−filter='gzip > $FILE.gz'
490
+ </programlisting>
491
+
492
+ 它可以用 <command>zcat</command> 恢复。
476
493
</para>
477
494
</formalpara>
478
495
@@ -1022,6 +1039,21 @@ ____________________________________________________________________________-->
1022
1039
有一点很重要:当且仅当归档命令成功时,它才返回零退出。在得到一个零值结果之后,<productname>PostgreSQL</productname>将假设该文件已经成功归档, 因此它稍后将被删除或者被新的数据覆盖。但是,一个非零值告诉<productname>PostgreSQL</productname>该文件没有被归档; 因此它会周期性的重试直到成功。
1023
1040
</para>
1024
1041
1042
+ <!--==========================orignal english content==========================
1043
+ <para>
1044
+ When the archive command is terminated by a signal (other than
1045
+ <systemitem>SIGTERM</systemitem> that is used as part of a server
1046
+ shutdown) or an error by the shell with an exit status greater than
1047
+ 125 (such as command not found), the archiver process aborts and gets
1048
+ restarted by the postmaster. In such cases, the failure is
1049
+ not reported in <xref linkend="pg-stat-archiver-view"/>.
1050
+ </para>
1051
+ ____________________________________________________________________________-->
1052
+ <para>
1053
+ 当归档命令被一个信号(不是作为服务器关闭的一部分所用的<systemitem>SIGTERM</systemitem>)或者是退出状态超过125(例如命令没有发现)的脚本的一个错误所终止时,
1054
+ 归档进程会退出并且被postmaster重新启动。当这种情况下,<xref linkend="pg-stat-archiver-view"/> 中不会报告故障。
1055
+ </para>
1056
+
1025
1057
<!--==========================orignal english content==========================
1026
1058
<para>
1027
1059
The archive command should generally be designed to refuse to overwrite
@@ -1385,7 +1417,8 @@ SELECT * FROM pg_stop_backup(false, true);
1385
1417
<filename>backup_label</filename> in the root directory of the backup. The
1386
1418
third field should be written to a file named
1387
1419
<filename>tablespace_map</filename> unless the field is empty. These files are
1388
- vital to the backup working, and must be written without modification.
1420
+ vital to the backup working and must be written byte for byte without
1421
+ modification, which may require opening the file in binary mode.
1389
1422
</para>
1390
1423
</listitem>
1391
1424
<listitem>
@@ -1474,16 +1507,15 @@ SELECT pg_start_backup('label', false, false);
1474
1507
<para>
1475
1508
在同一个连接中,发出命令:
1476
1509
<programlisting>
1477
- SELECT * FROM pg_stop_backup(false);
1510
+ SELECT * FROM pg_stop_backup(false, true );
1478
1511
</programlisting>
1479
1512
这会终止备份模式。在主控机上,它还执行一次自动切换到下一个WAL段。在后备机上,它无法自动切换WAL段,因此用户可能希望在主控机上运行<function>pg_switch_wal</function>来执行一次手工切换。要做切换的原因是让在备份期间写入的最后一个WAL段文件能准备好被归档。
1480
1513
</para>
1481
1514
<para>
1482
1515
<function>pg_stop_backup</function>将返回一个具有三个值的行。这些域的
1483
1516
第二个应该被写入到该备份根目录中名为<filename>backup_label</filename>的
1484
1517
文件。第三个域应该被写入到一个名为<filename>tablespace_map</filename>
1485
- 的文件,除非该域为空。这些文件对该备份正常工作来说是至关重要的,
1486
- 不能被随意修改。
1518
+ 的文件,除非该域为空。这些文件对该备份正常工作来说是至关重要的,必须逐个字节的写入而不能被随意修改,可能需要采用二进制的方式打开文件。
1487
1519
</para>
1488
1520
</listitem>
1489
1521
<listitem>
@@ -1533,7 +1565,7 @@ ____________________________________________________________________________-->
1533
1565
non-exclusive one, but it differs in a few key steps. This type of
1534
1566
backup can only be taken on a primary and does not allow concurrent
1535
1567
backups. Moreover, because it creates a backup label file, as
1536
- described below, it can block automatic restart of the master server
1568
+ described below, it can block automatic restart of the primary server
1537
1569
after a crash. On the other hand, the erroneous removal of this
1538
1570
file from a backup or standby is a common mistake, which can result
1539
1571
in serious data corruption. If it is necessary to use this method,
@@ -1607,9 +1639,9 @@ SELECT pg_start_backup('label', true);
1607
1639
this will result in corruption. Confusion about when it is appropriate
1608
1640
to remove this file is a common cause of data corruption when using this
1609
1641
method; be very certain that you remove the file only on an existing
1610
- master and never when building a standby or restoring a backup, even if
1642
+ primary and never when building a standby or restoring a backup, even if
1611
1643
you are building a standby that will subsequently be promoted to a new
1612
- master .
1644
+ primary .
1613
1645
</para>
1614
1646
</listitem>
1615
1647
<listitem>
@@ -1794,16 +1826,16 @@ ____________________________________________________________________________-->
1794
1826
<para>
1795
1827
It is often a good idea to also omit from the backup the files
1796
1828
within the cluster's <filename>pg_replslot/</filename> directory, so that
1797
- replication slots that exist on the master do not become part of the
1829
+ replication slots that exist on the primary do not become part of the
1798
1830
backup. Otherwise, the subsequent use of the backup to create a standby
1799
1831
may result in indefinite retention of WAL files on the standby, and
1800
- possibly bloat on the master if hot standby feedback is enabled, because
1832
+ possibly bloat on the primary if hot standby feedback is enabled, because
1801
1833
the clients that are using those replication slots will still be connecting
1802
- to and updating the slots on the master , not the standby. Even if the
1803
- backup is only intended for use in creating a new master , copying the
1834
+ to and updating the slots on the primary , not the standby. Even if the
1835
+ backup is only intended for use in creating a new primary , copying the
1804
1836
replication slots isn't expected to be particularly useful, since the
1805
1837
contents of those slots will likely be badly out of date by the time
1806
- the new master comes on line.
1838
+ the new primary comes on line.
1807
1839
</para>
1808
1840
____________________________________________________________________________-->
1809
1841
<para>
@@ -2280,16 +2312,17 @@ ____________________________________________________________________________-->
2280
2312
2281
2313
<!--==========================orignal english content==========================
2282
2314
<para>
2283
- The default behavior of recovery is to recover along the same timeline
2284
- that was current when the base backup was taken. If you wish to recover
2285
- into some child timeline (that is, you want to return to some state that
2286
- was itself generated after a recovery attempt), you need to specify the
2287
- target timeline ID in <xref linkend="guc-recovery-target-timeline"/>. You cannot recover into
2288
- timelines that branched off earlier than the base backup.
2315
+ The default behavior of recovery is to recover to the latest timeline found
2316
+ in the archive. If you wish to recover to the timeline that was current
2317
+ when the base backup was taken or into a specific child timeline (that
2318
+ is, you want to return to some state that was itself generated after a
2319
+ recovery attempt), you need to specify <literal>current</literal> or the
2320
+ target timeline ID in <xref linkend="guc-recovery-target-timeline"/>. You
2321
+ cannot recover into timelines that branched off earlier than the base backup.
2289
2322
</para>
2290
2323
____________________________________________________________________________-->
2291
2324
<para>
2292
- 恢复的默认行为是沿着相同的时间线进行恢复,该时间线是基础备份创建时的当前时间线。如果你希望恢复到某个子女时间线 (即,你希望回到在一次恢复尝试后产生的某个状态),你需要在 <xref linkend="guc-recovery-target-timeline"/>中指定目标时间线ID。你不能恢复到早于该基础备份之前分支出去的时间线。
2325
+ 恢复的默认行为是沿着归档中所发现的最新的时间线进行恢复。如果你希望恢复到执行基础备份时的当前时间线或者某个指定的子时间线 (即,你希望回到在一次恢复尝试后产生的某个状态),你需要指定<literal>current</literal>或者在 <xref linkend="guc-recovery-target-timeline"/>中指定目标时间线ID。你不能恢复到早于该基础备份之前分支出去的时间线。
2293
2326
</para>
2294
2327
</sect2>
2295
2328
@@ -2416,22 +2449,22 @@ ____________________________________________________________________________-->
2416
2449
If archive storage size is a concern, you can use
2417
2450
<application>gzip</application> to compress the archive files:
2418
2451
<programlisting>
2419
- archive_command = 'gzip < %p > /var/lib/pgsql/archive/%f '
2452
+ archive_command = 'gzip < %p > /mnt/server/archivedir/%f.gz '
2420
2453
</programlisting>
2421
2454
You will then need to use <application>gunzip</application> during recovery:
2422
2455
<programlisting>
2423
- restore_command = 'gunzip < /mnt/server/archivedir/%f > %p'
2456
+ restore_command = 'gunzip < /mnt/server/archivedir/%f.gz > %p'
2424
2457
</programlisting>
2425
2458
</para>
2426
2459
____________________________________________________________________________-->
2427
2460
<para>
2428
2461
如果担心归档存储的尺寸,你可以使用<application>gzip</application>来压缩归档文件:
2429
2462
<programlisting>
2430
- archive_command = 'gzip < %p > /var/lib/pgsql/archive/%f '
2463
+ archive_command = 'gzip < %p > /mnt/server/archivedir/%f.gz '
2431
2464
</programlisting>
2432
2465
那么在恢复时你将需要使用<application>gunzip</application>:
2433
2466
<programlisting>
2434
- restore_command = 'gunzip < /mnt/server/archivedir/%f > %p'
2467
+ restore_command = 'gunzip < /mnt/server/archivedir/%f.gz > %p'
2435
2468
</programlisting>
2436
2469
</para>
2437
2470
</sect3>
@@ -2550,7 +2583,7 @@ ____________________________________________________________________________-->
2550
2583
<itemizedlist>
2551
2584
<listitem>
2552
2585
<para>
2553
- If a <xref linkend="sql-createdatabase"/ >
2586
+ If a <link linkend="sql-createdatabase"><command>CREATE DATABASE</command></link >
2554
2587
command is executed while a base backup is being taken, and then
2555
2588
the template database that the <command>CREATE DATABASE</command> copied
2556
2589
is modified while the base backup is still in progress, it is
@@ -2563,7 +2596,7 @@ ____________________________________________________________________________-->
2563
2596
2564
2597
<listitem>
2565
2598
<para>
2566
- <xref linkend="sql-createtablespace"/ >
2599
+ <link linkend="sql-createtablespace"><command>CREATE TABLESPACE</command></link >
2567
2600
commands are WAL-logged with the literal absolute path, and will
2568
2601
therefore be replayed as tablespace creations with the same
2569
2602
absolute path. This might be undesirable if the log is being
@@ -2584,13 +2617,13 @@ ____________________________________________________________________________-->
2584
2617
<itemizedlist>
2585
2618
<listitem>
2586
2619
<para>
2587
- 如果一个<xref linkend="sql-createdatabase"/ >命令在基础备份时被执行,然后在基础备份进行时<command>CREATE DATABASE</command>所复制的模板数据库被修改,恢复中可能会导致这些修改也被传播到已创建的数据库中。这当然是我们不希望的。为了避免这种风险,最好不要在创建基础备份时修改任何模板数据库。
2620
+ 如果一个<link linkend="sql-createdatabase"><command>CREATE DATABASE</command></link >命令在基础备份时被执行,然后在基础备份进行时<command>CREATE DATABASE</command>所复制的模板数据库被修改,恢复中可能会导致这些修改也被传播到已创建的数据库中。这当然是我们不希望的。为了避免这种风险,最好不要在创建基础备份时修改任何模板数据库。
2588
2621
</para>
2589
2622
</listitem>
2590
2623
2591
2624
<listitem>
2592
2625
<para>
2593
- <xref linkend="sql-createtablespace"/ >命令会WAL以其字面绝对路径记录,并且因此将在重放时以相同的绝对路径来创建表空间。当日志在一台不同的机器上被重放时,这可能也不是我们希望的。即使日志在同一台机器上被重放也是危险的,就算是恢复到一个新的数据目录重放过程也会覆盖原来表空间的内容。为了避免这种潜在的陷阱,最佳做法是在创建或丢弃表空间后创建一个新的基础备份。
2626
+ <link linkend="sql-createtablespace"><command>CREATE TABLESPACE</command></link >命令会WAL以其字面绝对路径记录,并且因此将在重放时以相同的绝对路径来创建表空间。当日志在一台不同的机器上被重放时,这可能也不是我们希望的。即使日志在同一台机器上被重放也是危险的,就算是恢复到一个新的数据目录重放过程也会覆盖原来表空间的内容。为了避免这种潜在的陷阱,最佳做法是在创建或丢弃表空间后创建一个新的基础备份。
2594
2627
</para>
2595
2628
</listitem>
2596
2629
</itemizedlist>
0 commit comments