-
Notifications
You must be signed in to change notification settings - Fork 2
/
mysql-cluster.yaml
128 lines (120 loc) · 3.52 KB
/
mysql-cluster.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
heat_template_version: 2015-04-30
description: AutoScaling Wordpress
parameters:
image:
type: string
description: Image used for servers
default: CentOS-7-x86_64
key:
type: string
description: SSH key to connect to the servers
default: cloudkey1
flavor:
type: string
description: flavor used by the web servers
constraints:
- allowed_values: [m1.small, m1.medium]
database_flavor:
type: string
description: flavor used by the db server
constraints:
- allowed_values: [m1.small, m1.medium]
network:
type: string
description: Network used by the server
default: 24a88e36-fd6d-446d-8e0c-5edee3b79d1d
subnet_id:
type: string
description: subnet on which the load balancer will be located
default: 70aa7e50-a182-4ac8-a071-d664dda1c297
database_name:
type: string
description: Name of the wordpress DB
default: wordpress
database_user:
type: string
description: Name of the wordpress user
default: wordpress
public_network:
type: string
description: UUID of a Neutron external network
default: 9edf95ac-bd78-4988-91d3-b41affaddc11
resources:
mysql_cluster:
type: OS::Heat::CloudConfig
properties:
cloud_config:
runcmd:
- yum update -y
- setenforce 0
- cat << MARIA > /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
MARIA
- yum install MariaDB-Galera-server MariaDB-client galera -y
- yum install socat
- service mysql start
- yum install firewalld
- systemctl start firewalld
- systemctl enable firewalld
- for i in 3306 4444 4567 4568; do sudo firewall-cmd --permanent --add-port=$i/tcp; done;
- firewall-cmd --reload
dbserver1:
type: OS::Nova::Server
properties:
key_name: { get_param: key }
flavor: { get_param: flavor }
image: { get_param: image }
networks: [{ network: { get_param: network } }]
user_data:
get_resource: mysql_cluster
user_data_format: RAW
dbserver2:
type: OS::Nova::Server
properties:
key_name: { get_param: key }
flavor: { get_param: flavor }
image: { get_param: image }
networks: [{ network: { get_param: network } }]
user_data:
get_resource: mysql_cluster
user_data_format: RAW
dbserver3:
type: OS::Nova::Server
properties:
key_name: { get_param: key }
flavor: { get_param: flavor }
image: { get_param: image }
networks: [{ network: { get_param: network } }]
user_data:
get_resource: mysql_cluster
user_data_format: RAW
monitor:
type: OS::Neutron::HealthMonitor
properties:
type: TCP
delay: 5
max_retries: 5
timeout: 5
lb_pool:
type: OS::Neutron::Pool
properties:
protocol: HTTP
monitors: [{get_resource: monitor}]
subnet_id: {get_param: subnet_id}
lb_method: ROUND_ROBIN
vip:
protocol_port: 3306
lb_members:
type: OS::Neutron::LoadBalancer
properties:
pool_id: { get_resource: lb_pool }
members: [ { get_resource: dbserver1 }, { get_resource: dbserver2 }, { get_resource: dbserver3 } ]
protocol_port: 3306
outputs:
vip_ip:
description: IP of VIP
value: { get_attr: [ lb_pool, vip, address ] }