Skip to content

Commit

Permalink
Update to include ubuntu compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
gtowey committed Dec 8, 2017
1 parent bba9016 commit 98f685a
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 42 deletions.
5 changes: 2 additions & 3 deletions vagrant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ Orchestrator's Vagrant defaults to installing five (5) CentOS 6.6 boxes in the f
db1<->db2
| |
v v
db3 db4
db3 db4
```

It is possible to override what gets installed by the use of environmental variables:

```
VAGRANT_SERVER_URL defaults to 'https://atlas.hashicorp.com'
VAGRANT_DEFAULT_PROVIDER defaults to 'virtualbox'
VAGRANT_BOX defaults to 'nrel/CentOS-6.6-x86_64
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.
Expand Down Expand Up @@ -89,4 +89,3 @@ TO DO
- Support other MySQL's (5.5, 5.7, MariaDB)
- Support customizable replication configurations
- Better `my.cnf` templates

19 changes: 15 additions & 4 deletions vagrant/admin-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@

# Install orchestrator
rpm -i /tmp/orchestrator-release/orchestrator*.rpm
/sbin/chkconfig orchestrator on
cp /usr/local/orchestrator/orchestrator-sample.conf.json /etc/orchestrator.conf.json
/sbin/service orchestrator start

if [[ -e /etc/redhat-release ]]; then

/sbin/chkconfig orchestrator on
cp /usr/local/orchestrator/orchestrator-sample.conf.json /etc/orchestrator.conf.json
/sbin/service orchestrator start

elif [[ -e /etc/debian_version ]]; then

update-rc.d orchestrator defaults
cp /usr/local/orchestrator/orchestrator-sample.conf.json /etc/orchestrator.conf.json
/usr/sbin/service orchestrator start

fi

echo '* * * * * root /usr/bin/orchestrator -c discover -i db1' > /etc/cron.d/orchestrator-discovery

# Discover instances
/usr/bin/orchestrator -c discover -i localhost
/usr/bin/orchestrator -c discover -i localhost
66 changes: 54 additions & 12 deletions vagrant/base-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,12 @@ if [[ -e /etc/redhat-release ]]; then
fi

/sbin/service mysql start
cat <<-EOF | mysql -u root
CREATE DATABASE IF NOT EXISTS orchestrator;
GRANT ALL PRIVILEGES ON orchestrator.* TO 'orc_client_user'@'%' IDENTIFIED BY 'orc_client_password';
GRANT SUPER, PROCESS, REPLICATION SLAVE, RELOAD ON *.* TO 'orc_client_user'@'%';
GRANT ALL PRIVILEGES ON orchestrator.* TO 'orc_client_user'@'localhost' IDENTIFIED BY 'orc_client_password';
GRANT SUPER, PROCESS, REPLICATION SLAVE, RELOAD ON *.* TO 'orc_client_user'@'localhost';
GRANT ALL PRIVILEGES ON orchestrator.* TO 'orc_server_user'@'localhost' IDENTIFIED BY 'orc_server_password';
EOF

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
Expand All @@ -54,20 +48,68 @@ elif [[ -e /etc/debian_version ]]; then
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
export 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
#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

# add the mysql community packages
# from https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/
sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 5072E1F5
export CODENAME=$(/usr/bin/lsb_release -c | cut -f2)
echo "deb http://repo.mysql.com/apt/ubuntu/ ${CODENAME} mysql-5.7" | sudo tee /etc/apt/sources.list.d/mysql.list
apt-get -y update
echo "mysql-community-server mysql-community-server/root-pass password vagrant" | sudo debconf-set-selections
echo "mysql-community-server mysql-community-server/re-root-pass password vagrant" | sudo debconf-set-selections
apt-get -y --force-yes install mysql-server
chmod a+w /var/log

# All the project dependencies to build
sudo apt-get -y install ruby-dev gcc git rubygems rpm jq
gem install fpm
# Jump though some hoops to get a non-decrepit version of golang
sudo apt-get remove golang-go
cd /tmp
wget --quiet "https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-amd64.tar.gz"
sudo tar -C /usr/local -xzf go1.9.2.linux-amd64.tar.gz
echo "PATH=$PATH:/usr/local/go/bin" | sudo tee -a /etc/environment
export PATH="PATH=$PATH:/usr/local/go/bin"

# newest versions of java aren't compatable with the installed version of ruby (1.8.7)
gem install json --version 1.8.6
gem install fpm --version 1.4

# Build orchestrator and orchestrator agent
mkdir -p /home/vagrant/go/{bin,pkg,src} /tmp/orchestrator-release
mkdir -p /home/vagrant/go/src/github.com/github/orchestrator
mount --bind /orchestrator /home/vagrant/go/src/github.com/github/orchestrator

