-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathmakefile
189 lines (125 loc) · 4.65 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
NODE := $(shell basename $(PWD) | cut -d"." -f1)
PGLOG = /pg/data/log/postgresql-$(shell date +%a).csv
ssh:
ssh $(NODE)
status:
ssh $(NODE) "systemctl status"
pg-start:
ssh $(NODE) "sudo systemctl start postgresql"
pg-stop:
ssh $(NODE) "sudo systemctl stop postgresql"
pg-restart:
ssh $(NODE) "sudo systemctl restart postgresql"
pg-reload:
ssh $(NODE) "sudo systemctl reload postgresql"
pg-status:
ssh $(NODE) "sudo systemctl status postgresql"
pg-show-conf:
ssh $(NODE) "sudo cat /pg/data/postgresql.conf"
pg-show-hba:
ssh $(NODE) "sudo cat /pg/data/pg_hba.conf"
pg-show-recovery:
ssh $(NODE) "sudo cat /pg/data/recovery.conf"
pg-show-status:
ssh $(NODE) "sudo -iu postgres psql -xc 'SELECT pg_is_in_recovery();'"
pg-show-change:
ssh $(NODE) sudo -iu postgres ls /pg/change | sort -n
pg-change-history:
ssh $(NODE) sudo -iu postgres cat /pg/change/history
pg-change-log:
ssh $(NODE) sudo -iu postgres cat /pg/change/history
pg-show-log:
ssh $(NODE) sudo cat $(PGLOG)
pg-tail-log:
ssh $(NODE) sudo tail -f $(PGLOG)
pg-update-bin:
ssh $(NODE) "sudo rm -rf /tmp/bin"
scp -r ../../bin/pg $(NODE):/tmp/bin > /dev/null
ssh $(NODE) "sudo rm -rf /pg/bin; sudo mv -f /tmp/bin /pg/bin;sudo chown -R postgres:postgres /pg/bin"
pg-update-conf:
scp postgresql.conf $(NODE):/tmp/postgresql.conf
ssh $(NODE) 'sudo -iu postgres /pg/bin/deploy.sh /tmp/postgresql.conf'
pg-update-hba:
scp pg_hba.conf $(NODE):/tmp/pg_hba.conf
ssh $(NODE) 'sudo -iu postgres /pg/bin/deploy.sh /tmp/pg_hba.conf'
pg-update-recovery:
scp recovery.conf $(NODE):/tmp/recovery.conf
ssh $(NODE) 'sudo -iu postgres /pg/bin/deploy.sh /tmp/recovery.conf'
pg-show-activity:
ssh $(NODE) "sudo -iu postgres psql -xc 'TABLE pg_stat_activity;'"
pg-show-replication:
ssh $(NODE) "sudo -iu postgres psql -xc 'TABLE pg_stat_replication;'"
pg-show-replication-slots:
ssh $(NODE) "sudo -iu postgres psql -xc 'TABLE pg_replication_slots;'"
pg-version:
ssh $(NODE) pg_ctl --version
pg-kill:
ssh $(NODE) "sudo -iu postgres psql -c 'SELECT count(pg_terminate_backend(pid)) FROM pg_stat_activity WHERE pid <> pg_backend_pid();'"
pgb-start:
ssh $(NODE) "sudo systemctl start pgbouncer"
pgb-stop:
ssh $(NODE) "sudo systemctl stop pgbouncer"
pgb-restart:
ssh $(NODE) "sudo systemctl restart pgbouncer"
pgb-reload:
ssh $(NODE) "sudo systemctl reload pgbouncer"
pgb-status:
ssh $(NODE) "sudo systemctl status pgbouncer"
pgb-show-log:
ssh $(NODE) sudo cat /var/log/pgbouncer/pgbouncer.log
pgb-tail-log:
ssh $(NODE) sudo tail -f /var/log/pgbouncer/pgbouncer.log
pgb-update-conf:
scp pgbouncer.ini $(NODE):/tmp/pgbouncer.ini
ssh $(NODE) 'sudo -iu postgres /pg/bin/deploy.sh /tmp/pgbouncer.ini'
postgres-exporter-start:
ssh $(NODE) "sudo systemctl start postgres_exporter"
postgres-exporter-stop:
ssh $(NODE) "sudo systemctl stop postgres_exporter"
postgres-exporter-restart:
ssh $(NODE) "sudo systemctl restart postgres_exporter"
postgres-exporter-status:
ssh $(NODE) "sudo systemctl status postgres_exporter"
postgres-exporter-update-conf:
scp postgres_exporter.yaml $(NODE):/tmp/postgres_exporter.yaml
ssh $(NODE) 'sudo -iu postgres /pg/bin/deploy.sh /tmp/postgres_exporter.yaml
postgres-exporter-update-env:
scp postgres_exporter.env $(NODE):/tmp/postgres_exporter.env
ssh $(NODE) 'sudo -iu postgres /pg/bin/deploy.sh /tmp/postgres_exporter.env
consul-start:
ssh $(NODE) "sudo systemctl start consul"
consul-stop:
ssh $(NODE) "sudo systemctl stop consul"
consul-restart:
ssh $(NODE) "sudo systemctl restart consul"
consul-reload:
ssh $(NODE) "sudo systemctl reload consul"
consul-status:
ssh $(NODE) "sudo systemctl status consul"
consul-show-conf:
ssh $(NODE) "sudo cat /etc/consul.d/consul.json"
consul-show-nodes:
ssh $(NODE) "consul catalog nodes"
consul-show-services:
ssh $(NODE) "consul catalog services"
consul-update-conf:
scp consul.json $(NODE):/tmp/consul.json
ssh $(NODE) 'sudo mv -f /tmp/consul.json /etc/consul.d/consul.json; sudo chown -R consul:consul /etc/consul.d/'
prometheus-start:
ssh $(NODE) "sudo systemctl start prometheus"
prometheus-stop:
ssh $(NODE) "sudo systemctl stop prometheus"
prometheus-restart:
ssh $(NODE) "sudo systemctl restart prometheus"
prometheus-reload:
scp prometheus.yml $(NODE):/tmp/prometheus.yml
ssh $(NODE) "sudo mv -f /tmp/prometheus.yml /etc/prometheus/prometheus.yml; sudo chown -R prometheus:prometheus /etc/prometheus"
ssh $(NODE) "sudo systemctl restart prometheus"
prometheus-status:
ssh $(NODE) "sudo systemctl status prometheus"
prometheus-show-conf:
ssh $(NODE) "sudo cat /etc/prometheus.d/prometheus.json"
prometheus-show-nodes:
ssh $(NODE) "prometheus catalog nodes"
prometheus-show-services:
ssh $(NODE) "prometheus catalog services"