Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Admins

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 06:00 AM
Pierre LEBRECH
 
Posts: n/a
Default Slony1 or DRBD for replication ?

Hello,

I want to replicate my PostgreSQL database at an other location. The
distance between the two locations should be around 10 miles. The link
should be a fast ethernet dedicated link.

What would you suggest me to do? DRBD or slony1 for PostgreSQL replication?

Thank you.

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 06:00 AM
Shoaib Mir
 
Posts: n/a
Default Re: Slony1 or DRBD for replication ?

SLONY should be the choice

On 4/14/06, Pierre LEBRECH <pierre.lebrech@laposte.net> wrote:
>
> Hello,
>
> I want to replicate my PostgreSQL database at an other location. The
> distance between the two locations should be around 10 miles. The link
> should be a fast ethernet dedicated link.
>
> What would you suggest me to do? DRBD or slony1 for PostgreSQL
> replication?
>
> Thank you.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 06:00 AM
Joshua D. Drake
 
Posts: n/a
Default Re: Slony1 or DRBD for replication ?

On Fri, 2006-04-14 at 14:56 +0200, Pierre LEBRECH wrote:
> Hello,
>
> I want to replicate my PostgreSQL database at an other location. The
> distance between the two locations should be around 10 miles. The link
> should be a fast ethernet dedicated link.
>
> What would you suggest me to do? DRBD or slony1 for PostgreSQL replication?


It depends on your needs.

If you want to be able to use the slave postgresql instance (reporting,
non replicated name spaces, materialized views etc...) Slony or Mammoth
Replicator.

If you want to also replicate users/groups, grant and revoke, Mammoth
Replicator.

If you just want a hot backup... DRBD.

Joshua D. Drake


>
> Thank you.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>

--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/





---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 06:00 AM
Pierre LEBRECH
 
Posts: n/a
Default Re: Slony1 or DRBD for replication ?

Joshua D. Drake wrote:
> On Fri, 2006-04-14 at 14:56 +0200, Pierre LEBRECH wrote:
>
>>Hello,
>>
>>I want to replicate my PostgreSQL database at an other location. The
>>distance between the two locations should be around 10 miles. The link
>>should be a fast ethernet dedicated link.
>>
>>What would you suggest me to do? DRBD or slony1 for PostgreSQL replication?

>
>
> It depends on your needs.
>
> If you want to be able to use the slave postgresql instance (reporting,
> non replicated name spaces, materialized views etc...) Slony or Mammoth
> Replicator.
>
> If you want to also replicate users/groups, grant and revoke, Mammoth
> Replicator.
>
> If you just want a hot backup... DRBD.
>
> Joshua D. Drake
>


The second location should be used in case of emergency. So, if my first
machine/system becomes unreachable for whatever reason, I want to be
able to switch very quickly to the other machine. Of course, the goal is
to have no loss of data. That is the context.

Furthermore, I have experience with DRBD (not on databases) and I do not
know if DRBD would be the best way to solve this replication problem.

Thanks for any suggestions and explanations.

PS : my database is actualy in production in a critical environment

>
>
>>Thank you.
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 9: In versions below 8.0, the planner will ignore your desire to
>> choose an index scan if your joining column's datatypes do not
>> match
>>



---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-10-2008, 06:00 AM
Christopher Browne
 
Posts: n/a
Default Re: Slony1 or DRBD for replication ?

In the last exciting episode, pierre.lebrech@laposte.net (Pierre LEBRECH) wrote:
> Thanks for any suggestions and explanations.


A third possibility would be PITR, new in version 8, if the point is
to have recovery from big failure. You'd periodically copy the whole
DB, and continually copy WAL files across the wire...

See the PG docs; there's a whole chapter on it...
--
output = ("cbbrowne" "@" "gmail.com")
http://linuxdatabases.info/info/spreadsheets.html
"It can be shown that for any nutty theory, beyond-the-fringe
political view or strange religion there exists a proponent on the
Net. The proof is left as an exercise for your kill-file."
-- Bertil Jonell
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-10-2008, 06:02 AM
Jim C. Nasby
 
Posts: n/a
Default Re: Slony1 or DRBD for replication ?

