PostgreSQL High Availability Cookbook 2nd edition Edition Thomas instant download
PostgreSQL High Availability Cookbook 2nd edition Edition Thomas instant download
https://ebookfinal.com/download/postgresql-high-availability-
cookbook-2nd-edition-edition-thomas/
https://ebookfinal.com/download/blueprints-for-high-availability-2nd-
ed-edition-evan-marcus/
https://ebookfinal.com/download/postgresql-9-0-high-performance-
gregory-smith/
https://ebookfinal.com/download/network-infrastructure-and-
architecture-designing-high-availability-networks-1st-edition-
krzysztof-iniewski/
https://ebookfinal.com/download/architecting-for-scale-high-
availability-for-your-growing-applications-1st-edition-lee-atchison/
https://ebookfinal.com/download/mysql-high-availability-tools-for-
building-robust-data-centers-second-edition-charles-bell/
https://ebookfinal.com/download/learning-postgresql-10-2nd-edition-
salahaldin-juba/
https://ebookfinal.com/download/postgresql-replication-2nd-revised-
edition-edition-hans-jurgen-schonig/
https://ebookfinal.com/download/advertising-on-google-the-high-
performance-cookbook-1st-edition-kristina-cutura/
PostgreSQL High Availability Cookbook 2nd edition
Edition Thomas Digital Instant Download
Author(s): Thomas, Shaun M
ISBN(s): 9781787125674, 178712567X
Edition: 2nd edition
File Details: PDF, 4.14 MB
Year: 2017
Language: english
PostgreSQL High Availability
Cookbook
Second Edition
Shaun M. Thomas
BIRMINGHAM - MUMBAI
PostgreSQL High Availability Cookbook
Second Edition
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the
publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its
dealers and distributors will be held liable for any damages caused or alleged to be caused
directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
Did you know that Packt offers eBook versions of every book published, with PDF and
ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a
print book customer, you are entitled to a discount on the eBook copy. Get in touch with us
at service@packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a
range of free newsletters and receive exclusive discounts and offers on Packt books and
eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt
books and video courses, as well as industry-leading tools to help you plan your personal
development and advance your career.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Customer Feedback
Thank you for purchasing this Packt book. We take our commitment to improving our
content and products to meet your needs seriously - that's why your feedback is so
valuable. Whatever your feelings about your purchase, please consider leaving a review on
this book's Amazon page. Not only will this help us, more importantly it will also help
others in the community to make an informed decision about the resources that they invest
in to learn.
You can also review for us on a regular basis by joining our reviewers' club. If you're
interested in joining, or would like to learn more about the benefits we offer, please
contact us: customerreviews@packtpub.com.
Table of Contents
Preface 1
Chapter 1: Hardware Planning 9
Introduction 9
Planning for redundancy 10
Getting ready 10
How to do it… 11
How it works… 11
There's more… 12
See also 13
Having enough IOPS 13
Getting ready 13
How to do it… 14
How it works… 14
There's more… 15
A working example 16
Making concessions 16
Sizing storage 17
Getting ready 17
How to do it… 18
How it works… 19
There's more… 19
Real-world example 19
Adjusting the numbers 20
Incorporating the spreadsheet 21
Investing in a RAID 21
Getting ready 22
How to do it… 22
How it works… 23
There's more… 24
See also 24
Picking a processor 25
Getting ready 25
How to do it… 25
How it works… 27
There's more… 27
Hyperthreading 28
Turbo Boost 28
Power usage 28
See also 29
Making the most of memory 29
Getting ready 29
How to do it… 30
How it works… 30
There's more… 31
Exploring nimble networking 31
Getting ready 32
How to do it… 32
How it works… 34
There's more… 35
A networking example 35
Remembering redundancy 35
Saving the research 36
See also 36
Managing motherboards 36
Getting ready 37
How to do it… 37
How it works… 38
There's more… 39
See also 39
Selecting a chassis 40
Getting ready 40
How to do it… 40
How it works… 41
There's more… 42
Saddling up to a SAN 42
Getting ready 43
How to do it… 43
How it works… 44
There's more… 45
See also 45
Tallying up 46
Getting ready 46
How to do it… 46
How it works… 46
There's more… 47
[ ii ]
Protecting your eggs 48
Getting ready 48
How to do it… 48
How it works… 48
There's more… 49
Chapter 2: Handling and Avoiding Downtime 51
Introduction 51
Determining acceptable losses 52
Getting ready 53
How to do it… 53
How it works… 54
Configuration – getting it right the first time 54
Getting ready 55
How to do it… 55
How it works… 56
There's more… 59
See also 59
Configuration – managing scary settings 59
Getting ready 59
How to do it… 60
How it works… 60
There's more… 61
Distinct settings 62
More information 62
See also 62
Identifying important tables 63
Getting ready 63
How to do it… 64
How it works… 65
There's more… 66
Reset stats 66
Using pgstattuple 67
See also 67
Defusing cache poisoning 68
Getting ready 68
How to do it… 69
How it works… 70
See also 72
Exploring the magic of virtual IPs 72
[ iii ]
Getting ready 73
How to do it… 73
How it works… 74
There's more… 74
Terminating rogue connections 75
Getting ready 76
How to do it… 76
How it works… 77
There's more… 78
Reducing contention with concurrent indexes 79
Getting ready 79
How to do it… 80
How it works… 80
There's more… 80
No transactions 81
One at a time 81
Danger with OLTP use 81
See also 81
Managing system migrations 82
Getting ready 82
How to do it… 83
How it works… 84
There's more… 85
See also 85
Managing software upgrades 85
Getting ready 86
How to do it… 86
How it works… 88
There's more… 89
See also 89
Mitigating the impact of hardware failure 89
Getting ready 90
How to do it… 91
How it works… 92
There's more… 92
Copying WAL files more easily 93
Adding compression 93
Secondary delay 94
See also 94
Applying bonus kernel tweaks 94
[ iv ]
Getting ready 95
How to do it… 95
How it works… 96
There's more… 97
Chapter 3: Pooling Resources 99
Introduction 99
Determining connection costs and limits 101
Getting ready 101
How to do it… 102
How it works… 102
There's more… 103
Installing PgBouncer 103
Getting ready 104
How to do it… 104
How it works… 106
There's more… 106
See also 107
Configuring PgBouncer safely 107
Getting ready 107
How to do it… 108
How it works… 109
There's more… 110
What about pool_mode? 110
Problems with prepared statements 111
See also 111
Connecting to PgBouncer 111
Getting ready 112
How to do it… 112
How it works… 112
See also 112
Listing PgBouncer server connections 113
Getting ready 113
How to do it… 113
How it works… 113
There's more… 115
See also 115
Listing PgBouncer client connections 115
Getting ready 116
How to do it… 116
[v]
How it works… 116
There's more… 117
See also 118
Evaluating PgBouncer pool health 118
Getting ready 118
How to do it… 118
How it works… 119
There's more… 121
See also 121
Installing pgpool 122
Getting ready 122
How to do it… 122
How it works… 124
There's more… 125
See also 125
Configuring pgpool for master/slave mode 125
Getting ready 126
How to do it… 126
How it works… 128
There's more… 129
See also 129
Testing a write query on pgpool 130
Getting ready 130
How to do it… 130
How it works… 131
There's more… 132
Swapping active nodes with pgpool 132
Getting ready 133
How to do it… 133
How it works… 134
There's more… 135
See also 136
Combining the power of PgBouncer and pgpool 136
Getting ready 136
How to do it… 137
How it works… 137
There's more… 137
Chapter 4: Troubleshooting 138
Introduction 138
[ vi ]
Performing triage 139
Getting ready 139
How to do it… 140
How it works… 140
There's more… 142
Installing common statistics packages 142
How to do it… 143
How it works… 143
Evaluating the current disk performance with iostat 143
Getting ready 144
How to do it… 144
How it works… 144
There's more… 146
See also 146
Tracking I/O-heavy processes with iotop 146
Getting ready 147
How to do it… 147
How it works… 147
There's more… 148
See also 149
Viewing past performance with sar 149
Getting ready 149
How to do it… 149
How it works… 150
There's more… 151
See also 152
Correlating performance with dstat 152
Getting ready 152
How to do it… 152
How it works… 153
See also 155
Interpreting /proc/meminfo 155
Getting ready 156
How to do it… 156
How it works… 156
There's more… 158
See also 158
Examining /proc/net/bonding/bond0 159
Getting ready 159
[ vii ]
How to do it… 160
How it works… 160
See also 161
Checking the pg_stat_activity view 161
Getting ready 162
How to do it… 162
How it works… 163
There's more… 165
See also 166
Checking the pg_stat_statements view 166
Getting ready 166
How to do it… 167
How it works… 168
There's more… 169
Resetting the stats 169
Catching more queries 170
See also 170
Deciphering database locks 170
Getting ready 171
How to do it… 171
How it works… 172
There's more… 172
See also 174
Debugging with strace 174
Getting ready 174
How to do it… 174
How it works… 175
There's more… 177
See also 177
Logging checkpoints properly 177
Getting ready 178
How to do it… 179
How it works… 179
There's more… 181
See also 181
Chapter 5: Monitoring 182
Introduction 182
Figuring out what to monitor 183
Getting ready 183
[ viii ]
How to do it… 184
How it works… 184
There's more… 185
Installing and configuring Nagios 186
Getting ready 186
How to do it… 187
How it works… 188
There's more… 189
See also 189
Configuring Nagios to monitor a database host 190
Getting ready 190
How to do it… 190
How it works… 192
There's more… 193
See also 194
Enhancing Nagios with check_mk 194
Getting ready 194
How to do it… 195
How it works… 195
There's more… 197
See also 197
Getting to know check_postgres 197
Getting ready 198
How to do it… 198
How it works… 199
There's more… 200
See also 201
Installing and configuring collectd 201
Getting ready 201
How to do it… 202
How it works… 203
See also 205
Adding a custom PostgreSQL monitor to collectd 205
Getting ready 205
How to do it… 205
How it works… 206
There's more… 208
See also 209
Installing and configuring Graphite 209
[ ix ]
Getting ready 209
How to do it… 210
How it works… 211
See also 213
Adding collectd data to Graphite 214
Getting ready 214
How to do it… 214
How it works… 215
See also 217
Building a graph in Graphite 217
Getting ready 218
How to do it… 218
How it works… 219
There's more… 220
Customizing a Graphite graph 220
Getting ready 221
How to do it… 221
How it works… 221
Creating a Graphite dashboard 223
Getting ready 223
How to do it… 223
How it works… 224
There's more… 225
Chapter 6: Replication 226
Introduction 226
Deciding what to copy 227
Getting ready 227
How to do it… 227
How it works… 228
Securing the WAL stream 229
Getting ready 230
How to do it… 230
How it works… 231
There's more… 233
See also 233
Setting up a hot standby 233
Getting ready 234
How to do it… 234
How it works… 235
[x]
See also 238
Upgrading to asynchronous replication 238
Getting ready 238
How to do it… 238
How it works… 240
There's more… 241
Cascading replication 241
Using replication slots 241
Viewing replication status on a replica 242
See also 242
Bulletproofing with synchronous replication 243
Getting ready 243
How to do it… 243
How it works… 244
There's more… 245
Being less strict 245
Being more strict 246
Enabling extreme durability 247
See also 247
Faking replication with pg_receivexlog 248
Getting ready 248
How to do it… 248
How it works… 249
There's more… 250
See also 250
Setting up Slony 251
Getting ready 251
How to do it… 251
How it works… 253
See also 254
Copying a few tables with Slony 255
Getting ready 255
How to do it… 255
How it works… 257
There's more… 258
See also 258
Setting up Bucardo 259
Getting ready 259
How to do it… 259
How it works… 261
[ xi ]
See also 262
Copying a few tables with Bucardo 262
Getting ready 263
How to do it… 263
How it works… 264
See also 266
Setting up Londiste 266
Getting ready 266
How to do it… 267
How it works… 269
See also 270
Copying a few tables with Londiste 271
Getting ready 271
How to do it… 271
How it works… 272
See also 273
Setting up pglogical 273
Getting ready 273
How to do it… 274
How it works… 276
See also 276
Copying a few tables with pglogical 277
Getting ready 277
How to do it… 277
How it works… 278
There's more… 279
See also 280
Chapter 7: Replication Management Tools 281
Introduction 282
Deciding when to use third-party tools 283
Getting ready 283
How to do it… 283
How it works… 284
There's more… 285
Installing and configuring Barman 285
Getting ready 285
How to do it… 286
How it works… 287
There's more… 288
[ xii ]
Discovering Diverse Content Through
Random Scribd Documents
CHAPTER XII.
OSCAR TALKS TO THE COLONEL.
Dear Tom:
Here are the clothes you need. I am sorry I cannot see you again, for I should like
to ask you some questions in regard to a certain “affair” that happened last
summer; and in which you and Lish, the Wolfer, are supposed to have been
engaged. If you had anything to do with it, you will know what I mean, and you had
better dig out of here without the loss of a minute’s time. Go off somewhere among
white folks; begin all over again, with an earnest resolution to do better, and, as
soon as you are able, make amends for what you have done. But first drop Lish, as
you would drop a hot potato. You will never amount to a row of pins so long as you
have anything to do with him or men like him. I have as good evidence as I want
that he will rob you before the season is over, as Frank Fuller and Eben Webster
robbed Leon Parker. If you had no hand in that “affair,” whatever it may be, come
up to the fort as soon as you have read this note and put on these clothes, and I will
do everything in my power to give you a start. In either case drop Lish. It would be
better for you to work for nothing and board around, as you did in Denver, than to
associate longer with him.
H aving picketed his horse and placed his saddle and bridle under
the wagon with the others, Oscar joined the group about the
fire, who were preparing to dispose of a second supper before going
to bed—their long ride in the keen air having given them a most
ravenous appetite.
Oscar was as hungry as the rest, and never did he partake of
homely fare with more relish than he did that night. The black coffee
sweetened with brown sugar, and served up without milk, was equal
to any his mother had ever made; the fat bacon was better than most
beef, and the hardtack was to be preferred to pastry.
He ate his full share of the viands, and then rolled himself up in his
blankets, and, with his saddle for a pillow, slept the sleep of the
weary, until he was aroused by the voices of the teamsters, who, with
the help of the Indian, had kept watch of the horses during the night.
A dash of cold water in his face, and a hasty breakfast, prepared
him for the hunt, the details of which were arranged while the horses
were being brought up.
“Now, Oscar,” said the colonel, as he sprang into the saddle and
led the way toward a plateau that lay about two miles distant from
the camp, “stay as close to me as you can, and if we don’t secure a
specimen of something before another meal is served up to us, it will
not be our fault. What do you intend to do with that rifle, I’d like to
know?”
“Why, I am going to shoot a prong-horn with it if I get the chance,”
answered Oscar.
“Take it back to camp, and tell the teamsters to take care of it until
you return,” said the colonel. “It will only be in your way. Your
revolver and lasso are what you must depend on this morning.”
Oscar hastened to obey, and, when he reached the camp, he found
that the colonel had not brought his hounds along. As soon as he
came up with the officer again he asked why he had not done so.
“We want to see some sport while our horses are fresh,” was the
reply, “and the best way to get it is to run the game down ourselves. A
dash of three or four miles will take all the breath out of them, and
then we’ll give the hounds a chance. This afternoon we will try still-
hunting, which has gone almost out of style, except among the
Indians and a few white pot-hunters, and then you can use your
rifle.”
During the ride to the plateau the colonel improved the
opportunity to give Oscar some instructions in regard to the manner
in which antelope were hunted, and the course he must pursue to
make the hunt successful.
He showed him how to throw the lasso, and, although the boy tried
hard to imitate him, he did it simply out of politeness, and not
because he believed that he would ever be able to capture anything
with that novel weapon.
He could throw the lasso with all ease as far as its length would
permit, and sometimes the noose would go, and sometimes it
wouldn’t. He was not very expert with the revolver either, and often
wished he had held fast to his rifle.
When the hunting party mounted the hills that led to the plateau,
Oscar obtained his first view of a prong-horn.
He was disappointed, as almost everybody is who sees for the first
time something he has often read or heard about. He knew that the
antelope seldom exceeds three feet in height at the shoulders, and
that it rarely weighs more than sixty or seventy pounds; but still he
did not expect to find it so diminutive a creature.
There were several small herds grazing quietly within range of his
vision, and but for their color they might have been taken for so
many sheep.
Having carefully marked the position of the different herds, the
hunters drew silently back down the ridge, and following in the lead
of the colonel made a detour of a mile or more, in order to reach
some hillocks on the leeward side of the game, under cover of which
they could approach some hundreds of yards nearer to the spot on
which they were grazing.
On reaching this place of concealment, they dismounted for a few
minutes to tighten their saddle-girths, arrange their lassoes and look
to their revolvers; and, when everything was ready for the exciting
chase that was to follow, they rode out on the plateau and showed
themselves to the antelope.
The actions of the animals, who were thus disturbed at their quiet
repast by the sudden appearance of enemies whose presence they
had never suspected, astonished Oscar.
Instead of setting off in full flight at once, as he had expected they
would, they one and all made a few “buck-jumps”—that is, sprang
straight up and down in the air; and then, running together in a
group, stood and stared at the intruders.
But when the colonel, with a wild Indian yell and a wave of his hat,
dashed toward them at the top of his speed, they scattered like leaves
before a storm, and made off at their best pace.
Oscar followed close at the colonel’s heels, the gallant little black
on which he was mounted easily keeping pace with the officer’s more
bulky horse; and presently he saw a full-grown doe, with a couple of
fawns at her side, break away from the others and direct her course
across the plateau toward the lower prairie that lay beyond.
“There’s your chance, Preston!” shouted the colonel. “Shoot the
doe and lasso the youngsters. You’ll never find finer specimens if you
hunt until your hair is as white as mine. Go it, now, and don’t forget
that the louder you yell the more fun you’ll have!”
The hubbub that arose behind him made Oscar believe that the
other members of the party must be of the same opinion.
The chorus of whoops and howls that rent the air when the game
was seen in full flight was almost enough to raise a doubt in his mind
as to whether his hunting companions were friendly white men or
hostile Indians.
Oscar shoots the Prong-horn.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookfinal.com