Cluster MariaDB – Galera
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ansible
terraform
.gitignore
README.md

README.md

Cluster MariaDB - Galera

Project clone

$ git clone https://github.com/vandocouto/MariaDB-Galera.git

##Configure the keys file step 1 - Create directory (chave)

$ cd MariaDB-Galera/
$ mkdir chave

step 2 - Move the .pem into the key directory, file permission should be 400

cd chave/
$ ls -ltr
total 4
-r-------- 1 evandrocouto evandrocouto 1692 Abr  7 12:32 Blog-Estudo.pem

Script deploy.sh

Step 1 - Inform AWS Access Key and AWS Secret Key

cd ../
$ vim terraform/deploy.sh 
Need full access on EC2
export AWS_ACCESS_KEY_ID=""
export AWS_SECRET_ACCESS_KEY=""

Deploy infrastructure

Need to install Terraform and Ansible

Step 1 - Adjust the variable file

$ vim terraform/default/variables.tf

Step 2 - After tuning, run the command below

 ./deploy.sh default plan

Step 2 - Building the Infrastructure

 ./deploy.sh default apply

Output

Will be displayed the IP's and Load Balance post construction

Outputs:

Private IP = 10.0.0.8,10.0.3.238,10.0.1.220
Public IP = 34.203.229.66,54.236.17.153,54.91.250.110
lb_address = internal-MariaDBGalera-1689159607.us-east-1.elb.amazonaws.com

Running the playbook

Step 1 - Configuring the hosts file

$ vim ansible/hosts

Example:

Set as below (First public ip and private ip should be the manager)
[galera]
34.203.229.66
54.236.17.153
54.91.250.110

[manager]
34.203.229.66

[node]
54.236.17.153
54.91.250.110

[all:children]
galera
manager
node

[all:vars]
manager_ip=10.0.0.8
node1_ip=10.0.3.238
node2_ip=10.0.1.110
root_db_password=pass
ansible_ssh_user=ubuntu
ansible_ssh_private_key_file=../chave/Blog-Estudo.pem

Step 2 - Run the playbook

$ ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i hosts tasks/main.yml

Access the instances and enter mysql with the user root and password pass

$ mysql -u root -ppass

Or

mysql -u root -ppass -e "show status like 'wsrep_cluster_size'"

If everything is correct, it should contain the value 3

+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| wsrep_cluster_size | 3     |
+--------------------+-------+

Closing the project

 $ ./deploy.sh default destroy