Build on macOS

Instructions for building Vitess on your machine for testing and development purposes

If you run into issues or have questions, we recommend posting in our Slack channel, click the Slack icon in the top right to join. This is a very active community forum and a great place to interact with other users.

The following has been verified to work on macOS Mojave. If you are new to Vitess, it is recommended to start with the local install guide instead.

Install Dependencies

Install Xcode

Install Xcode.

Install Homebrew and Dependencies

Install Homebrew. From here you should be able to install:

  1. brew install automake git curl wget mysql@5.7

Add mysql@5.7 to your PATH:

  1. echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile

Download and install Golang 1.17. For example, at writing:

  1. curl -LO https://golang.org/dl/go1.17.darwin-amd64.pkg
  2. sudo installer -pkg go1.17.darwin-amd64.pkg -target /

Do not install etcd via brew otherwise it will not be the version that is supported. Let it be installed when running make build.

Do not set up MySQL or etcd to restart at login.

Build Vitess

Navigate to the directory where you want to download the Vitess source code and clone the Vitess GitHub repo:

  1. cd ~
  2. git clone https://github.com/vitessio/vitess.git
  3. cd vitess

Set environment variables that Vitess will require. It is recommended to put these in your ~/.bash_profile file:

  1. # Vitess binaries
  2. export PATH=~/vitess/bin:${PATH}

Build Vitess:

  1. make build

Testing your Binaries

The unit tests require that you first install a Java runtime. This is required for running ZooKeeper tests:

  1. brew tap adoptopenjdk/openjdk
  2. brew install adoptopenjdk8
  3. brew info java

You will also need to install ant and maven:

  1. brew install ant maven

You can then install additional components from make tools. If your machine requires a proxy to access the Internet, you will need to set the usual environment variables (e.g. http_proxy, https_proxy, no_proxy) first:

  1. make tools
  2. make unit_test

In addition to running tests, you can try running the local example.

Common Build Issues

Key Already Exists

This error is because etcd was not cleaned up from the previous run of the example. You can manually fix this by running ./401_teardown.sh, removing vtdataroot and then starting again:

  1. Error: 105: Key already exists (/vitess/zone1) [6]
  2. Error: 105: Key already exists (/vitess/global) [6]

/tmp/mysql.sock Already In Use

This error occurs because mysql is serving on the same port that vttgate requires. To solve this issue stop mysql service. If you have installed mysql via brew as specified above you should run:

  1. brew services stop mysql@5.7