Following on from my other couple of quick introductions for setting up and using vagrant, you can see them below.
This is the first step in setting up MariaDB and setup database replication using Vagrant. This example was all done on the Mac
The first thing we need to do is create the directories, change to where you want to store the machines, I use the default location ~/.vagrant.d/boxes.
So lets start, load terminal and type
cd ~/.vagrant.d/boxes/ mkdir master mkdir slave
Now you have the directories, you can type vagrant init to create the basic template, but I would copy the ones below
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "centos/7" config.vm.define "master" config.vm.network "private_network", ip: "192.168.33.10" config.vm.provision "ansible" do |ansible| ansible.playbook = "playbook.yml" end end
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "centos/7" config.vm.define "slave" config.vm.network "private_network", ip: "192.168.33.11" config.vm.provision "ansible" do |ansible| ansible.playbook = "playbook.yml" end end
Now you have the machines ready to fire up, but before we do in each of the directories, you need to create playbook.yml in both the master and slave directory.
As you can tell from the files, you have two machines, one named Master and one named Slave, they will have distinct IP addresses as well.
--- - hosts: all become: true tasks: - name: create repo file copy: dest: "/etc/yum.repos.d/LucyDB.repo" content: | [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1 - name: Install yum: name: mariadb-server state: present
Once you have saved the file, you are ready to fire up the machines, this will automatically create the MariaDB repo file and install MariaDB for you so you will have a working machine. In the next step we will configure MariaDB and setup and test the databases.