万本电子书0元读

万本电子书0元读

顶部广告

PostgreSQL Administration Cookbook, 9.5/9.6 Edition电子书

售       价:¥

4人正在读 | 0人评论 9.8

作       者:Simon Riggs

出  版  社:Packt Publishing

出版时间:2017-04-27

字       数:73.3万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Over 150 recipes to help you administer your PostgreSQL database more efficiently About This Book ?Get to grips with the capabilities of PostgreSQL 9.6 to administer your database more efficiently ?Monitor, tune, secure and protect your database ?A step-by-step, recipe-based guide to help you tackle any problem in PostgreSQL administration with ease Who This Book Is For This book is for system administrators, database administrators, data architects, developers, and anyone with an interest in planning for, or running, live production databases. This book is most suited to those who have some technical experience. What You Will Learn ?Implement PostgreSQL features for performance and reliability ?Harness the power of the latest PostgreSQL 9.6 features ?Manage open source PostgreSQL versions 9.5 and 9.6 on various platforms ?Discover advanced technical tips for experienced users ?Explore best practices for planning and designing live databases ?Select and implement robust backup and recovery techniques ?Explore concise and clear guidance on replication and high availability ?See the latest details on Logical Replication and Bi-Directional Replication In Detail PostgreSQL is a powerful opensource database management system; now recognized as the expert's choice for a wide range of applications, it has an enviable reputation for performance and stability. PostgreSQL provides an integrated feature set comprising relational database features, object-relational, text search, Geographical Info Systems, analytical tools for big data and
目录展开

Title Page

Copyright

Credits

About the Authors

About the Reviewer

www.PacktPub.com

Customer Feedback

Preface

What this book covers

What you need for this book

Who this book is for

Sections

Getting ready

How to do it…

How it works…

There's more…

See also

Conventions

Reader feedback

Customer support

Downloading the example code

Downloading the color images of this book

Errata

Piracy

Questions

First Steps

Introduction

Introducing PostgreSQL 9.6

What makes PostgreSQL different?

Robustness

Security

Ease of use

Extensibility

Performance and concurrency

Scalability

SQL and NoSQL

Popularity

Commercial support

Research and development funding

Getting PostgreSQL

How to do it...

How it works...

There's more...

Connecting to the PostgreSQL server

Getting ready

How to do it...

How it works...

There's more...

See also

Enabling access for network/remote users

How to do it...

How it works...

There's more...

See also

Using graphical administration tools

How to do it...

How it works...

See also

Using the psql query and scripting tool

Getting ready

How to do it...

How it works...

There's more...

See also

Changing your password securely

How to do it...

How it works...

Avoiding hardcoding your password

Getting ready

How to do it...

How it works...

There's more...

Using a connection service file

How to do it...

How it works...

Troubleshooting a failed connection

How to do it...

There's more...

Exploring the Database

Introduction

What version is the server?

How to do it...

How it works...

There's more...

What is the server uptime?

How to do it...

How it works...

See also

Locating the database server files

Getting ready

How to do it...

How it works...

There's more...

Locating the database server's message log

Getting ready

How to do it...

How it works...

There's more...

Locating the database's system identifier

Getting ready

How to do it...

How it works...

Listing databases on this database server

How to do it...

How it works...

There's more...

How many tables are there in a database?

How to do it...

How it works...

There's more...

How much disk space does a database use?

How to do it...

How it works...

How much disk space does a table use?

How to do it...

How it works...

There's more...

Which are my biggest tables?

How to do it...

How it works...

How many rows are there in a table?

How to do it...

How it works...

Quickly estimating the number of rows in a table

How to do it...

How it works...

There's more...

Function 1 - estimating the number of rows

Function 2 - computing the size of a table without locks

Listing extensions in this database

Getting ready

How to do it...

How it works...

There's more...

Understanding object dependencies

Getting ready

How to do it...

How it works...

There's more...

Configuration

Introduction

Reading the fine manual

How to do it...

How it works...

There's more...

Planning a new database

Getting ready

How to do it...

How it works...

There's more...

Changing parameters in your programs

How to do it...

How it works...

There's more...

Finding the current configuration settings

How to do it...

There's more...

How it works...

Which parameters are at non-default settings?

How to do it...

How it works...

There's more...

Updating the parameter file

Getting ready

How to do it...

How it works...

