1. Trang chủ
  2. » Công Nghệ Thông Tin

administration

109 14 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

Mastering PostgreSQL Administration BRUCE MOMJIAN POSTGRESQL is an open-source, full-featured relational database This presentation covers advanced administration topics Creative Commons Attribution License http://momjian.us/presentations Last updated: September, 2015 / 109 Outline Installation Configuration Maintenance Monitoring Recovery / 109 Installation ◮ Click-Through Installers ◮ ◮ ◮ ◮ Ports ◮ ◮ ◮ ◮ ◮ MS Windows Linux OS X RPM DEB PKG other packages Source ◮ ◮ ◮ obtaining build options installing / 109 Initialization (initdb) $ initdb The files belonging to this database system will be owned by user "postgres" This user must also own the server process The database cluster will be initialized with locale en_US.UTF-8 The default database encoding has accordingly been set to UTF8 The default text search configuration will be set to "english" fixing permissions on existing directory /u/pgsql/data ok creating subdirectories ok selecting default max_connections 100 selecting default shared_buffers 32MB creating configuration files ok creating template1 database in /u/pgsql/data/base/1 ok initializing pg_authid ok initializing dependencies ok creating system views ok loading system objects’ descriptions ok creating collations ok creating conversions ok creating dictionaries ok setting privileges on built-in objects ok creating information schema ok loading PL/pgSQL server-side language ok vacuuming database template1 ok copying template1 to template0 ok copying template1 to postgres ok / 109 Initialization (continued) WARNING: enabling "trust" authentication for local connections You can change this by editing pg_hba.conf or using the -A option the next time you run initdb Success You can now start the database server using: /u/pgsql/bin/postgres -D /u/pgsql/data or /u/pgsql/bin/pg_ctl -D /u/pgsql/data -l logfile start / 109 pg_controldata $ pg_controldata pg_control version number: Catalog version number: Database system identifier: Database cluster state: pg_control last modified: Latest checkpoint location: Prior checkpoint location: Latest checkpoint’s REDO location: Latest checkpoint’s TimeLineID: Latest checkpoint’s NextXID: Latest checkpoint’s NextOID: Latest checkpoint’s NextMultiXactId: Latest checkpoint’s NextMultiOffset: Latest checkpoint’s oldestXID: Latest checkpoint’s oldestXID’s DB: Latest checkpoint’s oldestActiveXID: Time of latest checkpoint: Minimum recovery ending location: Backup start location: Current wal_level setting: Current max_connections setting: Current max_prepared_xacts setting: Current max_locks_per_xact setting: Maximum data alignment: Database block size: Blocks per segment of large relation: WAL block size: Bytes per WAL segment: Maximum length of identifiers: Maximum columns in an index: Maximum size of a TOAST chunk: Date/time type storage: Float4 argument passing: 903 201105231 5701206621592472575 in production Tue 24 Jan 2012 09:33:32 AM EST 0/16BD258 0/16BD1D0 0/16BD258 0/679 24576 668 Tue 24 Jan 2012 09:33:32 AM EST 0/0 0/0 minimal 100 64 8192 131072 8192 16777216 64 32 1996 64-bit integers by value / 109 System Architecture Main Libpq Postmaster Postgres Postgres Parse Statement Traffic Cop Query utility Utility Command e.g CREATE TABLE, COPY SELECT, INSERT, UPDATE, DELETE Rewrite Query Generate Paths Optimal Path Generate Plan Plan Execute Plan Utilities Access Methods Catalog Storage Managers Nodes / Lists / 109 Starting Postmaster LOG: LOG: LOG: database system was shut down at 2012-01-24 09:33:29 EST database system is ready to accept connections autovacuum launcher started ◮ manually ◮ pg_ctl start ◮ on boot / 109 Stopping Postmaster LOG: LOG: LOG: LOG: received smart shutdown request autovacuum launcher shutting down shutting down database system is shut down ◮ manually ◮ pg_ctl stop ◮ on shutdown / 109 Connections ◮ local — unix domain socket ◮ host — TCP/IP, both SSL or non-SSL ◮ hostssl — only ◮ hostnossl — never SSL SSL 10 / 109 Client Application Crash Nothing Required Transactions in progress are rolled back 95 / 109 Graceful Postgres Server Shutdown Nothing Required Transactions in progress are rolled back 96 / 109 Abrupt Postgres Server Crash Nothing Required Transactions in progress are rolled back 97 / 109 Operating System Crash Nothing Required Transactions in progress are rolled back Partial page writes are repaired 98 / 109 Disk Failure Restore from previous backup or use PITR 99 / 109 Accidental DELETE Recover table from previous backup, perhaps using pg_restore It is possible to modify the backend code to make deleted tuples visible, dump out the deleted table and restore the original code All tuples in the table since the previous vacuum will be visible It is possible to restrict that so only tuples deleted by a specific transaction are visible 100 / 109 Write-Ahead Log (WAL) Corruption See pg_resetxlog Review recent transactions and identify any damage, including partially committed transactions 101 / 109 File Deletion It may be necessary to create an empty file with the deleted file name so the object can be deleted, and then the object restored from backup 102 / 109 Accidental DROP TABLE Restore from previous backup 103 / 109 Accidental DROP INDEX Recreate index 104 / 109 Accidental DROP DATABASE Restore from previous backup 105 / 109 Non-Starting Installation Restart problems are usually caused by write-ahead log problems See pg_resetxlog Review recent transactions and identify any damage, including partially committed transactions 106 / 109 Index Corruption Use REINDEX 107 / 109 Table Corruption Try reindexing the table Try identifying the corrupt OID of the row and transfer the valid rows into another table using SELECT…INTO…WHERE oid != ### Use http://sources redhat.com/rhdb/tools.html to analyze the internal structure of the table 108 / 109 Conclusion http://momjian.us/presentations 109 / 109

Ngày đăng: 27/04/2016, 17:24

Xem thêm

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w