Slony Postgresql "Replication

Fehlerquellen

node löschen (wäre das selbe wie  drop schema "_T2" cascade  auf masterhost und slavehost:

slonik <<_EOF_ 2>> /db/slony_setup.log 1>> /db/slony_setup.log
        cluster name = T2;
        node 1 admin conninfo = 'dbname=databasex host=masterhost.de port=5432 user=slony password=xxxx';
        node 2 admin conninfo = 'dbname=databasex host=slavehost.de port=5432 user=slony password=xxxx';
        try {
        uninstall node (id = 1);
    }
    on error {
        echo 'Could not uninstall Slony-I on node 1';
        exit -1;
    }
        try {
        uninstall node (id = 2);
    }
    on error {
        echo 'Could not uninstall Slony-I on node 2';
        exit -1;
    }
        echo 'Slony-I successfully uninstalled on database databasex';
_EOF_

anschließend Datenbank erstellen und Struktur clonden mittels createdb und pg_dump -s(für schema only) databasex | psql ...

Nächster Schritt Node initialisieren:

slonik <<_EOF_ 2>> /db/slony_setup.log 1>> /db/slony_setup.log
        cluster name = T2;
        node 1 admin conninfo = 'dbname=databasex host=masterhost.de port=5432 user=slony password=xxxx';
        node 2 admin conninfo = 'dbname=databasex host=slavehost.de port=5432 user=slony password=xxxx';
        try { # schema auf dem master server zu erstellen
        echo 'Initializing the cluster';
        init cluster (id = 1, comment = 'Node 1');
    }
    on error {
        echo 'Could not initialize the cluster!';
        exit -1;
    }
    echo 'Database cluster initialized as Node 1';
    try { # schema auf dem slave server zu erstellen
        echo 'Storing node 2';
        store node (id = 2, comment = 'Node 2');
    }
    on error {
        echo 'Could not create Node 2!';
        exit -1;
    }
    echo 'Node 2 created';
    try {
        echo 'Creating store paths';
                store path (server = 1, client = 2, conninfo = 'dbname=databasex host=slavehost.de port=5432 user=slony password=');
                store path (server = 2, client = 1, conninfo = 'dbname=databasex host=masterhost.de port=5432 user=slony password=');
        }
    on error {
        echo 'Could not create store paths!';
        exit -1;
    }
    echo 'Store paths created';
    try {
        echo 'Storing listen network';
                store listen (origin = 1, provider = 1, receiver = 2);
                store listen (origin = 2, provider = 2, receiver = 1);
        }
    on error {
        echo 'Could not store listen network!';
        exit -1;
    }
    echo 'listen network stored';
    try {
        create set (id = 1, origin = 1, comment = 'databasex tables');
    }
    on error {
        echo 'Could not create subscription set!';
        exit -1;
    }
    echo 'Subscription set created';
    # anschließend tabellen hinzufügen

Zu guter letzt noch einmal slonik ausführen um die Hauptdaten mittels COPY auf den Slave zu transferieren.

slonik <<_EOF_ 2>> /db/slony_setup.log 1>> /db/slony_setup.log
        cluster name = T2;
        node 1 admin conninfo = 'dbname=databasex host=masterhost.de port=5432 user=slony password=xxxx';
        node 2 admin conninfo = 'dbname=databasex host=slavehost.de port=5432 user=slony password=xxxx';

        try {
                subscribe set (id = 1, provider = 1, receiver = 2, forward = no);
        }
    on error {
        echo 'Could not subscribe the set to the slaves';
        exit -1;
    }
    echo 'Database databasex subscribed to slaves';
_EOF_

MarkusRechberger/slony (zuletzt geändert am 2007-12-23 22:47:16 durch localhost)