test (test text); =# INSERT INTO test VALUES (‘ςετσʔλ'); =# SELECT * FROM test; =# INSERT INTO test VALUES (‘ςετσʔλ’); ERROR: cannot execute INSERT in a read-only transaction
ΧϯϚ۠Γ (ྫ: ’ελϯόΠ1’, ‘ελϯόΠ2’, ‘ελϯόΠ3’, ‘ελϯόΠ4’) ఆٛͨ͠શͯͷελϯόΠΛಉظͱͯ͠ѻ͍·͢ɻ • FIRST N (ྫ: FIRST 2 ’ελϯόΠ1’, ‘ελϯόΠ2’, ‘ελϯόΠ3’, ‘ελϯόΠ4’) લ͔ΒNͷελϯόΠΛಉظͱͯ͠ѻ͍·͢ɻ • ANY N (ྫ: ANY 2 ’ελϯόΠ1’, ‘ελϯόΠ2’, ‘ελϯόΠ3’, ‘ελϯόΠ4’) ͍ͣΕ͔NͷελϯόΠΛಉظͱͯ͠ѻ͍·͢ɻ
• ϓϥΠϚϦʔ • ελϯόΠ LOG: standby “<ελϯόΠ໊>” is now a synchronous standby with priority 1 LOG: started streaming WAL from primary at <WALҐஔ> on timeline <λΠϜϥΠϯ>
• ϓϥΠϚϦʔ • ελϯόΠ LOG: standby “<ελϯόΠ໊>” is now a synchronous standby with priority 1 LOG: started streaming WAL from primary at <WALҐஔ> on timeline <λΠϜϥΠϯ> λΠϜϥΠϯIDɺϑΣΠϧΦʔόʔ όοΫΞοϓ͔Β෮چͰ൪߸͕ΓସΘΔʂ
2. ύϒϦογϟʔଆͷσʔλϕʔεͷpg_hba.confɺ্هϢʔβʔͷଓઃఆͷՃ Λߦ͍·͢ɻ =# CREATE ROLE repl_user LOGIN REPLICATION PASSWORD ‘...'; =# ALTER DEFAULT PRIVILEGES FOR ROLE <DBॴ༗Ϣʔβʔ> GRANT ALL PRIVILEGES ON TABLES TO repl_user; host replication repl_user <ελϯόΠଆIPΞυϨε>/<αϒωοτϚεΫ> md5
TABLESΛࢦఆ͢Δͱɺকདྷ࡞͞ΕΔςʔϒϧϨϓϦέʔ γϣϯରͱͳΓ·͢ɻ =# CREATE TABLE test (id integer, name text, primary key (id)); =# CREATE PUBLICATION test FOR TABLE test WITH(publish = ‘insert, update, delete, truncate’); -- ύϒϦέʔγϣϯ໊Λtestͱͯ͠࡞
چϓϥΠϚϦʔ͕ελϯόΠʹͳ͍ͬͯΔ͔ɺσʔλΛՃͯ֬͠ೝ ͯ͠Έ·͢ɻ =# SELECT * FROM test; test --------------- ςετσʔλ ςετσʔλ2 =# INSERT INTO test VALUES (‘ςετσʔλ’); ERROR: cannot execute INSERT in a read-only transaction σʔλ͕࿈ܞ͞Ε͍ͯΔ
INTO test VALUES (10, 'test1'); =# INSERT INTO test VALUES (10, ‘test2'); ERROR: duplicate key value violates unique constraint "test_pk" DETAIL: Key (id)=(10) already exists.