There's more...

Setting parameters for particular groups of users

How to do it...

How it works...

The basic server configuration checklist

Getting ready

How to do it...

There's more...

Adding an external module to PostgreSQL

Getting ready

How to do it...

How it works...

Using an installed module

Getting ready

How to do it...

How it works...

Managing installed extensions

How it works...

There's more...

Server Control

Introduction

Starting the database server manually

Getting ready

How to do it...

How it works...

Stopping the server safely and quickly

How to do it...

How it works...

See also

Stopping the server in an emergency

How to do it...

How it works...

Reloading the server configuration files

How to do it...

How it works...

There's more...

Restarting the server quickly

How to do it...

There's more...

Preventing new connections

How to do it...

How it works...

Restricting users to only one session each

How to do it...

How it works...

Pushing users off the system

How to do it...

How it works...

Deciding on a design for multitenancy

How to do it...

How it works...

Using multiple schemas

Getting ready

How to do it...

How it works...

Giving users their own private database

Getting ready

How to do it...

How it works...

There's more...

See also

Running multiple servers on one system

Getting ready

How to do it...

How it works...

Setting up a connection pool

Getting ready

How to do it...

How it works...

There's more...

Accessing multiple servers using the same host and port

Getting ready

How to do it...

There's more...

Tables and Data

Introduction

Choosing good names for database objects

Getting ready

How to do it...

There's more...

Handling objects with quoted names

Getting ready

How to do it...

How it works...

There's more...

Enforcing the same name and definition for columns

Getting ready

How to do it...

How it works...

There's more...

Identifying and removing duplicates

Getting ready

How to do it...

How it works...

There's more...

Preventing duplicate rows

Getting ready

How to do it...

How it works...

There's more...

Duplicate indexes

Uniqueness without indexes

Real-world example - IP address range allocation

Real-world example - range of time

Real-world example - prefix ranges

Finding a unique key for a set of data

Getting ready

How to do it...

How it works...

Generating test data

How to do it...

How it works...

There's more...

See also

Randomly sampling data

How to do it...

How it works...

Loading data from a spreadsheet

Getting ready

How to do it...

How it works...

There's more...

Loading data from flat files

Getting ready

How to do it...

How it works...

There's more...

Security

Introduction

Typical user role

The PostgreSQL superuser

How to do it...

How it works...

There's more...

Other superuser-like attributes

Attributes are never inherited

See also

Revoking user access to a table

Getting ready

How to do it...

How it works...

There's more...

Database creation scripts

Default search path

Securing views

Granting user access to a table

Getting ready

How to do it...

How it works...

There's more...

Access to the schema

Granting access to a table through a group role

Granting access to all objects in a schema

Granting user access to specific columns

Getting ready

How to do it...

How it works...

There's more...

Granting user access to specific rows

Getting ready

How to do it...

How it works...

There's more...

Creating a new user

Getting ready

How to do it...

How it works...

There's more...

Temporarily preventing a user from connecting

Getting ready

How to do it...

How it works...

There's more...

Limiting the number of concurrent connections by a user

Forcing NOLOGIN users to disconnect

Removing a user without dropping their data

Getting ready

How to do it...

How it works...

Checking whether all users have a secure password

How to do it...

How it works...

Giving limited superuser powers to specific users

Getting ready

How to do it...

How it works...

There's more...

Writing a debugging_info function for developers

Auditing DDL changes

Getting ready

How to do it...

How it works...

There's more...

Was the change committed?

Who made the change?

Can I find this information from the database?

You may still miss some DDL...

Auditing data changes

Getting ready

How to do it...

Collecting data changes from the server log

Collecting changes using triggers

Collecting changes using triggers and saving them in another database

Always knowing which user is logged in

Getting ready

How to do it...

How it works...

There's more...

Not inheriting user attributes

Integrating with LDAP

Getting ready

How to do it...

How it works...

There's more...

Setting up the client to use LDAP

Replacement for the User Name Map feature

See also

Connecting using SSL

Getting ready

How to do it...

How it works...

There's more...

Getting the SSL key and certificate

Setting up a client to use SSL

Checking server authenticity

Using SSL certificates to authenticate

Getting ready

How to do it...

How it works...

There's more...

Avoiding duplicate SSL connection attempts

Using multiple client certificates

Using the client certificate to select the database user

See also

