Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mkdir -p /var/lib/pgsql/rsbd2
- initdb /var/lib/pgsql/rsbd2
- pg_ctl -D /var/lib/pgsql/rsbd2 -l logfile start
- ---
- create server rsbd1 foreign data wrapper postgres_fdw options (host 'localhost', port '5432', dbname 'postgres');
- create user mapping for postgres server rsbd1 options (user 'postgres')
- import foreign schema public limit to (pracownicy) from server rsbd1 into public;
- ---
- select adres from zespoly where id_zesp=10;
- adres
- ------------
- PIOTROWO 1
- (1 row)
- select placa_pod from pracownicy where id_prac=100;
- placa_pod
- -----------
- 999.00
- (1 row)
- ===============
- =3==Transakcje=
- ===============
- 1) -> terminal 1 odpowiedizalny za baze 1
- 2) -> terminal 2 odpowiedizalny za baze 2
- 3) -> terminal pomocniczy
- -------------------
- 1) begin;
- 1) update pracownicy set placa_pod=777 where id_prac=100;
- 2) begin;
- 2) update zespoly set adres='PIOTROWO 88' where id_zesp=10;
- 1) PREPARE TRANSACTION 'distributed-transaction02-rsbd1';
- 2) PREPARE TRANSACTION 'distributed-transaction02-rsbd2';
- 3) pg_ctl -D /var/lib/pgsql/rsbd2 stop
- 3) pg_ctl -D /var/lib/pgsql/rsbd1 stop
- 3) pg_ctl -D /var/lib/pgsql/rsbd1 start
- 3) pg_ctl -D /var/lib/pgsql/rsbd2 start
- 1) select * from pg_prepared_xacts;
- transaction | gid | prepared | owner | database
- -------------+-------+-------------------------------+----------+----------
- 1778 | 02-01 | 2019-10-10 10:07:49.471017-04 | postgres | postgres
- (1 row)2) select * from pg_prepared_xacts;
- transaction | gid | prepared | owner | database
- -------------+-------+-------------------------------+----------+----------
- 1769 | 02-02 | 2019-10-10 10:07:59.102974-04 | postgres | postgres
- (1 row)
- ==================
- =4==Zakleszczenie=
- ==================
- 1) begin;
- 1) select placa_pod from pracownicy where id_prac=100 for update nowait;
- 1) update pracownicy set placa_pod=placa_pod+10 where id_prac=100;
- 2) begin;
- 2) select adres from zespoly where id_zesp=10 for update nowait;
- 2) update zespoly set adres='PIOTROWO 88' where id_zesp=10;
- 1) select adres from zespoly where id_zesp=10 for update nowait;
- 1) update zespoly set adres='PIOTROWO 77' where id_zesp=10;
- 2) select placa_pod from pracownicy where id_prac=100 for update nowait;
- 2) update pracownicy set placa_pod=placa_pod+10 where id_prac=100 for update nowait;
- ============
- =5==Repliki=
- ============
- 1) select * from zespoly_replika;
- wady ? po kazdej aktualizacji trzeba odsiwezyc zawartosc materializowanych perpspektyw
- curl https://install.citusdata.com/community/rpm.sh | sudo bash
- sudo yum install -y pg_cron_11
- 81,0-1 Bot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement