Skip to content

Commit 0192a6c

Browse files
committed
brand new provision script
1 parent 4716439 commit 0192a6c

File tree

1 file changed

+161
-0
lines changed

1 file changed

+161
-0
lines changed

contrib/mmts/tests2/provision.yml

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
---
2+
3+
- hosts: all
4+
5+
vars:
6+
pg_port: 15432
7+
pg_prefix: "{{ansible_env.HOME}}/pg_cluster"
8+
pg_src: "{{pg_prefix}}/src"
9+
pg_dst: "{{pg_prefix}}/install"
10+
pg_datadir: "{{pg_prefix}}/data_{{pg_port}}"
11+
pg_repo: https://github.com/postgrespro/postgres_cluster.git
12+
pg_version_tag: master
13+
pg_destroy_and_init: true
14+
makejobs: 4
15+
16+
tasks:
17+
18+
- name: ensure dependencies (Debian)
19+
apt: pkg={{item}} state=installed
20+
with_items:
21+
- git
22+
- automake
23+
- libtool
24+
- build-essential
25+
- bison
26+
- flex
27+
- libreadline-dev
28+
when: ansible_os_family == "Debian"
29+
become: yes
30+
31+
- name: ensure dependencies (RedHat)
32+
yum: name="@Development tools" state=present
33+
when: ansible_os_family == "RedHat"
34+
become: yes
35+
36+
- name: ensure dependencies (RedHat)
37+
yum: name={{item}} state=installed
38+
with_items:
39+
- git
40+
- automake
41+
- libtool
42+
- bison
43+
- flex
44+
- readline-devel
45+
when: ansible_os_family == "RedHat"
46+
become: yes
47+
48+
- name: increase semaphores
49+
sysctl: name=kernel.sem value="1000 128000 128 512"
50+
become: yes
51+
52+
- name: increase open files
53+
lineinfile:
54+
dest: /etc/security/limits.d/cluster.conf
55+
line: "{{ansible_ssh_user}} soft nofile 65535"
56+
state: present
57+
create: yes
58+
become: yes
59+
60+
- name: clone postgres sources
61+
git: repo={{pg_repo}}
62+
dest={{pg_src}}
63+
version={{pg_version_tag}}
64+
depth=1
65+
accept_hostkey=True
66+
register: pg_sources
67+
68+
- name: build and install
69+
shell: env CFLAGS="-O0" ./configure --prefix={{pg_dst}} --enable-debug --without-zlib && make clean && make -j {{makejobs}} && make install
70+
args:
71+
chdir: "{{pg_src}}"
72+
creates: "{{pg_dst}}/bin/postgres"
73+
74+
- name: build raftable
75+
shell: "make clean && make -j {{makejobs}} install"
76+
args:
77+
chdir: "{{pg_src}}/contrib/raftable"
78+
79+
- name: build multimaster
80+
shell: "make clean && make -j {{makejobs}} install"
81+
args:
82+
chdir: "{{pg_src}}/contrib/mmts"
83+
84+
###############################################################
85+
86+
- name: stop postgres if it was running
87+
shell: "pkill -9 postgres || true"
88+
when: pg_destroy_and_init
89+
90+
- name: remove datadirs on datanodes
91+
command: "rm -rf {{pg_datadir}}"
92+
when: pg_destroy_and_init
93+
94+
- name: create datadirs on datanodes
95+
command: "{{pg_dst}}/bin/initdb {{pg_datadir}}"
96+
environment:
97+
LD_LIBRARY_PATH: "{{pg_dst}}/lib/"
98+
args:
99+
creates: "{{pg_datadir}}"
100+
101+
- name: generate mmts connstrings
102+
set_fact:
103+
connstr: "host={{item}} user={{ansible_ssh_user}} port={{pg_port}} dbname=postgres"
104+
raft_connstr: "{{ hostvars[item]['node_id'] }}:{{item}}:8989"
105+
with_items:
106+
"{{ groups['nodes'] | reverse | batch(nnodes | d(3) | int) | first }}"
107+
register: connstrs
108+
109+
- name: collect raftable connstrings
110+
set_fact:
111+
mm_connstr: "{{ connstrs.results | map(attribute='ansible_facts.connstr') | join(', ') }}"
112+
raft_connstr: "{{ connstrs.results | map(attribute='ansible_facts.raft_connstr') | join(', ') }}"
113+
114+
- name: configure postgres on datanodes
115+
lineinfile:
116+
dest: "{{pg_datadir}}/postgresql.conf"
117+
line: "{{item}}"
118+
state: present
119+
with_items:
120+
- "listen_addresses = '*'"
121+
- "max_prepared_transactions = 800"
122+
- "shared_buffers = 3GB"
123+
- "max_connections = 2048"
124+
- "port = {{pg_port}}"
125+
- "synchronous_commit = off"
126+
- "wal_level = logical"
127+
- "max_worker_processes = 15"
128+
- "max_replication_slots = 10"
129+
- "max_wal_senders = 10"
130+
- "log_checkpoints = on"
131+
- "log_autovacuum_min_duration = 0"
132+
- "shared_preload_libraries = 'raftable,multimaster'"
133+
- "default_transaction_isolation = 'repeatable read'"
134+
- "raftable.id = {{ node_id }}"
135+
- "raftable.peers = '{{ raft_connstr }}'"
136+
- "multimaster.workers = 4"
137+
- "multimaster.arbiter_port = {{ 7777 }}"
138+
- "multimaster.use_raftable = true"
139+
- "multimaster.queue_size=52857600"
140+
- "multimaster.ignore_tables_without_pk = 1"
141+
- "multimaster.node_id = {{ node_id }}"
142+
- "multimaster.conn_strings = '{{ mm_connstr }}'"
143+
- "multimaster.heartbeat_recv_timeout = 1000"
144+
- "multimaster.heartbeat_send_timeout = 250"
145+
- "multimaster.twopc_min_timeout = 40000"
146+
147+
- name: enable blind trust on datanodes
148+
lineinfile:
149+
dest: "{{pg_datadir}}/pg_hba.conf"
150+
line: "{{item}}"
151+
state: present
152+
with_items:
153+
- "host all all 0.0.0.0/0 trust"
154+
- "host replication all 0.0.0.0/0 trust"
155+
- "local replication all trust"
156+
157+
- name: start postgrespro
158+
shell: "ulimit -c unlimited && {{pg_dst}}/bin/pg_ctl start -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"
159+
environment:
160+
LD_LIBRARY_PATH: "{{pg_dst}}/lib/"
161+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy