Skip to content

Commit b507fd2

Browse files
committed
prepare for merge
1 parent 5ac02f8 commit b507fd2

34 files changed

+396
-21
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/deploy/cluster.yml renamed to contrib/pg_tsdtm/tests/deploy.dima/cluster.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
- hosts: nodes
44
# gather_facts: no
5-
# pre_tasks:
6-
# - name: make a list
7-
# set_fact:
8-
# ansible_os_family: "Debian"
95

106
roles:
117
- role: postgres
@@ -18,21 +14,6 @@
1814
- line: "dtm.vacuum_delay=1000"
1915

2016
tasks:
21-
# - name: clone dtm sources
22-
# git: repo=https://github.com/postgrespro/pg_tsdtm.git
23-
# dest={{pg_prefix}}/pg_tsdtm
24-
# accept_hostkey=yes
25-
# update=yes
26-
# force=yes
27-
# register: dtm_sources
28-
29-
# - name: build dtm
30-
# shell: "make clean && make -j {{makejobs}} install"
31-
# args:
32-
# chdir: "{{pg_prefix}}/pg_tsdtm"
33-
# environment:
34-
# PG_CONFIG: "{{pg_dst}}/bin/pg_config"
35-
# when: dtm_sources.changed
3617

3718
- name: enable dtm extension on datanodes
3819
lineinfile:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[nodes]
2+
127.0.0.1 ansible_ssh_port=2222 ansible_ssh_user=vagrant ansible_ssh_private_key_file=/Users/stas/vm/debian6/.vagrant/machines/default/virtualbox/private_key
3+
4+
[clients]
5+
127.0.0.1 ansible_ssh_port=2222 ansible_ssh_user=vagrant ansible_ssh_private_key_file=/Users/stas/vm/debian6/.vagrant/machines/default/virtualbox/private_key
File renamed without changes.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
- hosts: tag_Name_dtmtest
3+
user: ec2-user
4+
5+
roles:
6+
7+
- role: postgres
8+
pg_port: 15432
9+
pg_repo: https://github.com/kelvich/postgresql.git
10+
pg_version_tag: xtm_patched
11+
pg_destroy_and_init: true
12+
pg_config_role:
13+
- line: "dtm.buffer_size = 65536"
14+
15+
tasks:
16+
- name: collect private ips
17+
set_fact:
18+
pip: "{{ ec2_private_ip_address }}"
19+
20+
- name: set dtm ip
21+
set_fact:
22+
dtm_ip: "{{ hostvars[groups['tag_Name_dtmtest'][0]].pip }}"
23+
24+
- name: clone dtm sources
25+
git: repo=https://github.com/postgrespro/pg_dtm.git
26+
dest={{pg_prefix}}/pg_dtm
27+
accept_hostkey=yes
28+
update=yes
29+
force=yes
30+
register: dtm_sources
31+
32+
- name: build dtm
33+
shell: "make clean && make -j {{makejobs}} install"
34+
args:
35+
chdir: "{{pg_prefix}}/pg_dtm"
36+
environment:
37+
PG_CONFIG: "{{pg_dst}}/bin/pg_config"
38+
when: dtm_sources.changed
39+
40+
- name: enable dtm extension on datanodes
41+
lineinfile:
42+
dest: "{{pg_datadir}}/postgresql.conf"
43+
line: "{{item}}"
44+
state: present
45+
with_items:
46+
- "shared_preload_libraries = 'pg_dtm'"
47+
- "dtm.host = '{{ dtm_ip }}'"
48+
49+
- name: restart postgrespro
50+
command: "{{pg_dst}}/bin/pg_ctl restart -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"
51+
environment:
52+
LD_LIBRARY_PATH: "{{pg_dst}}/lib/"
53+
54+
- hosts: tag_Name_dtmtest[0]
55+
user: ec2-user
56+
tasks:
57+
- name: build dtmd
58+
shell: "make clean && make -j 4"
59+
args:
60+
chdir: "~/pg_cluster/pg_dtm/dtmd"
61+
# environment:
62+
# PG_CONFIG: "~/pg_cluster/install/bin/pg_config"
63+
64+
- name: kill dtmd
65+
shell: kill -9 `cat ~/pg_cluster/dtm_data/arbiter.pid` || true
66+
67+
- name: ensure datadir for dtm exists
68+
shell: "rm -rf ~/pg_cluster/dtm_data && mkdir ~/pg_cluster/dtm_data"
69+
70+
- name: start dtm
71+
shell: >
72+
nohup ~/pg_cluster/pg_dtm/dtmd/bin/dtmd
73+
-d ~/pg_cluster/dtm_data -a 0.0.0.0 -p 5431 > ~/pg_cluster/dtm_data/log &
74+
75+
- name: wait until dtm is available
76+
wait_for: port=5431 delay=1
77+
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
- hosts: nodes
3+
4+
pre_tasks:
5+
- name: setup the private key for postgrespro git access
6+
copy: dest=.ssh/ppg-deploy src=~/ppg-deploy.key mode=0600
7+
8+
roles:
9+
- role: postgres
10+
pg_port: 15432
11+
pg_repo: git@gitlab.postgrespro.ru:pgpro-dev/postgrespro.git
12+
pg_version_tag: xtm
13+
pg_destroy_and_init: true
14+
pg_repo_key: ~/.ssh/ppg-deploy
15+
16+
tasks:
17+
- name: clone dtm sources
18+
git: repo=https://github.com/postgrespro/pg_tsdtm.git
19+
dest={{pg_prefix}}/pg_dtm
20+
accept_hostkey=yes
21+
update=yes
22+
force=yes
23+
register: dtm_sources
24+
25+
- name: build dtm
26+
shell: "make clean && make -j {{makejobs}} install"
27+
args:
28+
chdir: "{{pg_prefix}}/pg_dtm"
29+
environment:
30+
PG_CONFIG: "{{pg_dst}}/bin/pg_config"
31+
when: dtm_sources.changed
32+
33+
- name: enable dtm extension on datanodes
34+
lineinfile:
35+
dest: "{{pg_datadir}}/postgresql.conf"
36+
line: "{{item}}"
37+
state: present
38+
with_items:
39+
- "shared_preload_libraries = 'pg_dtm'"
40+
41+
- name: restart postgrespro
42+
command: "{{pg_dst}}/bin/pg_ctl restart -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"
43+
environment:
44+
LD_LIBRARY_PATH: "{{pg_dst}}/lib/"
45+
46+
- hosts: clients
47+
tasks:
48+
49+
- name: copy transfers source
50+
copy: src=../{{item}} dest=~/{{item}} mode=0755
51+
with_items:
52+
- "dtmbench.cpp"
53+
54+
- name: clone pqxx
55+
git: repo=https://github.com/Ambrosys/pqxx.git
56+
dest=~/pqxx
57+
accept_hostkey=yes
58+
update=no
59+
force=yes
60+
register: pqxx
61+
62+
- name: build pqxx
63+
shell: "./configure --prefix=/home/{{ansible_ssh_user}}/pg_cluster/install/ --enable-shared && make -j4 && make install"
64+
args:
65+
chdir: "~/pqxx"
66+
environment:
67+
PATH: "/home/{{ansible_ssh_user}}/pg_cluster/install/bin/:{{ansible_env.PATH}}"
68+
# when: pqxx.changed
69+
70+
- name: compile dtmbench
71+
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/"
72+
73+
- name: move dtmbench to bin
74+
shell: "mv dtmbench ~/pg_cluster/install/bin/dtmbench"
75+
76+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
3+
- hosts: nodes[0]
4+
roles:
5+
- role: postgrespro
6+
deploy_dtm: true
7+
8+
- hosts: nodes, !master
9+
roles:
10+
- role: postgrespro
11+
pg_src: ./postgrespro_pgshard
12+
pg_version: xtm_pgshard
13+
pg_port: 25432
14+
deploy_postgres: true
15+
pg_dtm_enable: true
16+
pg_dtm_host: "{{ groups['nodes'][0] }}"
17+
18+
- hosts: master
19+
roles:
20+
- role: postgrespro
21+
pg_src: ./postgrespro_pgshard
22+
pg_version: xtm_pgshard
23+
pg_port: 25432
24+
deploy_postgres: true
25+
pg_dtm_enable: true
26+
pg_dtm_host: "{{ groups['nodes'][0] }}"
27+
deploy_pg_shard: true
28+
29+
# - hosts: clients
30+
# roles:
31+
# - role: postgrespro
32+

