Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Now supports Debian
Browse files Browse the repository at this point in the history
  • Loading branch information
rlowe committed Aug 26, 2015
1 parent 9d4bac0 commit 882b34f
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 29 deletions.
51 changes: 51 additions & 0 deletions vagrant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,54 @@ VAGRANT_DEFAULT_PROVIDER defaults to 'virtualbox'
VAGRANT_BOX defaults to 'nrel/CentOS-6.6-x86_64

The MySQL configuration is such that it is the minimum required to set up replication. For testing such features as delayed replication, RBR/SBR, GTID, it is simply a matter of editing the vagrant/dbX-my.cnf before running the `vagrant up` command.

FAQ
===

Q: By default, there are still a lot of steps that I have to do within each virtual machine to get going
A: That is by design. Vagrant will execute `db-post-install.sh`, `dbX-post-install.sh`, and `admin-post-install.sh` in the vagrant/ directory (they are .gitignore'd) for any custom work that you want to have done (i.e. build Orchestrator, etc etc)

Q: I run some other distribution of Linux. Why don't you support that?
A: Pull Requests are welcome! If you update any of the `vagrant/*.sh` scripts, they must work with at least CentOS 6 and Ubuntu 12

Tips & Tricks
=============

Specify GTID Usage
------------------

If you want to use GTID Replication, you must update all of the vagrant/dbX-my.cnf files with the following options in [mysqld]:

enforce-gtid-consistency
gtid-mode=ON

Specify RBR/SBR
---------------

vagrant/dbX-my.cnf files are copied directly to the virtual machines. If you'd like to specify SBR/RBR/MIXED, add one of the following lines to the [mysqld] section of the my.cnf template:

binlog_format=MIXED
binlog_format=STATEMENT
binlog_format=ROW

This is not global because we want to be able to test out non-standard replication configurations.

Use VMWare vs. VirtualBox
-------------------------

%> export VAGRANT_DEFAULT_PROVIDER='vmware_fusion'
%> vagrant up

CentOS
------

This is the default. Nothing special is required:

%> vagrant up

Ubuntu
------

%> export VAGRANT_SERVER_URL="https://atlas.hashicorp.com"
%> export VAGRANT_BOX='chef/ubuntu-12.04'
%> vagrant up
1 change: 0 additions & 1 deletion vagrant/admin-build.sh
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# Do nothing for the moment
62 changes: 50 additions & 12 deletions vagrant/base-build.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,44 @@
#!/bin/bash

# Percona's Yum Repository
sudo yum --nogpgcheck -y install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
if [[ -e /etc/centos-release ]]; then
# Percona's Yum Repository
sudo yum --nogpgcheck -y install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm

# No reason not to install this stuff in all the places :)
sudo yum --nogpgcheck -y install Percona-Server-server-56 Percona-Server-shared-56 Percona-Server-client-56 Percona-Server-shared-compat
sudo yum --nogpgcheck -y install percona-toolkit innotop percona-xtrabackup
# No reason not to install this stuff in all the places :)
sudo yum --nogpgcheck -y install Percona-Server-server-56 Percona-Server-shared-56 Percona-Server-client-56 Percona-Server-shared-compat
sudo yum --nogpgcheck -y install percona-toolkit percona-xtrabackup

# All the project dependencies to build
sudo yum --nogpgcheck -y install ruby-devel gcc rpm-build git
gem install fpm
# All the project dependencies to build
sudo yum --nogpgcheck -y install ruby-devel gcc rpm-build git
gem install fpm

# Go (via EPEL)
sudo yum --nogpgcheck -y install epel-release
sudo yum --nogpgcheck -y install golang
# Go (via EPEL)
sudo yum --nogpgcheck -y install epel-release
sudo yum --nogpgcheck -y install golang
elif [[ -e /etc/debian_version ]]; then
sudo echo exit 101 > /usr/sbin/policy-rc.d
sudo chmod +x /usr/sbin/policy-rc.d
# Percona's Apt Repository
sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
echo "deb http://repo.percona.com/apt "$(lsb_release -sc)" main" | sudo tee /etc/apt/sources.list.d/percona.list
sudo apt-get -y update
sudo apt-get -y install debconf-utils
echo "golang-go golang-go/dashboard boolean true" | sudo debconf-set-selections
echo "percona-server-server-5.6 percona-server-server/root_password password vagrant" | sudo debconf-set-selections
echo "percona-server-server-5.6 percona-server-server/root_password_again password vagrant" | sudo debconf-set-selections
DEBIAN_FRONTEND=noninteractive

# No reason not to install this stuff in all the places :)
sudo apt-get -y install percona-server-server-5.6 percona-server-common-5.6 percona-server-client-5.6
sudo apt-get -y install percona-toolkit percona-xtrabackup

# All the project dependencies to build
sudo apt-get -y install ruby-dev gcc git rubygems rpm
sudo gem install fpm

# Go
sudo apt-get -y install golang-go
fi

cat <<-EOF >> /etc/hosts
192.168.57.200 admin
Expand Down Expand Up @@ -105,10 +130,23 @@ EOF
chmod go-rwx /home/vagrant/.ssh/*
chown -R vagrant:vagrant /home/vagrant/.ssh

sudo service iptables stop
if [[ -e /etc/centos-release ]]; then
sudo service iptables stop
fi

if [[ $HOSTNAME == 'admin' ]]; then
bash /orchestrator/vagrant/admin-build.sh
if [[ -e /orchestrator/vagrant/admin-post-install.sh ]]; then
bash /orchestrator/vagrant/admin-post-install.sh
fi
else
bash /orchestrator/vagrant/$HOSTNAME-build.sh

if [[ -e /orchestrator/vagrant/db-post-install.sh ]]; then
bash /orchestrator/vagrant/db-post-install.sh
fi

if [[ -e /orchestrator/vagrant/$HOSTNAME-post-install.sh ]]; then
bash /orchestrator/vagrant/$HOSTNAME-post-install.sh
fi
fi
16 changes: 13 additions & 3 deletions vagrant/db1-build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
sudo rm -rf /etc/my.cnf
sudo cp /orchestrator/vagrant/db1-my.cnf /etc/my.cnf
if [[ -e /etc/centos-release ]]; then
sudo rm -rf /etc/my.cnf
sudo cp /orchestrator/vagrant/db1-my.cnf /etc/my.cnf
sudo service mysql start
elif [[ -e /etc/debian_version ]]; then
sudo cp /orchestrator/vagrant/db1-my.cnf /etc/mysql/my.cnf
sudo /etc/init.d/mysql restart

sudo service mysql start
sudo cat <<-EOF >> /root/.my.cnf
[client]
user = root
password = vagrant
EOF
fi

/usr/bin/mysql -uroot -ss -e 'GRANT REPLICATION SLAVE ON *.* TO "repl"@"192.168.57.%" IDENTIFIED BY "vagrant_repl"'
/usr/bin/mysql -uroot -ss -e 'CHANGE MASTER TO MASTER_HOST="192.168.57.202", MASTER_USER="repl", MASTER_PASSWORD="vagrant_repl"'
Expand Down
2 changes: 1 addition & 1 deletion vagrant/db1-my.cnf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
server_id=1
log_bin
log-slave-updates

[mysqld_safe]
log-error=/var/log/mysqld.log
Expand Down
16 changes: 13 additions & 3 deletions vagrant/db2-build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
sudo rm -rf /etc/my.cnf
sudo cp /orchestrator/vagrant/db2-my.cnf /etc/my.cnf
if [[ -e /etc/centos-release ]]; then
sudo rm -rf /etc/my.cnf
sudo cp /orchestrator/vagrant/db2-my.cnf /etc/my.cnf
sudo service mysql start
elif [[ -e /etc/debian_version ]]; then
sudo cp /orchestrator/vagrant/db2-my.cnf /etc/mysql/my.cnf
sudo /etc/init.d/mysql restart

sudo service mysql start
sudo cat <<-EOF >> /root/.my.cnf
[client]
user = root
password = vagrant
EOF
fi

/usr/bin/mysql -uroot -ss -e 'GRANT REPLICATION SLAVE ON *.* TO "repl"@"192.168.57.%" IDENTIFIED BY "vagrant_repl"'
/usr/bin/mysql -uroot -ss -e 'CHANGE MASTER TO MASTER_HOST="192.168.57.201", MASTER_USER="repl", MASTER_PASSWORD="vagrant_repl"'
Expand Down
2 changes: 1 addition & 1 deletion vagrant/db2-my.cnf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
server_id=2
log_bin
log-slave-updates

[mysqld_safe]
log-error=/var/log/mysqld.log
Expand Down
16 changes: 13 additions & 3 deletions vagrant/db3-build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
sudo rm -rf /etc/my.cnf
sudo cp /orchestrator/vagrant/db3-my.cnf /etc/my.cnf
if [[ -e /etc/centos-release ]]; then
sudo rm -rf /etc/my.cnf
sudo cp /orchestrator/vagrant/db3-my.cnf /etc/my.cnf
sudo service mysql start
elif [[ -e /etc/debian_version ]]; then
sudo cp /orchestrator/vagrant/db3-my.cnf /etc/mysql/my.cnf
sudo /etc/init.d/mysql restart

sudo service mysql start
sudo cat <<-EOF >> /root/.my.cnf
[client]
user = root
password = vagrant
EOF
fi

/usr/bin/mysql -uroot -ss -e 'GRANT REPLICATION SLAVE ON *.* TO "repl"@"192.168.57.%" IDENTIFIED BY "vagrant_repl"'
/usr/bin/mysql -uroot -ss -e 'CHANGE MASTER TO MASTER_HOST="192.168.57.201", MASTER_USER="repl", MASTER_PASSWORD="vagrant_repl"'
Expand Down
2 changes: 1 addition & 1 deletion vagrant/db3-my.cnf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
server_id=3
log_bin
log-slave-updates

[mysqld_safe]
log-error=/var/log/mysqld.log
Expand Down
16 changes: 13 additions & 3 deletions vagrant/db4-build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
sudo rm -rf /etc/my.cnf
sudo cp /orchestrator/vagrant/db4-my.cnf /etc/my.cnf
if [[ -e /etc/centos-release ]]; then
sudo rm -rf /etc/my.cnf
sudo cp /orchestrator/vagrant/db4-my.cnf /etc/my.cnf
sudo service mysql start
elif [[ -e /etc/debian_version ]]; then
sudo cp /orchestrator/vagrant/db4-my.cnf /etc/mysql/my.cnf
sudo /etc/init.d/mysql restart

sudo service mysql start
sudo cat <<-EOF >> /root/.my.cnf
[client]
user = root
password = vagrant
EOF
fi

/usr/bin/mysql -uroot -ss -e 'GRANT REPLICATION SLAVE ON *.* TO "repl"@"192.168.57.%" IDENTIFIED BY "vagrant_repl"'
/usr/bin/mysql -uroot -ss -e 'CHANGE MASTER TO MASTER_HOST="192.168.57.202", MASTER_USER="repl", MASTER_PASSWORD="vagrant_repl"'
Expand Down
2 changes: 1 addition & 1 deletion vagrant/db4-my.cnf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
server_id=4
log_bin
log-slave-updates

[mysqld_safe]
log-error=/var/log/mysqld.log
Expand Down

0 comments on commit 882b34f

Please sign in to comment.