Mapping external usernames to database roles

Getting ready

How to do it...

How it works...

There's more...

Encrypting sensitive data

Getting ready

How to do it...

How it works...

There's more...

For really sensitive data

For really, really, really sensitive data!

See also

Database Administration

Introduction

Writing a script that either succeeds entirely or fails entirely

How to do it...

How it works...

There's more...

Writing a psql script that exits on the first error

Getting ready

How to do it...

How it works...

There's more...

Investigating a psql error

Getting ready

How to do it

There's more...

Performing actions on many tables

Getting ready

How to do it...

How it works...

There's more...

Adding/removing columns on a table

How to do it...

How it works...

There's more...

Changing the data type of a column

Getting ready

How to do it...

How it works...

There's more...

Changing the definition of a data type

Getting ready

How to do it...

How it works...

There's more...

Adding/removing schemas

How to do it...

There's more...

Using schema-level privileges

Moving objects between schemas

How to do it...

How it works...

There's more...

Adding/removing tablespaces

Getting ready

How to do it...

How it works...

There's more...

Putting pg_xlog on a separate device

Tablespace-level tuning

Moving objects between tablespaces

Getting ready

How to do it...

How it works...

There's more...

Accessing objects in other PostgreSQL databases

Getting ready

How to do it...

How it works...

There's more...

There's more...

Accessing objects in other foreign databases

Getting ready

How to do it...

How it works...

There's more...

Updatable views

Getting ready

How to do it...

How it works...

There's more...

Using materialized views

Getting ready

How to do it...

How it works...

There's more...

Monitoring and Diagnosis

Introduction

Providing PostgreSQL information to monitoring tools

Finding more information about generic monitoring tools

Real-time viewing using pgAdmin

Checking whether a user is connected

Getting ready

How to do it...

How it works...

There's more...

What if I want to know whether a computer is connected?

What if I want to repeatedly execute a query in psql?

Checking which queries are running

Getting ready

How to do it...

How it works...

There's more...

Catching queries that only run for a few milliseconds

Watching the longest queries

Watching queries from ps

See also

Checking which queries are active or blocked

Getting ready

How to do it...

How it works...

There's more...

No need for the = true part

Do we catch all queries waiting on locks?

Knowing who is blocking a query

Getting ready

How to do it...

How it works...

Killing a specific session

How to do it...

How it works...

There's more...

Try to cancel the query first

What if the backend won't terminate?

Using statement_timeout to clean up queries that take too long to run

Killing idle in transaction queries

Killing the backend from the command line

Detecting an in-doubt prepared transaction

How to do it...

Knowing whether anybody is using a specific table

Getting ready

How to do it...

How it works...

There's more...

The quick-and-dirty way

Collecting daily usage statistics

Knowing when a table was last used

Getting ready

How to do it...

How it works...

There's more...

Usage of disk space by temporary data

Getting ready

How to do it...

How it works...

There's more...

Finding out whether a temporary file is in use any more

Logging temporary file usage

Understanding why queries slow down

Getting ready

How to do it...

How it works...

There's more...

Do the queries return significantly more data than they did earlier?

Do the queries also run slowly when they are run alone?

Is the second run of the same query also slow?

Table and index bloat

See also

Investigating and reporting a bug

Getting ready

How to do it...

How it works...

Producing a daily summary of log file errors

Getting ready

How to do it...

How it works...

There's more...

See also

Analyzing the real-time performance of your queries

Getting ready

How to do it...

How it works...

There's more...

Regular Maintenance

Introduction

Controlling automatic database maintenance

Getting ready

How to do it...

How it works...

There's more...

See also

Avoiding auto-freezing and page corruptions

How to do it...

Removing issues that cause bloat

Getting ready

How to do it...

How it works...

There's more...

Removing old prepared transactions

Getting ready

How to do it...

How it works...

There's more...

Actions for heavy users of temporary tables

How to do it...

How it works...

Identifying and fixing bloated tables and indexes

How to do it...

How it works...

There's more...

Monitoring and tuning vacuum

Getting ready

How to do it...

How it works...

There's more...

Maintaining indexes

Getting ready

How to do it...

How it works...

There's more...

Adding a constraint without checking existing rows

Getting ready

How to do it...

How it works...

Finding unused indexes

How to do it...

How it works...

Carefully removing unwanted indexes

