File tree Expand file tree Collapse file tree 6 files changed +53
-2
lines changed Expand file tree Collapse file tree 6 files changed +53
-2
lines changed File renamed without changes.
Original file line number Diff line number Diff line change
1
+ # ## initdb and send configs
2
+
3
+ ---
4
+ - hosts : nodes
5
+
6
+ environment :
7
+ PATH : " {{ pg_dst }}/bin:{{ ansible_env.PATH }}"
8
+
9
+ tasks :
10
+ - name : pkill pg
11
+ shell : ' pkill -9 postgres || true'
12
+
13
+ - name : remove datadirs on datanodes
14
+ file : path={{pg_datadir}} state=absent
15
+
16
+ - name : create datadirs on datanodes
17
+ command : " initdb {{pg_datadir}}"
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+
3
+ '''
4
+ Run ec2.py stored in .. directory and appends ec2_shardlord ec2_workers groups
5
+ to it.
6
+ '''
7
+
8
+ import os
9
+ import subprocess
10
+ import json
11
+ import socket
12
+
13
+ def ec2_elect_shardlord ():
14
+ script_dir = os .path .dirname (os .path .realpath (__file__ ))
15
+ ec2_path = os .path .join (os .path .dirname (script_dir ), "ec2.py" )
16
+ ec2_inv_txt = subprocess .check_output ([ec2_path , "--list" ])
17
+ ec2_inv = json .loads (ec2_inv_txt )
18
+ hosts = list (ec2_inv ["_meta" ]["hostvars" ].keys ())
19
+ # sort to choose the same shardlord each time
20
+ hosts .sort (key = socket .inet_aton )
21
+ shardlord , workers = [hosts [0 ]], hosts [1 :]
22
+ ec2_inv ["ec2_shardlord" ] = shardlord
23
+ ec2_inv ["ec2_workers" ] = workers
24
+ print json .dumps (ec2_inv , sort_keys = True , indent = 2 )
25
+
26
+
27
+ if __name__ == '__main__' :
28
+ # Run the script
29
+ ec2_elect_shardlord ()
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ pg_prefix="{{ansible_env.HOME}}/pg"
16
16
pg_src="{{pg_prefix}}/src"
17
17
pg_dst="{{pg_prefix}}/install"
18
18
pg_datadir="{{pg_prefix}}/data_{{pg_port}}"
19
+ pg_logfile="{{pg_datadir}}/pg.log"
19
20
pg_port=5432
20
21
21
22
pathman_repo=https://github.com/postgrespro/pg_pathman.git
@@ -41,4 +42,4 @@ ansible_ssh_private_key_file=~/.ssh/aws_rsa
41
42
42
43
# For local development
43
44
[vagrant]
44
- 10.42.42.10
45
+ # 10.42.42.10
Original file line number Diff line number Diff line change
1
+ # ## Build & install from sources PG, pg_pathman and pg_shardman
2
+
1
3
---
2
4
- hosts : nodes
3
5
Original file line number Diff line number Diff line change @@ -3,7 +3,9 @@ chmod 0400 ~/.ssh/aws_rsa
3
3
4
4
install python packages for ec2.py: (venv is recommended):
5
5
python3 -m venv ~/venv/aws
6
- source ~/venv/aws/bin/activate
6
+ As of writing this, python 3.5 has a nasty bug, so better use python 2:
7
+ virtualenv -p /usr/bin/python ~/venv/aws_2.7
8
+ source ~/venv/aws_2.7/bin/activate
7
9
pip install boto boto3 six ansible
8
10
9
11
Download and set up ec2.ini:
You can’t perform that action at this time.
0 commit comments