Build on CentOS

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

Build on macOS >>

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 CentOS 7. If you are new to Vitess, it is recommended to start with the local install guide instead.

Install Dependencies

Install Go 1.15+

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

  1. curl -LO https://golang.org/dl/go1.15.6.linux-amd64.tar.gz
  2. sudo tar -C /usr/local -xzf go1.15.6.linux-amd64.tar.gz

Make sure to add go to your bashrc:

  1. # Additions to ~/.bashrc file
  2. # Add go PATH
  3. export PATH=$PATH:/usr/local/go/bin
  4. # Add GOROOT
  5. export GOROOT=/usr/local/go/
  6. # Add GOPATH
  7. export GOPATH=/home/<user>/go

Packages from CentOS repos

The MariaDB version included with CentOS 7 (5.5) is not supported by Vitess. First install the MySQL 5.7 repository from Oracle:

  1. sudo yum localinstall -y https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
  2. sudo yum install -y mysql-community-server

Install additional dependencies required to build and run Vitess:

  1. sudo yum install -y make unzip g++ etcd curl git wget

Notes:

  • We will be using etcd as the topology service. The command make tools can also install Zookeeper or Consul for you, which requires additional dependencies.
  • Vitess currently has some additional tests written in Python, but we will be skipping this step for simplicity.

Disable SELinux

SELinux will not allow Vitess to launch MySQL in any data directory by default. You will need to disable it:

  1. sudo setenforce 0

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 .bashrc:

  1. # Additions to ~/.bashrc file
  2. #VTDATAROOT
  3. export VTDATAROOT=/tmp/vtdataroot
  4. # Vitess binaries
  5. export PATH=~/vitess/bin:${PATH}

Build Vitess:

  1. make build

Testing your Binaries

The unit tests require the following additional packages:

  1. sudo yum install -y ant maven zip gcc

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]

MySQL Fails to Initialize

This error is most likely the result of SELinux enabled:

  1. 1027 18:28:23.462926 19486 mysqld.go:734] mysqld --initialize-insecure failed: /usr/sbin/mysqld: exit status 1, output: mysqld: [ERROR] Failed to open required defaults file: /home/morgo/vitess/vtdataroot/vt_0000000102/my.cnf
  2. mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
  3. could not stat mysql error log (/home/morgo/vitess/vtdataroot/vt_0000000102/error.log): stat /home/morgo/vitess/vtdataroot/vt_0000000102/error.log: no such file or directory
  4. E1027 18:28:23.464117 19486 mysqlctl.go:254] failed init mysql: /usr/sbin/mysqld: exit status 1, output: mysqld: [ERROR] Failed to open required defaults file: /home/morgo/vitess/vtdataroot/vt_0000000102/my.cnf
  5. mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
  6. E1027 18:28:23.464780 19483 mysqld.go:734] mysqld --initialize-insecure failed: /usr/sbin/mysqld: exit status 1, output: mysqld: [ERROR] Failed to open required defaults file: /home/morgo/vitess/vtdataroot/vt_0000000101/my.cnf
  7. mysqld: [ERROR] Fatal error in defaults handling. Program aborted!

Build on macOS >>