Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
2010 Hokkaido
              http://www.ospn.jp/osc2010-do/




PostgreSQL 9.0


     PostgreSQL            / NTT OSS



  ...
PostgreSQL 9.0




                 /




                     2
PostgreSQL 9.0
              9.0 5
                                                                                       ...
PostgreSQL 9.0


      1.
      2.              (                                              )
      3.            VACUU...
1.
 9.0              2




                          •
     =
     =                    •



                      (      ...
vs.
        READ WRITE                READ WRITE




                        ( v8.4)

8.4
                                ...
vs.
                         Slony-I                pgpool-II
           9.0             2.0                    2.3




  ...
2.

                   (UNIQUE)
      “    ”   “    ”
               (EXCLUDE)
      “        ”          “   ”




     GP...
CREATE TABLE placement (
                                     &&       “    ”
  object   text,
  location box, --
  EXCLUD...
3.          VACUUM FULL
 VACUUM FULL
     8.4      “    ”
             →
     9.0      “    ”
                       →

 V...
PostgreSQL


  VACUUM
VACUUM     8.4                                    ,
 FULL      9.0                                  ...
+




    12
PostgreSQL 9.0
                 (HS)

                               2
                        (SR)
    WAL




    8.0

 ...
(PG8.0)




        archive_command
rsync
                = cp, scp




                                14
(PG8.0)




   restore_command     rsync
           = cp, scp




                               15
(PG8.3)

DB                         DB




        restore_command
            = pg_standby




                          ...
(PG9.0)

DB                                            DB

     primary_conninfo


                                       ...
SQL (                )
master/standby                /
                 (standby   master    )


                         ...
(    OK)




SQL


            19
vs.
      9.0




            (    )


(               )
                                     9.1



cf. MySQL 5.5 : Semi-...
WAL
            WAL                ?
① pg_current_xlog_location()
                WAL                 /
② pg_last_xlog_rec...
pg_dump
– max_standby_delay


–     /


– pg_start_backup()   / pg_control




                                     22
23
:
postgresql.conf
  wal_level → hot_standby, archive_mode → on



  archive_command
     WAL
  vacuum_defer_cleanup_age
  ...
:
postgresql.conf
   hot_standby → on
                           ?
   max_standby_delay = 30s


recovery.conf             ...
: wal_level (          )
WAL
      minimal (         )


                    WAL
           COPY TO, CREATE INDEX, CLUSTER...
max_standby_delay (                               )
                 ?




pg_dump




                                   ...
vacuum_defer_cleanup_age (       )
               ?
max_standby_delay
VACUUM
  PostgreSQL        = UPDATE, DELETE
HOT
  VA...
max_connections :
max_prepared_xacts : XA
max_locks_per_xact :




max_connections =
                    + max_wal_senders...
30
wal_level = hot_standby
                                        archive_mode = on
EDIT $PGDATA1/postgresql.conf           ...
/
                              ①


         pg_ctl start                   pg_ctl start
standby_mode = ‘off’             ...
PostgreSQL “9.0”
“               ”

                        “Let’s Postgres”
    http://lets.postgresql.jp/documents/techn...
34
PostgreSQL            → 9.1
              9.1



   SQL/MED

                                             SQL-DB

        ...
PostgreSQL 9.0




                 36
Upcoming SlideShare
Loading in …5
×

PostgreSQL 9.0 Update ~ホット・スタンバイがやってきた!~

12,685 views

Published on

PostgreSQL 9.0の新機能を紹介し、特にホット・スタンバイ・レプリケーションについて、その動作や使い方を詳しく解説します。

  • Be the first to comment

PostgreSQL 9.0 Update ~ホット・スタンバイがやってきた!~

  1. 1. 2010 Hokkaido http://www.ospn.jp/osc2010-do/ PostgreSQL 9.0 PostgreSQL / NTT OSS 2010.6.26 1
  2. 2. PostgreSQL 9.0 / 2
  3. 3. PostgreSQL 9.0 9.0 5 9.0.0 2 / 3 Ingress Ingress PostgreSQL PostgreSQL 8.1 1977 6.0 6.0 7.4 7.4 •• •2 8.3 9.0 (2010/8 ) •2 1986 1996 2000 •• •HOT: •HOT: • • 2003 •VACUUM •VACUUM 2004 • • • • POSTGRES POSTGRES 2005 • • // 2006 7.3 7.3 • • 2007 2008 2009 8.0 2010 •Windows 8.2 •Windows •• •CPU •CPU •• (PITR) (PITR) • • 8. •• •GIN: •GIN: Window Window •VACUUM •VACUUM • DBMS • DBMS 3
  4. 4. PostgreSQL 9.0 1. 2. ( ) 3. VACUUM FULL 1 2 3 / LISTEN/NOTIFY / Windows 64-bit ( URL ) http://developer.postgresql.org/pgdocs/postgres/release-9-0.html http://lets.postgresql.jp/documents/technical/9.0/ 4
  5. 5. 1. 9.0 2 • = = • ( ) VACUUM / PostgreSQL 5
  6. 6. vs. READ WRITE READ WRITE ( v8.4) 8.4 WAL archive_command WAL pg_standby ( 1 ) READ WRITE READ WRITE 9.0 (v9.0) WAL ( ) wal sender WAL wal receiver 9.0 9.0 6
  7. 7. vs. Slony-I pgpool-II 9.0 2.0 2.3 DB ( ) DB SQL PK , DDL ※ ☆ 10 10 3 ( ) ○ ○ ○ ☆ ※PK= , DDL= 7
  8. 8. 2. (UNIQUE) “ ” “ ” (EXCLUDE) “ ” “ ” GPS 8
  9. 9. CREATE TABLE placement ( && “ ” object text, location box, -- EXCLUDE USING gist (location WITH &&) ); CREATE TABLE reservation ( room text, during period, -- { , } EXCLUDE USING gist (room WITH =, during WITH &&) ); gist text gist contrib/btree_gist period ( 9.1 ) 9
  10. 10. 3. VACUUM FULL VACUUM FULL 8.4 “ ” → 9.0 “ ” → VACUUM FULL VACUUM FULL UP UP VACUUM ( ) FULL FULL +TRUNCATE 10
  11. 11. PostgreSQL VACUUM VACUUM 8.4 , FULL 9.0 , CLUSTER + , REINDEX - , VACUUM VACUUM FULL (8.4) REINDEX VACUUM FULL (9.0) CLUSTER REINDEX REINDEX 11
  12. 12. + 12
  13. 13. PostgreSQL 9.0 (HS) 2 (SR) WAL 8.0 8.3 9.0 13
  14. 14. (PG8.0) archive_command rsync = cp, scp 14
  15. 15. (PG8.0) restore_command rsync = cp, scp 15
  16. 16. (PG8.3) DB DB restore_command = pg_standby 16
  17. 17. (PG9.0) DB DB primary_conninfo OK restore_command = cp, scp pg_standby 17
  18. 18. SQL ( ) master/standby / (standby master ) 18
  19. 19. ( OK) SQL 19
  20. 20. vs. 9.0 ( ) ( ) 9.1 cf. MySQL 5.5 : Semi-Synchronous Replication ? ? 20
  21. 21. WAL WAL ? ① pg_current_xlog_location() WAL / ② pg_last_xlog_receive_location() ③ pg_last_xlog_replay_location() :② ① :③ ① SQL (32bit+32bit ) WAL 21
  22. 22. pg_dump – max_standby_delay – / – pg_start_backup() / pg_control 22
  23. 23. 23
  24. 24. : postgresql.conf wal_level → hot_standby, archive_mode → on archive_command WAL vacuum_defer_cleanup_age VACUUM ? max_wal_senders → max_connections wal_sender_delay 24
  25. 25. : postgresql.conf hot_standby → on ? max_standby_delay = 30s recovery.conf recovery.conf standby_mode = ‘on’ ? off (WAL ) primary_conninfo restore_command WAL trigger_file pg_ctl stop → start 25
  26. 26. : wal_level ( ) WAL minimal ( ) WAL COPY TO, CREATE INDEX, CLUSTER, VACUUM FULL 8.4 archive_mode = off archive 8.4 archive_mode = on archive_mode hot_standby archive WAL 26
  27. 27. max_standby_delay ( ) ? pg_dump or canceling statement due to conflict with recovery terminating connection due to conflict with recovery 27
  28. 28. vacuum_defer_cleanup_age ( ) ? max_standby_delay VACUUM PostgreSQL = UPDATE, DELETE HOT VACUUM autovacuum HOT 28
  29. 29. max_connections : max_prepared_xacts : XA max_locks_per_xact : max_connections = + max_wal_senders wal_level, archive_mode, max_wal_senders (pg_ctl reload) 29
  30. 30. 30
  31. 31. wal_level = hot_standby archive_mode = on EDIT $PGDATA1/postgresql.conf archive_command = 'cp %p /arclog/%f' max_wal_senders = 1 EDIT $PGDATA1/pg_hba.conf pg_ctl start -D $PGDATA1 SELECT pg_start_backup(‘label’) host replication postgres ::1/128 trust rsync ( ) SELECT pg_stop_backup() rsync -av –delete --exclude=pg_xlog --exclude=postmaster.pid $PGDATA1/* $BACKUP/pgdata rsync ( ) hot_standby = on chmod -R 0700 ※ mkdir $PGDATA2/pg_xlog EDIT $PGDATA2/postgresql.conf EDIT $PGDATA2/recovery.conf restore_command = 'cp /arclog/%f %p' pg_ctl start -D $PGDATA2 standby_mode = 'on' primary_conninfo = 'host=localhost' 31
  32. 32. / ① pg_ctl start pg_ctl start standby_mode = ‘off’ standby_mode = ‘on’ pg_ctl stop pg_ctl stop trigger_file ( ) ② 32
  33. 33. PostgreSQL “9.0” “ ” “Let’s Postgres” http://lets.postgresql.jp/documents/technical/9.0/1 SQL = 33
  34. 34. 34
  35. 35. PostgreSQL → 9.1 9.1 SQL/MED SQL-DB SQL/MED PostgreSQL SQL/MED DB UP UP 35
  36. 36. PostgreSQL 9.0 36

×