# Build Orchestrator
export GOPATH=/home/vagrant/go
export GO15VENDOREXPERIMENT=1
cd ${GOPATH}/src/github.com/github/orchestrator
/usr/local/go/bin/go get ./...
${GOPATH}/src/github.com/github/orchestrator/build.sh
chown -R vagrant.vagrant /home/vagrant /tmp/orchestrator-release


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

update-rc.d mysql defaults
/usr/sbin/service mysql start
fi

mysql -uroot -pvagrant -e "grant all on *.* to 'root'@'localhost' identified by ''"
cat <<-EOF | mysql -u root
CREATE DATABASE IF NOT EXISTS orchestrator;
GRANT ALL PRIVILEGES ON orchestrator.* TO 'orc_client_user'@'%' IDENTIFIED BY 'orc_client_password';
GRANT SUPER, PROCESS, REPLICATION SLAVE, RELOAD ON *.* TO 'orc_client_user'@'%';
GRANT ALL PRIVILEGES ON orchestrator.* TO 'orc_client_user'@'localhost' IDENTIFIED BY 'orc_client_password';
GRANT SUPER, PROCESS, REPLICATION SLAVE, RELOAD ON *.* TO 'orc_client_user'@'localhost';
GRANT ALL PRIVILEGES ON orchestrator.* TO 'orc_server_user'@'localhost' IDENTIFIED BY 'orc_server_password';
EOF

cat <<-EOF >> /etc/hosts
192.168.57.200 admin
192.168.57.201 db1
Expand Down
3 changes: 2 additions & 1 deletion vagrant/db1-build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
if [[ -e /etc/debian_version ]]; then
sudo /usr/sbin/service mysql stop
sudo cp /orchestrator/vagrant/db1-my.cnf /etc/mysql/my.cnf
sudo /etc/init.d/mysql restart
sudo /usr/sbin/service mysql start
fi

/usr/bin/mysql -uroot -ss -e 'GRANT REPLICATION SLAVE ON *.* TO "repl"@"192.168.57.%" IDENTIFIED BY "vagrant_repl"'
Expand Down
5 changes: 1 addition & 4 deletions vagrant/db1-my.cnf
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
[mysqld]
datadir=/var/lib/mysql
user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
server_id=1
log_bin
log-slave-updates
report-host=db1

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
5 changes: 3 additions & 2 deletions vagrant/db2-build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
if [[ -e /etc/debian_version ]]; then
sudo cp /orchestrator/vagrant/db1-my.cnf /etc/mysql/my.cnf
sudo /etc/init.d/mysql restart
sudo /usr/sbin/service mysql stop
sudo cp /orchestrator/vagrant/db2-my.cnf /etc/mysql/my.cnf
sudo /usr/sbin/service mysql start
fi

/usr/bin/mysql -uroot -ss -e 'GRANT REPLICATION SLAVE ON *.* TO "repl"@"192.168.57.%" IDENTIFIED BY "vagrant_repl"'
Expand Down
4 changes: 0 additions & 4 deletions vagrant/db2-my.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,3 @@ server_id=2
log_bin
log-slave-updates
report-host=db2

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
6 changes: 4 additions & 2 deletions vagrant/db3-build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
if [[ -e /etc/debian_version ]]; then
sudo cp /orchestrator/vagrant/db1-my.cnf /etc/mysql/my.cnf
sudo /etc/init.d/mysql restart
sudo /usr/sbin/service mysql stop
sudo cp /orchestrator/vagrant/db3-my.cnf /etc/mysql/my.cnf
sudo /usr/sbin/service mysql start
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", MASTER_CONNECT_RETRY=10, MASTER_RETRY_COUNT=36'
/usr/bin/mysql -uroot -ss -e 'START SLAVE'
4 changes: 0 additions & 4 deletions vagrant/db3-my.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,3 @@ server_id=3
log_bin
log-slave-updates
report-host=db3

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
6 changes: 4 additions & 2 deletions vagrant/db4-build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
if [[ -e /etc/debian_version ]]; then
sudo cp /orchestrator/vagrant/db1-my.cnf /etc/mysql/my.cnf
sudo /etc/init.d/mysql restart
sudo /usr/sbin/service mysql stop
sudo cp /orchestrator/vagrant/db4-my.cnf /etc/mysql/my.cnf
sudo /usr/sbin/service mysql start
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", MASTER_CONNECT_RETRY=10, MASTER_RETRY_COUNT=36'
/usr/bin/mysql -uroot -ss -e 'START SLAVE'
4 changes: 0 additions & 4 deletions vagrant/db4-my.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,3 @@ server_id=4
log_bin
log-slave-updates
report-host=db4

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

0 comments on commit 98f685a

Please sign in to comment.