On Fri, Apr 14, 2006 at 07:42:29PM +0200, Pierre LEBRECH wrote:
> The second location should be used in case of emergency. So, if my first
> machine/system becomes unreachable for whatever reason, I want to be
> able to switch very quickly to the other machine. Of course, the goal is
> to have no loss of data. That is the context.
>
> Furthermore, I have experience with DRBD (not on databases) and I do not
> know if DRBD would be the best way to solve this replication problem.
>
> Thanks for any suggestions and explanations.
>
> PS : my database is actualy in production in a critical environment


I believe that Continuent currently has the only no-loss (ie:
syncronous) replication solution. DRBD might allow for this as well, if
it can be setup to not return from fsync until the data's been
replicated.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-10-2008, 06:02 AM
Benjamin Krajmalnik
 
Posts: n/a
Default Howto: Using PITR recovery for standby replication

I am running PostgreSQL 8.1.3 on Windows.

The project itself is a real time data acquisition system, so it cannot be taken off-line for backups.

I have tried using pg_dump, but discovered that the backup was not a consistent backup. The application currently inserts about 1 million rows per day (will ramp to about 5 million when in full production). All of the insertion of the data is controlledby a master stored procedure which inserts rows into a raw log, and dynamically aggregates data into anclliary tables which enable us to see statistical data of the systems being monitored withut having to mine the raw data.

The original prototype of this system was running onder MS SQL Server 2000, but once PostgreSQL 8.1 was released I decided to port it. The biggest challenge which I have right now is to ensure that we can have data recovery in case of a catastrophic failure in the primary system - with the ability to load a "cold spare".

Back to the problem I faced when testing backups with pg_dump, it appears that the backup was not a consistent backup of the data. For example, sequences which are used by some tables bo longer held the correct values (the tables now held higher values), and ths would indicate to me that the backup of an aggregate table may not match the underlying raw data which created it.

As such, my only option is to create a "hot backup" using PITR. I would like to know if the following scenario would work:

A secondary server with the same version of PostgreSQL is loaded on a secondary server. The PostgreSQL service on the second box would not be running. I would issue a pg_start_backup. I would then copy the the database directory to the second box. Issue a pg_stop_backup. I would delete the WAL logs form the secondary box's pg_xlog. I wuld then copy the archived WAL's as well as the current WAL to the secondary pg_xlog location.

In could then backup the snapshot from the secondatry box to a lesser media for archival purposes, and in the event of a problem, I would simply start the service on he secondary box.

Is this a workable solution? Or, better yet, could th secondary be ive and, after the initial backup and restore from the main box, could replication be acomplished by somehow moving the new archived logs to the secondary box, thereby creating a timed replication (forexample, every hour we cold create anothe backup ad just move the WAL file oer, since the state of the secondary database shoud reflect the state of the previous bacukp)?

While I absolutely love PotgreSQL, and together with some of the add-ons (pgAdmin, pgAgent, the add-ons from EMS) there is alost nothing missing, the relative difficulty of backing up / restoring vis-a-vis the commercial solutions is frustrating. Not hat it is a PostgreQL problem, but rather a learning curve, but until I get this working atisfactorily I am a bit worried.

As always, any insight and assistance ill be deeply appreciated.



Regards,

Benjamin






Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-10-2008, 06:02 AM
Tom Lane
 
Posts: n/a
Default Re: Howto: Using PITR recovery for standby replication

"Benjamin Krajmalnik" <kraj@illumen.com> writes:
> I have tried using pg_dump, but discovered that the backup was not a =
> consistent backup.


Really?

> Back to the problem I faced when testing backups with pg_dump, it =
> appears that the backup was not a consistent backup of the data. For =
> example, sequences which are used by some tables bo longer held the =
> correct values (the tables now held higher values),


Sequences are non-transactional, so pg_dump might well capture a higher
value of the sequence counter than is reflected in any table row, but
there are numerous other ways by which a gap can appear in the set of
sequence values. That's not a bug. If you've got real discrepancies
in pg_dump's output, a lot of us would like to know about 'em.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-10-2008, 06:02 AM
Benjamin Krajmalnik
 
