Skip to content

Commit 75ecbab

Browse files
committed
2 parents b0122db + a4ca34c commit 75ecbab

File tree

15 files changed

+443
-238
lines changed

15 files changed

+443
-238
lines changed
Lines changed: 87 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,85 @@
11
---
2-
- hosts: nodes
2+
- hosts: nodes[1]:nodes[2]:nodes[3]
3+
# accelerate: true
4+
5+
pre_tasks:
6+
- name: setup the private key for postgrespro git access
7+
copy: dest=.ssh/ppg-deploy src=~/ppg-deploy.key mode=0600
38

49
roles:
510
- role: postgres
611
pg_port: 15432
7-
pg_repo: https://github.com/kelvich/postgresql.git
8-
pg_version_tag: xtm_patched
12+
pg_repo: git@gitlab.postgrespro.ru:pgpro-dev/postgrespro.git
13+
pg_version_tag: xtm
14+
pg_repo_key: ~/.ssh/ppg-deploy
915
pg_destroy_and_init: true
10-
pg_config_role:
11-
- line: "dtm.buffer_size = 65536"
16+
# pg_config_role:
17+
# - line: "dtm.buffer_size = 65536"
1218

1319
tasks:
14-
- name: clone dtm sources
15-
git: repo=https://github.com/postgrespro/pg_dtm.git
16-
dest={{pg_prefix}}/pg_dtm
17-
accept_hostkey=yes
18-
update=yes
19-
force=yes
20-
register: dtm_sources
20+
- name: generate connstrings
21+
set_fact:
22+
connstr: "replication=database host={{item}} user={{ansible_ssh_user}} port=15432 dbname=postgres sslmode=disable"
23+
with_items:
24+
groups['nodes'] | reverse | batch(nnodes | d(3) | int) | first
25+
register: connstrs
2126

22-
- name: build dtm
27+
- name: make a list
28+
set_fact:
29+
connections: "{{ connstrs.results | map(attribute='ansible_facts.connstr') | join(', ') }}"
30+
31+
- name: build multimaster
2332
shell: "make clean && make -j {{makejobs}} install"
2433
args:
25-
chdir: "{{pg_prefix}}/pg_dtm"
26-
environment:
27-
PG_CONFIG: "{{pg_dst}}/bin/pg_config"
28-
# when: dtm_sources.changed
34+
chdir: "{{pg_src}}/contrib/multimaster"
2935

3036
- name: enable dtm extension on datanodes
3137
lineinfile:
3238
dest: "{{pg_datadir}}/postgresql.conf"
3339
line: "{{item}}"
3440
state: present
3541
with_items:
36-
- "shared_preload_libraries = 'pg_dtm'"
37-
- "dtm.host = '{{ groups['nodes'][0] }}'"
42+
- "wal_level = logical"
43+
- "max_wal_senders = 10"
44+
- "wal_sender_timeout = 0"
45+
- "max_replication_slots = 10"
46+
- "max_worker_processes = 100"
47+
- "shared_preload_libraries = 'multimaster'"
48+
- "multimaster.arbiter_host = '{{ groups['nodes'][0] }}'"
49+
- "multimaster.conn_strings = '{{ connections }}'"
50+
- "multimaster.node_id = {{ node_id }}"
51+
- "multimaster.queue_size = 1073741824"
52+
- "multimaster.workers = 16"
3853

3954
- name: restart postgrespro
4055
command: "{{pg_dst}}/bin/pg_ctl restart -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"
4156
environment:
4257
LD_LIBRARY_PATH: "{{pg_dst}}/lib/"
4358

4459
- hosts: nodes[0]
60+
pre_tasks:
61+
- name: setup the private key for postgrespro git access
62+
copy: dest=.ssh/ppg-deploy src=~/ppg-deploy.key mode=0600
63+
64+
roles:
65+
- role: postgres
66+
pg_port: 15432
67+
pg_repo: git@gitlab.postgrespro.ru:pgpro-dev/postgrespro.git
68+
pg_version_tag: xtm
69+
pg_repo_key: ~/.ssh/ppg-deploy
70+
pg_destroy_and_init: true
71+
4572
tasks:
46-
- name: build dtmd
73+
- name: build sockhub
4774
shell: "make clean && make -j 4"
4875
args:
49-
chdir: "~/pg_cluster/pg_dtm/dtmd"
50-
# environment:
51-
# PG_CONFIG: "~/pg_cluster/install/bin/pg_config"
76+
chdir: "~/pg_cluster/src/contrib/multimaster/sockhub"
77+
78+
- name: build dtm
79+
shell: "make clean && make -j 4"
80+
args:
81+
chdir: "~/pg_cluster/src/contrib/multimaster/dtmd"
82+
# when: dtm_sources.changed
5283

5384
- name: kill dtmd
5485
shell: kill -9 `cat ~/pg_cluster/dtm_data/arbiter.pid` || true
@@ -58,9 +89,41 @@
5889

