This repository has been archived by the owner on Sep 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
manifest.yaml
197 lines (186 loc) · 7.95 KB
/
manifest.yaml
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
190
191
192
193
194
195
196
197
jpsType: install
application:
name: MariaDB Galera Cluster (10.0)
id: mariadb-galera
categories:
- apps/clustered-dbs
- apps/clusters
homepage: https://mariadb.com/
logo: https://raw.githubusercontent.com/layershift/mariadb-galera/master/img/mariadb.png
type: docker
version: '10.0'
description: "MariaDB 10.0 Galera Cluster is a synchronous multi-master cluster
for MariaDB. It is available on Linux only, and only supports the XtraDB/InnoDB
storage engines. \nThis installation consists of three MariaDB cluster members
in Docker containers as well as HAProxy to connecto from your application to the
cluster."
settings:
fields:
- type: string
name: app_user
caption: Username
vtype: alphanum
vtypeText: Alphanumeric input only.
placeholder: Applicatinon database user
required: true
- type: string
name: app_pwd
caption: Password
vtype: alphanum
vtypeText: Alphanumeric input only.
placeholder: Application database password
required: true
- type: string
name: database_name
caption: Database
vtype: alphanum
vtypeText: Alphanumeric input only.
placeholder: Application database name
required: true
- type: string
name: root_pwd
caption: Root password
vtype: alphanum
vtypeText: Alphanumeric input only.
placeholder: Root password
required: true
env:
topology:
nodes:
- nodeType: docker
count: 1
fixedCloudlets: 1
flexibleCloudlets: 16
displayName: Galera Proxy
docker:
nodeMission: cp
image: layershift/haproxy:dev
- nodeType: docker
count: 3
fixedCloudlets: 1
flexibleCloudlets: 24
displayName: MariaDB Galera Cluster
docker:
nodeMission: sqldb
image: layershift/mariadb-galera:dev
onInstall:
call:
- preconfigureMariaDB
- configureNodes
- startNode0
- startNode1
- startNode2
- configureHAProxy
procedures:
- id: preconfigureMariaDB
onCall:
- executeShellCommands:
- nodeMission: sqldb
user: root
commands:
- sed -i "s/NODE1/${nodes.sqldb[0].address}/g" /etc/sysconfig/iptables
- sed -i "s/NODE2/${nodes.sqldb[1].address}/g" /etc/sysconfig/iptables
- sed -i "s/NODE3/${nodes.sqldb[2].address}/g" /etc/sysconfig/iptables
- sed -i "s/NODE4/${nodes.cp[0].address}/g" /etc/sysconfig/iptables
- systemctl enable iptables.service 2>&1
- systemctl restart iptables.service 2>&1
- service mysql start 2>&1
- /usr/bin/mysqladmin -u root password "${settings.root_pwd}"
- sed -i "s/NODE1/${nodes.sqldb[0].address}/g" /tmp/user.sql
- sed -i "s/NODE2/${nodes.sqldb[1].address}/g" /tmp/user.sql
- sed -i "s/NODE3/${nodes.sqldb[2].address}/g" /tmp/user.sql
- sed -i "s/GOESHERE1/${settings.root_pwd}/g" /tmp/user.sql
- sed -i "s/GOESHERE2/${settings.app_user}/g" /tmp/user.sql
- sed -i "s/GOESHERE3/${settings.app_pwd}/g" /tmp/user.sql
- sed -i "s/GOESHERE4/${settings.database_name}/g" /tmp/user.sql
- sed -i "s/GOESHERE5/${nodes.cp[0].address}/g" /tmp/user.sql
- mysql -uroot -p"${settings.root_pwd}" < /tmp/user.sql
- service mysql stop 2>&1
- sed -i "s/PASSWORD/${settings.root_pwd}/g" /etc/my.cnf.d/server.cnf
- id: configureNodes
onCall:
- executeShellCommands:
- nodeId: "${nodes.sqldb[0].id}"
user: root
commands:
- sed -i "s/NODE1,NODE2,NODE3/${nodes.sqldb[0].address}:4567,${nodes.sqldb[1].address}:4567,${nodes.sqldb[2].address}:4567/g"
/etc/my.cnf.d/server.cnf
- sed -i "s/THISNODE/${nodes.sqldb[0].address}/g" /etc/my.cnf.d/server.cnf
- sed -i "s/THISNAME/galera-node-${nodes.sqldb[0].id}/g" /etc/my.cnf.d/server.cnf
- sed -i "s/#wsrep/wsrep/g" /etc/my.cnf.d/server.cnf
- nodeId: "${nodes.sqldb[1].id}"
user: root
commands:
- sed -i "s/NODE1,NODE2,NODE3/${nodes.sqldb[0].address}:4567,${nodes.sqldb[1].address}:4567,${nodes.sqldb[2].address}:4567/g"
/etc/my.cnf.d/server.cnf
- sed -i "s/THISNODE/${nodes.sqldb[1].address}/g" /etc/my.cnf.d/server.cnf
- sed -i "s/THISNAME/galera-node-${nodes.sqldb[1].id}/g" /etc/my.cnf.d/server.cnf
- sed -i "s/#wsrep/wsrep/g" /etc/my.cnf.d/server.cnf
- nodeId: "${nodes.sqldb[2].id}"
user: root
commands:
- sed -i "s/NODE1,NODE2,NODE3/${nodes.sqldb[0].address}:4567,${nodes.sqldb[1].address}:4567,${nodes.sqldb[2].address}:4567/g"
/etc/my.cnf.d/server.cnf
- sed -i "s/THISNODE/${nodes.sqldb[2].address}/g" /etc/my.cnf.d/server.cnf
- sed -i "s/THISNAME/galera-node-${nodes.sqldb[2].id}/g" /etc/my.cnf.d/server.cnf
- sed -i "s/#wsrep/wsrep/g" /etc/my.cnf.d/server.cnf
- id: startNode0
onCall:
- executeShellCommands:
- nodeId: "${nodes.sqldb[0].id}"
user: root
commands:
- service mysql stop 2>&1; service mysql start --wsrep-new-cluster 2>&1
- id: startNode1
onCall:
- executeShellCommands:
- nodeId: "${nodes.sqldb[1].id}"
user: root
commands:
- service mysql stop 2>&1; service mysql start 2>&1
- id: startNode2
onCall:
- executeShellCommands:
- nodeId: "${nodes.sqldb[2].id}"
user: root
commands:
- service mysql stop 2>&1; service mysql start 2>&1
- id: configureHAProxy
onCall:
- executeShellCommands:
- nodeId: "${nodes.cp[0].id}"
user: root
commands:
- sed -i "s/HAPIP/${nodes.cp[0].address}/g" /etc/haproxy/haproxy.cfg
- sed -i "s/HAPASS/${nodes.cp[0].password}/g" /etc/haproxy/haproxy.cfg
- sed -i "s/HOST1_IP/${nodes.sqldb[0].address}/g" /etc/haproxy/haproxy.cfg
- sed -i "s/HOST2_IP/${nodes.sqldb[1].address}/g" /etc/haproxy/haproxy.cfg
- sed -i "s/HOST3_IP/${nodes.sqldb[2].address}/g" /etc/haproxy/haproxy.cfg
- sed -i "s/HAPASS/${nodes.cp[0].password}/g" /etc/haproxy/scripts/alert.py
- sed -i "s/EMAIL_ADDRESS/${user.email}/g" /etc/haproxy/scripts/alert.py
- "/bin/systemctl daemon-reload"
- "/bin/systemctl restart haproxy.service"
- "/bin/systemctl restart supervisord.service"
success:
text: |
Your MariaDB Galera Cluster has been deployed.
You can access the docker containers from our **[SSH Gateway](http://kb.layershift.com/jelastic-ssh-access)**.
Root password and connection details have been emailed to you.
More about MariaDB Galera cluster: [https://mariadb.com/kb/en/mariadb/what-is-mariadb-galera-cluster/](https://mariadb.com/kb/en/mariadb/what-is-mariadb-galera-cluster/).
Docker on Jelastic: [https://jelastic.com/docker/](https://jelastic.com/docker/)."
email: |
Your MariaDB Galera Cluster has been deployed.
You can access the docker containers from our **[SSH Gateway](http://kb.layershift.com/jelastic-ssh-access)**.
Details:
* **MySQL root password is**: `${settings.root_pwd}`
* **Database user**: `${settings.app_user}`
* **Database user password**: `${settings.app_pwd}`
* **Application Database**: `${settings.database_name}`
* HAProxy IP for database connection: **${nodes.cp[0].address}**
* HAProxy admin URL: ${nodes.cp[0].url}/stats
* HAProxy access:
** user: `haproxy`
** password: `${nodes.cp[0].password}`
Entry point for your application is [HAProxy](http://www.haproxy.org/) instance with ${nodes.cp[0].address} IP address - you should point your application to that IP when configuring your database.
More about MariaDB Galera cluster: [https://mariadb.com/kb/en/mariadb/what-is-mariadb-galera-cluster/](https://mariadb.com/kb/en/mariadb/what-is-mariadb-galera-cluster/).
Docker on Jelastic: [https://jelastic.com/docker/](https://jelastic.com/docker/).