Getting ready

How to do it...

How it works...

Planning maintenance

How to do it...

How it works...

Performance and Concurrency

Introduction

Finding slow SQL statements

Getting ready

How to do it...

How it works...

There's more...

Collecting regular statistics from pg_stat* views

Getting ready

How to do it...

How it works...

There's more...

Another statistics collection package

Finding out what makes SQL slow

Getting ready

How to do it...

There's more...

Not enough CPU power or disk I/O capacity for the current load

Locking problems

EXPLAIN options

See also

Reducing the number of rows returned

How to do it...

There's more...

See also

Simplifying complex SQL queries

Getting ready

How to do it...

There's more...

Using materialized views (long-living, temporary tables)

Using set-returning functions for some parts of queries

Speeding up queries without rewriting them

How to do it...

Increasing work_mem

More ideas with indexes

There's more...

Using a TABLESAMPLE view

In case of many updates, set fillfactor on the table

Rewriting the schema - a more radical approach

Discovering why a query is not using an index

Getting ready

How to do it...

How it works...

There's more...

Forcing a query to use an index

Getting ready

How to do it...

There's more...

Using parallel query

How to do it...

How it works...

There's more...

Using optimistic locking

How to do it...

How it works...

There's more...

Reporting performance problems

How to do it...

There's more...

Backup and Recovery

Introduction

Understanding and controlling crash recovery

How to do it...

How it works...

There's more...

Planning backups

How to do it...

Hot logical backups of one database

How to do it...

How it works...

There's more...

See also

Hot logical backups of all databases

How to do it...

How it works...

See also

Backups of database object definitions

How to do it...

There's more...

Standalone hot physical database backup

How to do it...

How it works...

There's more...

See also

Hot physical backup and continuous archiving

Getting ready

How to do it...

How it works...

Recovery of all databases

Getting ready

How to do it...

Logical - from custom dump taken with pg_dump -F c

Logical - from the script dump created by pg_dump -F p

Logical - from the script dump created by pg_dumpall

Physical

How it works...

There's more...

See also

Recovery to a point in time

Getting ready

How to do it...

How it works...

There's more...

See also

Recovery of a dropped/damaged table

How to do it...

Logical - from custom dump taken with pg_dump -F c

Logical - from the script dump

Physical

How it works...

See also

Recovery of a dropped/damaged database

How to do it...

Logical - from the custom dump -F c

Logical - from the script dump created by pg_dump

Logical - from the script dump created by pg_dumpall

Physical

Improving performance of backup/recovery

Getting ready

How to do it...

How it works...

There's more...

See also

Incremental/differential backup and restore

How to do it...

How it works...

There's more...

Hot physical backups with Barman

Getting ready

How to do it...

How it works...

There's more...

Recovery with Barman

Getting ready

How to do it...

How it works...

There's more...

Replication and Upgrades

Introduction

Replication concepts

Topics

Basic concepts

History and scope

Practical aspects

Data loss

Single-master replication

Multinode architectures

Clustered or massively parallel databases

Multimaster replication

Scalability tools

Other approaches to replication

Replication best practices

How to do it...

There's more...

Setting up file-based replication - deprecated

Getting ready

How to do it...

How it works...

There's more...

See also

Setting up streaming replication

Getting ready

How to do it...

How it works...

There's more...

Setting up streaming replication security

Getting ready

How to do it...

How it works...

There's more...

Hot Standby and read scalability

Getting ready

How to do it...

How it works...

Managing streaming replication

Getting ready

How to do it...

There's more...

See also

Using repmgr

Getting ready

How to do it...

How it works...

There's more...

Using replication slots

Getting ready

How to do it...

There's more...

See also

Monitoring replication

Getting ready

How to do it...

There's more...

Performance and synchronous replication

Getting ready

How to do it...

How it works...

There's more...

Delaying, pausing, and synchronizing replication

Getting ready

How to do it...

There's more...

See also

Logical replication

Getting ready

How to do it...

How it works...

There's more...

Bi-directional replication

Getting ready

How to do it...

How it works...

There's more...

Archiving transaction log data

Getting ready

How to do it...

There's more...

See also

Upgrading - minor releases

Getting ready

How to do it...

How it works...

Major upgrades in-place

Getting ready

How to do it...

How it works...

Major upgrades online

How to do it...

How it works...

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部