<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                一個朋友說參考了網址:http://www.mkyong.com/database/postgresql-point-in-time-recovery-incremental-backup/后做了一個基于時間點的數據庫恢復操作,但是失敗了。其過程大致如下:? 測試環境:vmware 8? os :centos 5.7 (final)? PG: version 9.1.2? ####以下是他的測試過程記錄 ~~~ postgres=# create table testPITR1 as select * from pg_class, pg_description; SELECT 936936 postgres=# select * from current_timestamp(0); timestamptz ------------------------ 2012-07-02 01:53:16-07 (1 row) postgres=# select pg_start_backup('full_backup-testing_20120702'); pg_start_backup ----------------- 0/60000020 (1 row) postgres=# select pg_current_xlog_location(); pg_current_xlog_location -------------------------- 0/600000B0 (1 row) ~~~ ~~~ --打包數據文件 tar pgdata.tar ./pgdata ~~~ ~~~ postgres=# select pg_stop_backup(); NOTICE: pg_stop_backup complete, all required WAL segments have been archived pg_stop_backup ---------------- 0/60000168 (1 row) postgres=# create table testPITR2 as select * from pg_class, pg_description; SELECT 946764 postgres=# select * from current_timestamp(0); timestamptz ------------------------ 2012-07-02 02:05:20-07 (1 row) postgres=# create table testPITR3 as select * from pg_class, pg_description; SELECT 956592 postgres=# select * from current_timestamp(0); timestamptz ------------------------ 2012-07-02 02:14:33-07 (1 row) postgres=# create table testPITR4 as select * from pg_class, pg_description; SELECT 966420 postgres=# select * from current_timestamp(0); timestamptz ------------------------ 2012-07-02 02:35:31-07 (1 row) postgres=# \d List of relations Schema | Name | Type | Owner --------+-------------+-------+---------- public | tesk | table | postgres public | test | table | postgres public | testpitr1 | table | postgres public | testpitr2 | table | postgres public | testpitr3 | table | postgres public | testpitr4 | table | postgres (7 rows) [postgres@localhost archive]$ pwd /home/postgres/archive [postgres@localhost archive]$ ls -lsh total 1.1G 64M -rw-------. 1 postgres postgres 64M Jul 2 01:41 000000020000000000000013 64M -rw-------. 1 postgres postgres 64M Jul 2 01:52 000000020000000000000014 64M -rw-------. 1 postgres postgres 64M Jul 2 01:52 000000020000000000000015 64M -rw-------. 1 postgres postgres 64M Jul 2 01:52 000000020000000000000016 64M -rw-------. 1 postgres postgres 64M Jul 2 01:56 000000020000000000000017 64M -rw-------. 1 postgres postgres 64M Jul 2 02:04 000000020000000000000018 4.0K -rw-------. 1 postgres postgres 295 Jul 2 02:04 000000020000000000000018.00000020.backup 64M -rw-------. 1 postgres postgres 64M Jul 2 02:04 000000020000000000000019 64M -rw-------. 1 postgres postgres 64M Jul 2 02:05 00000002000000000000001A 64M -rw-------. 1 postgres postgres 64M Jul 2 02:05 00000002000000000000001B 64M -rw-------. 1 postgres postgres 64M Jul 2 02:07 00000002000000000000001C 64M -rw-------. 1 postgres postgres 64M Jul 2 02:07 00000002000000000000001D 64M -rw-------. 1 postgres postgres 64M Jul 2 02:07 00000002000000000000001E 64M -rw-------. 1 postgres postgres 64M Jul 2 02:07 00000002000000000000001F 64M -rw-------. 1 postgres postgres 64M Jul 2 02:35 000000020000000000000020 64M -rw-------. 1 postgres postgres 64M Jul 2 02:35 000000020000000000000021 64M -rw-------. 1 postgres postgres 64M Jul 2 02:35 000000020000000000000022 64M -rw-------. 1 postgres postgres 64M Jul 2 02:35 000000020000000000000023 將原來的PGDATA通過move名字改為pgdata_bad [postgres@localhost pg_xlog]$ pwd /database/pgdata_bad/pg_xlog [postgres@localhost pg_xlog]$ ls -lsh total 1.9G 64M -rw-------. 1 postgres postgres 64M Jun 14 22:33 00000001000000000000000C 64M -rw-------. 1 postgres postgres 64M Jun 14 22:33 00000001000000000000000D 64M -rw-------. 1 postgres postgres 64M Jun 14 21:05 00000001000000000000000E 64M -rw-------. 1 postgres postgres 64M Jun 14 22:05 00000001000000000000000F 64M -rw-------. 1 postgres postgres 64M Jun 15 03:40 00000002000000000000000D 64M -rw-------. 1 postgres postgres 64M Jun 15 03:46 00000002000000000000000E 64M -rw-------. 1 postgres postgres 64M Jun 15 03:51 00000002000000000000000F 64M -rw-------. 1 postgres postgres 64M Jun 15 04:23 000000020000000000000010 64M -rw-------. 1 postgres postgres 64M Jun 25 02:41 000000020000000000000011 64M -rw-------. 1 postgres postgres 64M Jun 30 01:24 000000020000000000000012 65M -rw-------. 1 postgres postgres 64M Jul 2 01:41 000000020000000000000013 64M -rw-------. 1 postgres postgres 64M Jul 2 01:52 000000020000000000000014 64M -rw-------. 1 postgres postgres 64M Jul 2 01:52 000000020000000000000015 64M -rw-------. 1 postgres postgres 64M Jul 2 01:52 000000020000000000000016 64M -rw-------. 1 postgres postgres 64M Jul 2 01:56 000000020000000000000017 64M -rw-------. 1 postgres postgres 64M Jul 2 02:04 000000020000000000000018 4.0K -rw-------. 1 postgres postgres 295 Jul 2 02:04 000000020000000000000018.00000020.backup 64M -rw-------. 1 postgres postgres 64M Jul 2 02:04 000000020000000000000019 65M -rw-------. 1 postgres postgres 64M Jul 2 02:05 00000002000000000000001A 64M -rw-------. 1 postgres postgres 64M Jul 2 02:05 00000002000000000000001B 64M -rw-------. 1 postgres postgres 64M Jul 2 02:07 00000002000000000000001C 64M -rw-------. 1 postgres postgres 64M Jul 2 02:07 00000002000000000000001D 64M -rw-------. 1 postgres postgres 64M Jul 2 02:07 00000002000000000000001E 64M -rw-------. 1 postgres postgres 64M Jul 2 02:07 00000002000000000000001F 64M -rw-------. 1 postgres postgres 64M Jul 2 02:35 000000020000000000000020 64M -rw-------. 1 postgres postgres 64M Jul 2 02:35 000000020000000000000021 65M -rw-------. 1 postgres postgres 64M Jul 2 02:35 000000020000000000000022 64M -rw-------. 1 postgres postgres 64M Jul 2 02:35 000000020000000000000023 64M -rw-------. 1 postgres postgres 64M Jul 2 02:37 000000020000000000000024 4.0K -rw-------. 1 postgres postgres 56 Jun 14 22:34 00000002.history 4.0K drwx------. 2 postgres postgres 4.0K Jul 2 02:35 archive_status 36M -rw-------. 1 postgres postgres 36M Jun 25 02:41 xlogtemp.2046 24M -rw-------. 1 postgres postgres 24M Jun 30 01:24 xlogtemp.2077 ~~~ 將之前打包備份的文件釋放到pgdata位置,并重建pg_xlog文件,然后啟動? # rm -rf pg_xlog? # mkdir -p pg_xlog/archive_status? 這個時候啟動是正常的,PSQL可以登錄進去 ~~~ postgres=# \d List of relations Schema | Name | Type | Owner --------+-------------+-------+---------- public | tesk | table | postgres public | test | table | postgres public | testpitr1 | table | postgres (4 rows) ~~~ 因為沒有做恢復,所以是正常的。? 然后關閉數據庫,設置recovery.conf文件? restore_command = 'cp /home/postgres/archive/%f %p'? recovery_target_time = '2012-07-02 02:10:31'? 設置完了再啟動就報錯了,日志如下: ~~~ [root@localhost pg_log]# more postgresql-2012-07-03_014309.csv 2012-07-03 01:43:09.701 PDT,,,7621,,4ff2b09d.1dc5,1,,2012-07-03 01:43:09 PDT,,0,LOG,00000,"database system was shut down at 2012-07-03 00:03:21 PDT",,,,,,,,,"" 2012-07-03 01:43:09.764 PDT,,,7621,,4ff2b09d.1dc5,2,,2012-07-03 01:43:09 PDT,,0,LOG,00000,"starting point-in-time recovery to 2012-07-02 02:10:31-07",,,,,,,,,"" 2012-07-03 01:43:14.177 PDT,,,7621,,4ff2b09d.1dc5,3,,2012-07-03 01:43:09 PDT,,0,LOG,00000,"restored log file ""000000020000000000000019"" from archive",,,,,,,,,"" 2012-07-03 01:43:14.177 PDT,,,7621,,4ff2b09d.1dc5,4,,2012-07-03 01:43:09 PDT,,0,LOG,00000,"invalid resource manager ID in primary checkpoint record",,,,,,,,,"" 2012-07-03 01:43:14.342 PDT,,,7621,,4ff2b09d.1dc5,5,,2012-07-03 01:43:09 PDT,,0,LOG,00000,"restored log file ""000000020000000000000018"" from archive",,,,,,,,,"" 2012-07-03 01:43:14.342 PDT,,,7621,,4ff2b09d.1dc5,6,,2012-07-03 01:43:09 PDT,,0,LOG,00000,"invalid xl_info in secondary checkpoint record",,,,,,,,,"" 2012-07-03 01:43:14.342 PDT,,,7621,,4ff2b09d.1dc5,7,,2012-07-03 01:43:09 PDT,,0,PANIC,XX000,"could not locate a valid checkpoint record",,,,,,,,,"" 2012-07-03 01:43:18.500 PDT,,,7619,,4ff2b09c.1dc3,1,,2012-07-03 01:43:08 PDT,,0,LOG,00000,"startup process (PID 7621) was terminated by signal 6: Aborted",,,,,,,,,"" 2012-07-03 01:43:18.500 PDT,,,7619,,4ff2b09c.1dc3,2,,2012-07-03 01:43:08 PDT,,0,LOG,00000,"aborting startup due to startup process failure",,,,,,,,,"" [root@localhost pg_log]# more postgresql-2012-07-03_014309.log cp: cannot stat `/home/postgres/archive/00000002.history': No such file or directory [root@localhost archive]# more 00000002.history 1 00000001000000000000000D no recovery target specified ~~~ 看了一下,/home/postgres/archive/00000002.history這個文件確實是沒有,就從老的備份文件里面拷貝了一份過去,再啟動,.log文件沒有信息了,但是.csv文件報錯如下: ~~~ [root@localhost pg_log]# more postgresql-2012-07-03_014413.csv 2012-07-03 01:44:13.159 PDT,,,7647,,4ff2b0dd.1ddf,1,,2012-07-03 01:44:13 PDT,,0,LOG,00000,"database system was shut down at 2012-07-03 00:03:21 PDT",,,,,,,,,"" 2012-07-03 01:44:13.168 PDT,,,7647,,4ff2b0dd.1ddf,2,,2012-07-03 01:44:13 PDT,,0,LOG,00000,"restored log file ""00000002.history"" from archive",,,,,,,,,"" 2012-07-03 01:44:13.168 PDT,,,7647,,4ff2b0dd.1ddf,3,,2012-07-03 01:44:13 PDT,,0,LOG,00000,"starting point-in-time recovery to 2012-07-02 02:10:31-07",,,,,,,,,"" 2012-07-03 01:44:13.300 PDT,,,7647,,4ff2b0dd.1ddf,4,,2012-07-03 01:44:13 PDT,,0,LOG,00000,"restored log file ""000000020000000000000019"" from archive",,,,,,,,,"" 2012-07-03 01:44:13.300 PDT,,,7647,,4ff2b0dd.1ddf,5,,2012-07-03 01:44:13 PDT,,0,LOG,00000,"invalid resource manager ID in primary checkpoint record",,,,,,,,,"" 2012-07-03 01:44:13.407 PDT,,,7647,,4ff2b0dd.1ddf,6,,2012-07-03 01:44:13 PDT,,0,LOG,00000,"restored log file ""000000020000000000000018"" from archive",,,,,,,,,"" 2012-07-03 01:44:13.407 PDT,,,7647,,4ff2b0dd.1ddf,7,,2012-07-03 01:44:13 PDT,,0,LOG,00000,"invalid xl_info in secondary checkpoint record",,,,,,,,,"" 2012-07-03 01:44:13.407 PDT,,,7647,,4ff2b0dd.1ddf,8,,2012-07-03 01:44:13 PDT,,0,PANIC,XX000,"could not locate a valid checkpoint record",,,,,,,,,"" 2012-07-03 01:44:13.811 PDT,,,7645,,4ff2b0dc.1ddd,1,,2012-07-03 01:44:12 PDT,,0,LOG,00000,"startup process (PID 7647) was terminated by signal 6: Aborted",,,,,,,,,"" 2012-07-03 01:44:13.811 PDT,,,7645,,4ff2b0dc.1ddd,2,,2012-07-03 01:44:12 PDT,,0,LOG,00000,"aborting startup due to startup process failure",,,,,,,,,"" ~~~ 最終的PG_CONTROLDATA信息如下: ~~~ [postgres@localhost pgdata]$ pg_controldata pg_control version number: 903 Catalog version number: 201105231 Database system identifier: 5735970894348214195 Database cluster state: shut down pg_control last modified: Tue 03 Jul 2012 12:03:21 AM PDT Latest checkpoint location: 0/64000020 Prior checkpoint location: 0/60000140 Latest checkpoint's REDO location: 0/64000020 Latest checkpoint's TimeLineID: 2 Latest checkpoint's NextXID: 0/1859 Latest checkpoint's NextOID: 40985 Latest checkpoint's NextMultiXactId: 1 Latest checkpoint's NextMultiOffset: 0 Latest checkpoint's oldestXID: 1792 Latest checkpoint's oldestXID's DB: 1 Latest checkpoint's oldestActiveXID: 0 Time of latest checkpoint: Tue 03 Jul 2012 12:03:17 AM PDT Minimum recovery ending location: 0/0 Backup start location: 0/0 Current wal_level setting: hot_standby Current max_connections setting: 100 Current max_prepared_xacts setting: 0 Current max_locks_per_xact setting: 64 Maximum data alignment: 8 Database block size: 8192 Blocks per segment of large relation: 1048576 WAL block size: 65536 Bytes per WAL segment: 67108864 Maximum length of identifiers: 64 Maximum columns in an index: 32 Maximum size of a TOAST chunk: 1996 Date/time type storage: 64-bit integers Float4 argument passing: by value Float8 argument passing: by value ~~~ ########說明##########? 在上述恢復的過程中,該DB被啟動了兩次,在第一次啟動的時候是沒有指定recovery.conf文件的,這里有一個前后的順序問題,應該先配置recovery.conf,配置其恢復的時間點,然后啟動DB。啟動時已經有了一個check點了,這個時候再恢復到過去是不可能的,當然了,如果把recovery.conf中的recovery_target_time設置成比第一次啟動晚的時間點也是可以的。 我本機的檢測過程如下: ~~~ [postgres@localhost pgdata]$ psql psql (9.1.2) Type "help" for help. postgres=# select pg_current_xlog_location(); pg_current_xlog_location -------------------------- 0/94000078 (1 row) postgres=# \q [postgres@localhost pgdata]$ pg_stop waiting for server to shut down................. done server stopped [postgres@localhost pgdata]$ pg_start server starting [postgres@localhost pgdata]$ psql psql (9.1.2) Type "help" for help. postgres=# select pg_current_xlog_location(); pg_current_xlog_location -------------------------- 0/98000078 (1 row) ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看