Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Bruce - Postgres Replication
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<p>This document describes how to add a table to an existing <a href="http://bruce.codehaus.org/">Bruce</a> replication cluster<sup>1</sup>. An familiarity with administering <a href="http://www.postgresql.org/">PostgreSQL</a> is presumed of the reader.</p> <h4>The simple case: A brand new table</h4> <ul> <li>Create the table on the master database, using psql and 'create table' statements, including indexes, constraints, primary key, etc.</li> <li>Create the table on all the slaves. One way to do this is<sup>2</sup>:</li> </ul> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> pg_dump -n <table schema name> -t <table name> <master database> | psql -a <slave database> </pre></td></tr></table> <ul> <li>Create slave triggers on all slaves:</li> </ul> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> psql <slave database> create trigger <table name>_deny BEFORE INSERT OR DELETE OR UPDATE ON <fully qualified table name> FOR EACH ROW EXECUTE PROCEDURE bruce.denyaccesstrigger(); \q </pre></td></tr></table> <ul> <li>Create master triggers:</li> </ul> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> psql <master database> create trigger <table name>_sn BEFORE INSERT OR DELETE OR UPDATE ON <fully qualified table name> FOR EACH STATEMENT EXECUTE PROCEDURE bruce.logsnapshottrigger(); create trigger <table name>_tx AFTER INSERT OR DELETE OR UPDATE ON <fully qualified tables name> FOR EACH ROW EXECUTE PROCEDURE bruce.logtransactiontrigger(); \q </pre></td></tr></table> <ul> <li>Table is now being replicated, no daemon restart is necessary.</li> </ul> <h4>The not so simple case: An already populated table</h4> <ul> <li>Lock the cluster.</li> </ul> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> psql <master database> begin work; lock table bruce.currentlog in access exclusive mode; --- Keep this transaction open for now </pre></td></tr></table> <ul> <li>In another window: create table on all slaves, including table data:</li> </ul> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> pg_dump -h <master host> -n <table schema name> -t <table name> <master database name> | psql -h <slave hostname> <slave database name> </pre></td></tr></table> <ul> <li>Create slave triggers on all slaves:</li> </ul> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> psql <slave database> create trigger <table name>_deny BEFORE INSERT OR DELETE OR UPDATE ON <fully qualified table name> FOR EACH ROW EXECUTE PROCEDURE bruce.denyaccesstrigger(); \q </pre></td></tr></table> <ul> <li>Back to the open transaction on the master, create master triggers:</li> </ul> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> create trigger <table name>_sn BEFORE INSERT OR DELETE OR UPDATE ON <fully qualified table name> FOR EACH STATEMENT EXECUTE PROCEDURE bruce.logsnapshottrigger(); create trigger <table name>_tx AFTER INSERT OR DELETE OR UPDATE ON <fully qualified tables name> FOR EACH ROW EXECUTE PROCEDURE bruce.logtransactiontrigger(); </pre></td></tr></table> <ul> <li>Close transaction:</li> </ul> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> commit; \q </pre></td></tr></table> <ul> <li>Table is being replicated. No daemon restart is nessasary</li> </ul> <h5>Footnotes</h5> <p><sup>1</sup>. For now. In a future version of <a href="http://bruce.codehaus.org/">Bruce</a>, a method will be provided to ease this process.<br /> <sup>2</sup>. Replace text within <> with appropriate values.</p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced