-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmanual
67 lines (66 loc) · 2.98 KB
/
manual
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
# -*- mode: ruby -*- vi: set ft=ruby :
haproxy_url = "http://192.168.88.5:8182/haproxy?stats"
puts "Your systems looks ready to test, now you can play and test things out"
puts "Visit the haproxy url to see who is master : " + String(haproxy_url)
puts ""
puts "Login in the second node: vagrant ssh db1 and switch over the cluster like this:"
puts ""
puts "sudo su - "
puts "su - postgres"
puts "repmgr cluster show"
puts "repmgr standby switchover"
puts "Then visit the haproxy url and see the role switch result"
puts ""
puts "To connect to the 'testdb' database you can use different ports which will mean different services"
puts "Haproxy (HA/VIP):"
puts "Connect to the HA port psql postgres://test:[email protected]:5432/testdb"
puts ""
puts "Database (direct/VIP):"
puts "psql postgres://test:[email protected]:6432/testdb"
puts ""
puts "Pgbouncer (VIP):"
puts "psql postgres://test:[email protected]:7432/testdb"
puts ""
puts "It's important to understand the differences between those 3 ports"
puts "Flow is : HAPROXY -> PGBOUNCER -> DATABASE"
puts ""
puts "Every server has a pgbouncer, database and haproxy instance present (and of course a keepalived install)"
puts "keepalived will only handle the VIP address, haproxy will only listen on port 5432 on the vip ip and is the only one that will, but since each node has "
puts "a haproxy running at all times but it's only listening on the VIP."
puts ""
puts "So it's important to understand that when connecting to the VIP IP that you always land on the machine where keepalived owns the vip."
puts "This doesn't mean its the postgresql master server."
puts "The postgresql master server can be diffent from the keepalived master, they are not related at all, they operate independant"
puts ""
puts "You can still connect to a specific server by using the non-vip IP's"
puts ""
puts "Connect directly to the DB on node1 (db1)"
puts "psql postgres://test:[email protected]:6432/testdb"
puts ""
puts "Connect directly to the DB on node2 (db2)"
puts "psql postgres://test:[email protected]:6432/testdb"
puts ""
puts "Connect indirectly to the DB via pgbouncer on node1 (db1)"
puts "psql postgres://test:[email protected]:7432/testdb"
puts ""
puts "Connect indirectly to the DB via pgbouncer on node2 (db2)"
puts "psql postgres://test:[email protected]:7432/testdb"
puts ""
puts "Now it's time to have some fun watching keepalived in action"
puts "Log into keepalived active node (ssh to the vip using vagrant user)"
puts "ssh [email protected]"
puts ""
puts "Check if the vip ip is present:"
puts "type ip a"
puts ""
puts "Kill or stop keepalived"
puts "check again : ip a"
puts ""
puts "It should be gone now and present on the other node"
puts ""
puts "Test the database connection to the VIP:"
puts "psql postgres://test:[email protected]:5432/testdb"
puts ""
puts "Also check the haproxy interface, should still work again, but the name of the node has changed"
puts "Visit the haproxy url to see who is master : " + String(haproxy_url)
puts ""