contrib/pg_tsdtm/tests/deploy/ec2.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
3+
- hosts: localhost
4+
connection: local
5+
gather_facts: False
6+
7+
tasks:
8+
9+
- name: Provision a set of instances
10+
ec2:
11+
key_name: macmini
12+
group: launch-wizard-2
13+
# instance_type: t2.micro
14+
instance_type: c3.2xlarge
15+
image: ami-60b6c60a
16+
wait: true
17+
region: us-east-1
18+
exact_count: 10
19+
count_tag:
20+
Name: dtmtest
21+
instance_tags:
22+
Name: dtmtest
23+
register: ec2
24+
25+
- name: Add all instance public IPs to host group
26+
add_host: hostname={{ item.public_ip }} groups=ec2hosts
27+
with_items: ec2.instances
28+
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
3+
- name: ensure dependencies (Debian)
4+
apt: pkg={{item}} state=installed
5+
with_items:
6+
- git
7+
- automake
8+
- libtool
9+
- build-essential
10+
- bison
11+
- flex
12+
- libreadline-dev
13+
when: ansible_os_family == "Debian"
14+
sudo: yes
15+
16+
- name: ensure dependencies (RedHat)
17+
yum: name="@Development tools" state=present
18+
when: (pg_copydist is undefined) and ansible_os_family == "RedHat"
19+
sudo: yes
20+
21+
- name: ensure dependencies (RedHat)
22+
yum: name={{item}} state=installed
23+
with_items:
24+
- git
25+
- automake
26+
- libtool
27+
- bison
28+
- flex
29+
- readline-devel
30+
when: (pg_copydist is undefined) and ansible_os_family == "RedHat"
31+
sudo: yes
32+
33+
- name: increase semaphores
34+
shell: sysctl kernel.sem='1000 128000 128 512'
35+
sudo: yes
36+
37+
- name: increase open files
38+
shell: "echo '{{ansible_ssh_user}} soft nofile 65535' > /etc/security/limits.d/cluster.conf"
39+
args:
40+
creates: "/etc/security/limits.d/cluster.conf"
41+
sudo: yes
42+
43+
#############################################################################
44+
45+
- name: clone postgres sources
46+
git: repo={{pg_repo}}
47+
dest={{pg_src}}
48+
version={{pg_version_tag}}
49+
depth=1
50+
accept_hostkey=True
51+
key_file={{pg_repo_key}}
52+
register: pg_sources
53+
when: pg_copydist is undefined
54+
55+
- name: force rebuild on changed sources
56+
command: "rm -f {{pg_dst}}/bin/postgres"
57+
when: (pg_copydist is undefined) and pg_sources.changed
58+
59+
- name: build and install
60+
shell: ./configure --prefix={{pg_dst}} --without-zlib && make clean && make -j {{makejobs}} && make install
61+
args:
62+
chdir: "{{pg_src}}"
63+
creates: "{{pg_dst}}/bin/postgres"
64+
when: pg_copydist is undefined
65+
66+
#############################################################################
67+
68+
- name: copy pg source
69+
copy: src=./{{item}} dest=~/{{item}} mode=0755
70+
with_items:
71+
- "pg_cluster_install.tgz"
72+
when: pg_copydist is defined
73+
74+
- name: extract postgres
75+
command: "tar xzf pg_cluster_install.tgz"
76+
when: pg_copydist is defined
77+
78+
#############################################################################
79+
80+
- stat: path={{pg_datadir}}/postmaster.pid
81+
register: pg_pidfile
82+
83+
# - name: stop postgres if it was running
84+
# command: "{{pg_dst}}/bin/pg_ctl stop -w -D {{pg_datadir}}"
85+
# environment:
86+
# LD_LIBRARY_PATH: "{{pg_dst}}/lib"
87+
# when: pg_pidfile.stat.exists
88+
89+
- name: stop postgres if it was running
90+
shell: "kill -9 `head -n 1 {{pg_datadir}}/postmaster.pid`"
91+
environment:
92+
LD_LIBRARY_PATH: "{{pg_dst}}/lib"
93+
when: pg_pidfile.stat.exists
94+
95+
- name: remove datadirs on datanodes
96+
command: "rm -rf {{pg_datadir}}"
97+
when: pg_destroy_and_init
98+
99+
- name: create datadirs on datanodes
100+
command: "{{pg_dst}}/bin/initdb {{pg_datadir}}"
101+
environment:
102+
LD_LIBRARY_PATH: "{{pg_dst}}/lib/"
103+
args:
104+
creates: "{{pg_datadir}}"
105+
106+
- name: configure postgres on datanodes
107+
lineinfile:
108+
dest: "{{pg_datadir}}/postgresql.conf"
109+
line: "{{item.line}}"
110+
state: present
111+
with_items: "{{pg_config}}"
112+
113+
- name: configure postgres on datanodes -- 2
114+
lineinfile:
115+
dest: "{{pg_datadir}}/postgresql.conf"
116+
line: "{{item.line}}"
117+
state: present
118+
with_items: "{{pg_config_role}}"
119+
120+
- name: enable blind trust on datanodes
121+
lineinfile:
122+
dest: "{{pg_datadir}}/pg_hba.conf"
123+
line: "host all all 0.0.0.0/0 trust"
124+
125+
- name: start postgrespro
126+
shell: "{{pg_dst}}/bin/pg_ctl start -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"
127+
environment:
128+
LD_LIBRARY_PATH: "{{pg_dst}}/lib/"
129+

0 commit comments

Comments
 (0)