Posts: n/a
Default Re: Howto: Using PITR recovery for standby replication

Tom,

First of all forgive me if I am totally incorrect - I may very well be If so, believe me I will be a very happy camper since my concerns will be void. My concern was raised when I backed up the server which was receiving production data, and I restored it in a developmen server. The difference between both of them is tht the production server has a very high row insertion rate, while the development server has about 10 rows per minute inserted (just to enable us to check tht our real time aggregation code and graphical display routines are working properly).

After restoring, when we fired up the service responsible for record insertion, I began receiving the constraint violations on the columns controlled by the sequences. The table had higher values in them than the sequences. This raised a huge red flag for me. My concern was that the aggreegated data tables may not reflect the data in the raw inserted tables - essentially, that they may be out of sync.

The particular table which was problematic (and for which I posted another message due to the unique constraint violation which I am seeing intermittently) is the one with the high insertion rate. The sequence is currently being used to facilitate purginf of old records. However, as I study and play more with PostgreSQL, I found the ability to partition a table. Once I move to table partitioning, my problem of ourgin data past retention periods will be fixed.

My entire conecpt may have been incorrect and is based with my experiences with MS SQL Server whereby when I purged records based on the date, due to the large amounts of data huge transaction logs were created, and in some cases ended up using so much diskspace that the database imploded! The workaroound which I created under SQL Server was to assign an identity field to each row, select the minimum value for the day to be purged, and then purge records 10,000 at a time within transactions. This kept the transaction file small and the database from exploding dye to running out of disk space.

It is very possible that this may not have been an issue with PostgreSQL, but I could not take a chance, so I ported the methodology over. The new architecture will have a table partition for each month (12 partitions). Once the retention period of the given partition expires it will simply be truncated.

Sorry for the rambling, but, if I understand correctly from you, the only items which were out of synch were the sequences, but all of the tables would have maintained consistency relative to each other? If so, once I get rid of the unnecessary sequences, I can create a small function to be run after a restore which can reset the sequences to the proper value. That would be simple enough, and would provide an easily implemented solution.

You'll probably see me in here asking lots of questins as I cut my teeth on PostgreSQL. Hopefully, at some point in the future I will be able to contribute back with solutions

Once again, thank you. Also, did you receive the snippet of the stored procedure which I sent you? As I mentioned, the only place where row insertion is performed is via that stored procedure, and the sequences were created by defining the columns as "bigserial", which still has me puzzled as to why I am experiencing the contraing violation on the unique primary key.

Regards,

Benjamin

________________________________

From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Thu 4/20/2006 9:09 PM
To: Benjamin Krajmalnik
Cc: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Howto: Using PITR recovery for standby replication



"Benjamin Krajmalnik" <kraj@illumen.com> writes:
> I have tried using pg_dump, but discovered that the backup was not a =
> consistent backup.


Really?

> Back to the problem I faced when testing backups with pg_dump, it =
> appears that the backup was not a consistent backup of the data. For =
> example, sequences which are used by some tables bo longer held the =
> correct values (the tables now held higher values),


Sequences are non-transactional, so pg_dump might well capture a higher
value of the sequence counter than is reflected in any table row, but
there are numerous other ways by which a gap can appear in the set of
sequence values. That's not a bug. If you've got real discrepancies
in pg_dump's output, a lot of us would like to know about 'em.

regards, tom lane



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-10-2008, 06:02 AM
Alvaro Herrera
 
Posts: n/a
Default Re: Howto: Using PITR recovery for standby replication

Benjamin Krajmalnik wrote:

> The particular table which was problematic (and for which I posted
> another message due to the unique constraint violation which I am
> seeing intermittently) is the one with the high insertion rate. The
> sequence is currently being used to facilitate purginf of old records.


How are you creating the dumps of the sequence and the table? If you do
both separately (as in two pg_dump invocations with a -t switch each),
that could explain your problem. This shouldn't really happen however,
because the sequence dump should be emitted in a dump of the table, if
the field is really of SERIAL or BIGSERIAL type. However I don't see
any other way which would make the sequence go out of sync.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:25 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554