Skip to content

Commit 97526b4

Browse files
committed
postgres role for deploy
1 parent 3f882e3 commit 97526b4

File tree

3 files changed

+156
-2
lines changed

3 files changed

+156
-2
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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+
register: pg_sources
52+
when: pg_copydist is undefined
53+
54+
- name: force rebuild on changed sources
55+
command: "rm -f {{pg_dst}}/bin/postgres"
56+
when: (pg_copydist is undefined) and pg_sources.changed
57+
58+
- name: build and install
59+
shell: ./configure --prefix={{pg_dst}} --without-zlib && make clean && make -j {{makejobs}} && make install
60+
args:
61+
chdir: "{{pg_src}}"
62+
creates: "{{pg_dst}}/bin/postgres"
63+
when: pg_copydist is undefined
64+
65+
#############################################################################
66+
67+
- name: copy pg source
68+
copy: src=./{{item}} dest=~/{{item}} mode=0755
69+
with_items:
70+
- "pg_cluster_install.tgz"
71+
when: pg_copydist is defined
72+
73+
- name: extract postgres
74+
command: "tar xzf pg_cluster_install.tgz"
75+
when: pg_copydist is defined
76+
77+
#############################################################################
78+
79+
- stat: path={{pg_datadir}}/postmaster.pid
80+
register: pg_pidfile
81+
82+
# - name: stop postgres if it was running
83+
# command: "{{pg_dst}}/bin/pg_ctl stop -w -D {{pg_datadir}}"
84+
# environment:
85+
# LD_LIBRARY_PATH: "{{pg_dst}}/lib"
86+
# when: pg_pidfile.stat.exists
87+
88+
- name: stop postgres if it was running
89+
shell: "kill -9 `head -n 1 {{pg_datadir}}/postmaster.pid`"
90+
environment:
91+
LD_LIBRARY_PATH: "{{pg_dst}}/lib"
92+
when: pg_pidfile.stat.exists
93+
94+
- name: remove datadirs on datanodes
95+
command: "rm -rf {{pg_datadir}}"
96+
when: pg_destroy_and_init
97+
98+
- name: create datadirs on datanodes
99+
command: "{{pg_dst}}/bin/initdb {{pg_datadir}}"
100+
environment:
101+
LD_LIBRARY_PATH: "{{pg_dst}}/lib/"
102+
args:
103+
creates: "{{pg_datadir}}"
104+
105+
- name: configure postgres on datanodes
106+
lineinfile:
107+
dest: "{{pg_datadir}}/postgresql.conf"
108+
line: "{{item.line}}"
109+
state: present
110+
with_items: "{{pg_config}}"
111+
112+
- name: configure postgres on datanodes -- 2
113+
lineinfile:
114+
dest: "{{pg_datadir}}/postgresql.conf"
115+
line: "{{item.line}}"
116+
state: present
117+
with_items: "{{pg_config_role}}"
118+
119+
- name: enable blind trust on datanodes
120+
lineinfile:
121+
dest: "{{pg_datadir}}/pg_hba.conf"
122+
line: "host all all 0.0.0.0/0 trust"
123+
124+
- name: start postgrespro
125+
shell: "{{pg_dst}}/bin/pg_ctl start -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"
126+
environment:
127+
LD_LIBRARY_PATH: "{{pg_dst}}/lib/"
128+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# vim: ts=2 sts=2 sw=2 expandtab
2+
---
3+
makejobs: 4
4+
5+
pg_repo: git://git.postgresql.org/git/postgresql.git
6+
pg_version_tag: master
7+
8+
pg_destroy_and_init: false
9+
10+
pg_port: 5432
11+
pg_config:
12+
- line: "shared_buffers = 3GB"
13+
- line: "wal_keep_segments = 128"
14+
- line: "fsync = off"
15+
- line: "autovacuum = off"
16+
- line: "listen_addresses = '*'"
17+
- line: "max_connections = 2048"
18+
- line: "max_prepared_transactions = 4000"
19+
- line: "port = {{pg_port}}"
20+
pg_config_role:
21+
- line: "#pg_config_role"
22+
23+
pg_prefix: "{{ansible_env.HOME}}/pg_cluster"
24+
pg_src: "{{pg_prefix}}/src"
25+
pg_dst: "{{pg_prefix}}/install"
26+
pg_datadir: "{{pg_prefix}}/data_{{pg_port}}"

tests/perf.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
gather_facts: no
3131
tasks:
3232
- name: init database
33-
shell: "~/pg_cluster/install/bin/dtmbench {{connections}} -a 2000000 -i"
33+
shell: "~/pg_cluster/install/bin/dtmbench {{connections}} -a 500000 -i"
3434
register: init_result
3535
- debug: var=init_result
3636

@@ -44,7 +44,7 @@
4444
shell: >
4545
~/pg_cluster/install/bin/dtmbench {{connections}}
4646
-w {{ (nconns | d(100)| int)*(nnodes | d(2) | int)/(2*( groups['clients'] | count))}}
47-
-s {{offset}} -d 100000 -r 1 -n 20000 -a 500000 |
47+
-s {{offset}} -d 100000 -r 1 -n 2000 -a 500000 |
4848
tee -a perf.results |
4949
sed "s/^/`hostname`:/"
5050
register: transfers_result

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