5990
- name: start dtm
6091
shell: >
61-
nohup ~/pg_cluster/pg_dtm/dtmd/bin/dtmd
92+
nohup ~/pg_cluster/src/contrib/multimaster/dtmd/bin/dtmd
6293
-d ~/pg_cluster/dtm_data -a 0.0.0.0 -p 5431 > ~/pg_cluster/dtm_data/log &
6394
6495
- name: wait until dtm is available
6596
wait_for: port=5431 delay=1
6697

98+
99+
- hosts: clients
100+
101+
tasks:
102+
- name: copy transfers source
103+
copy: src=../{{item}} dest=~/{{item}} mode=0755
104+
with_items:
105+
- "dtmbench.cpp"
106+
107+
- name: clone pqxx
108+
git: repo=https://github.com/Ambrosys/pqxx.git
109+
dest=~/pqxx
110+
accept_hostkey=yes
111+
update=no
112+
force=yes
113+
register: pqxx
114+
115+
- name: build pqxx
116+
shell: "./configure --prefix=/home/{{ansible_ssh_user}}/pg_cluster/install/ --enable-shared && make && make install"
117+
args:
118+
chdir: "~/pqxx"
119+
environment:
120+
PATH: "/home/{{ansible_ssh_user}}/pg_cluster/install/bin/:{{ansible_env.PATH}}"
121+
when: pqxx.changed
122+
123+
- name: compile dtmbench
124+
shell: "g++ -g -Wall -O2 -o dtmbench dtmbench.cpp -lpqxx -lpq -pthread -L/home/{{ansible_ssh_user}}/pg_cluster/install/lib/ -I/home/{{ansible_ssh_user}}/pg_cluster/install/include/"
125+
126+
- name: compile dtmbench
127+
shell: "mv dtmbench ~/pg_cluster/install/bin/dtmbench"
128+
129+
Lines changed: 87 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,85 @@
11
---
2-
- hosts: nodes
2+
- hosts: nodes[1]:nodes[2]:nodes[3]
3+
# accelerate: true
4+
5+
pre_tasks:
6+
- name: setup the private key for postgrespro git access
7+
copy: dest=.ssh/ppg-deploy src=~/ppg-deploy.key mode=0600
38

49
roles:
510
- role: postgres
611
pg_port: 15432
7-
pg_repo: https://github.com/kelvich/postgresql.git
8-
pg_version_tag: xtm_patched
12+
pg_repo: git@gitlab.postgrespro.ru:pgpro-dev/postgrespro.git
13+
pg_version_tag: xtm
14+
pg_repo_key: ~/.ssh/ppg-deploy
915
pg_destroy_and_init: true
10-
pg_config_role:
11-
- line: "dtm.buffer_size = 65536"
16+
# pg_config_role:
17+
# - line: "dtm.buffer_size = 65536"
1218

1319
tasks:
14-
- name: clone dtm sources
15-
git: repo=https://github.com/postgrespro/pg_dtm.git
16-
dest={{pg_prefix}}/pg_dtm
17-
accept_hostkey=yes
18-
update=yes
19-
force=yes
20-
register: dtm_sources
20+
- name: generate connstrings
21+
set_fact:
22+
connstr: "replication=database host={{item}} user={{ansible_ssh_user}} port=15432 dbname=postgres sslmode=disable"
23+
with_items:
24+
groups['nodes'] | reverse | batch(nnodes | d(3) | int) | first
25+
register: connstrs
2126

22-
- name: build dtm
27+
- name: make a list
28+
set_fact:
29+
connections: "{{ connstrs.results | map(attribute='ansible_facts.connstr') | join(', ') }}"
30+
31+
- name: build multimaster
2332
shell: "make clean && make -j {{makejobs}} install"
2433
args:
25-
chdir: "{{pg_prefix}}/pg_dtm"
26-
environment:
27-
PG_CONFIG: "{{pg_dst}}/bin/pg_config"
28-
# when: dtm_sources.changed
34+
chdir: "{{pg_src}}/contrib/multimaster"
2935

3036
- name: enable dtm extension on datanodes
3137
lineinfile:
3238
dest: "{{pg_datadir}}/postgresql.conf"
3339
line: "{{item}}"
3440
state: present
3541
with_items:
36-
- "shared_preload_libraries = 'pg_dtm'"
37-
- "dtm.host = '{{ groups['nodes'][0] }}'"
42+
- "wal_level = logical"
43+
- "max_wal_senders = 10"
44+
- "wal_sender_timeout = 0"
45+
- "max_replication_slots = 10"
46+
- "max_worker_processes = 100"
47+
- "shared_preload_libraries = 'multimaster'"
48+
- "multimaster.arbiter_host = '{{ groups['nodes'][0] }}'"
49+
- "multimaster.conn_strings = '{{ connections }}'"
50+
- "multimaster.node_id = {{ node_id }}"
51+
- "multimaster.queue_size = 1073741824"
52+
- "multimaster.workers = 16"
3853

3954
- name: restart postgrespro
4055
command: "{{pg_dst}}/bin/pg_ctl restart -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"
4156
environment:
4257
LD_LIBRARY_PATH: "{{pg_dst}}/lib/"
4358

4459
- hosts: nodes[0]
60+
pre_tasks:
61+
- name: setup the private key for postgrespro git access
62+
copy: dest=.ssh/ppg-deploy src=~/ppg-deploy.key mode=0600
63+
64+
roles:
65+
- role: postgres
66+
pg_port: 15432
67+
pg_repo: git@gitlab.postgrespro.ru:pgpro-dev/postgrespro.git
68+
pg_version_tag: xtm
69+
pg_repo_key: ~/.ssh/ppg-deploy
70+
pg_destroy_and_init: true
71+
4572
tasks:
46-
- name: build dtmd
73+
- name: build sockhub
4774
shell: "make clean && make -j 4"
4875
args:
49-
chdir: "~/pg_cluster/pg_dtm/dtmd"
50-
# environment:
51-
# PG_CONFIG: "~/pg_cluster/install/bin/pg_config"
76+
chdir: "~/pg_cluster/src/contrib/multimaster/sockhub"
77+
78+
- name: build dtm
79+
shell: "make clean && make -j 4"
80+
args:
81+
chdir: "~/pg_cluster/src/contrib/multimaster/dtmd"
82+
# when: dtm_sources.changed
5283

5384
- name: kill dtmd
5485
shell: kill -9 `cat ~/pg_cluster/dtm_data/arbiter.pid` || true
@@ -58,9 +89,41 @@
5889

5990
- name: start dtm
6091
shell: >
61-
nohup ~/pg_cluster/pg_dtm/dtmd/bin/dtmd
92+
nohup ~/pg_cluster/src/contrib/multimaster/dtmd/bin/dtmd
6293
-d ~/pg_cluster/dtm_data -a 0.0.0.0 -p 5431 > ~/pg_cluster/dtm_data/log &
6394
6495
- name: wait until dtm is available
6596
wait_for: port=5431 delay=1
6697

98+
99+
- hosts: clients
100+
101+
tasks:
102+
- name: copy transfers source
103+
copy: src=../{{item}} dest=~/{{item}} mode=0755
104+
with_items:
105+
- "dtmbench.cpp"
106+
107+
- name: clone pqxx
108+
git: repo=https://github.com/Ambrosys/pqxx.git
109+
dest=~/pqxx
110+
accept_hostkey=yes
111+
update=no
112+
force=yes
113+
register: pqxx
114+
115+
- name: build pqxx
116+
shell: "./configure --prefix=/home/{{ansible_ssh_user}}/pg_cluster/install/ --enable-shared && make && make install"
117+
args:
118+
chdir: "~/pqxx"
119+
environment:
120+
PATH: "/home/{{ansible_ssh_user}}/pg_cluster/install/bin/:{{ansible_env.PATH}}"
121+
when: pqxx.changed
122+
123+
- name: compile dtmbench
124+
shell: "g++ -g -Wall -O2 -o dtmbench dtmbench.cpp -lpqxx -lpq -pthread -L/home/{{ansible_ssh_user}}/pg_cluster/install/lib/ -I/home/{{ansible_ssh_user}}/pg_cluster/install/include/"
125+
126+
- name: compile dtmbench
127+
shell: "mv dtmbench ~/pg_cluster/install/bin/dtmbench"
128+
129+

contrib/multimaster/tests/deploy_layouts/roles/postgres/tasks/main.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
version={{pg_version_tag}}
4949
depth=1
5050
accept_hostkey=True
51+
key_file={{pg_repo_key}}
5152
register: pg_sources
5253
when: pg_copydist is undefined
5354

@@ -86,7 +87,7 @@
8687
# when: pg_pidfile.stat.exists
8788

8889
- name: stop postgres if it was running
89-
shell: "kill -9 `head -n 1 {{pg_datadir}}/postmaster.pid`"
90+
shell: "kill -9 `head -n 1 {{pg_datadir}}/postmaster.pid` || true"
9091
environment:
9192
LD_LIBRARY_PATH: "{{pg_dst}}/lib"
9293
when: pg_pidfile.stat.exists
@@ -119,7 +120,12 @@
119120
- name: enable blind trust on datanodes
120121
lineinfile:
121122
dest: "{{pg_datadir}}/pg_hba.conf"
122-
line: "host all all 0.0.0.0/0 trust"
123+
line: "{{item}}"
124+
state: present
125+
with_items:
126+
- "host all all 0.0.0.0/0 trust"
127+
- "host replication all 0.0.0.0/0 trust"
128+
- "local replication all trust"
123129

124130
- name: start postgrespro
125131
shell: "{{pg_dst}}/bin/pg_ctl start -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"

contrib/multimaster/tests/deploy_layouts/roles/postgres/vars/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
makejobs: 4
44

55
pg_repo: git://git.postgresql.org/git/postgresql.git
6+
pg_repo_key: None
67
pg_version_tag: master
78

89
pg_destroy_and_init: false

0 commit comments

Comments
 (0)