You are here

MyEnv Installation Guide

This article will cover the installation of MyEnv, the MySQL and MariaDB environment of FromDual.

Why MyEnv?

MyEnv is a program to run multiple MySQL, MariaDB, Percona Server or Galera Cluster database instances on ONE server with ease. You can even run multiple database instances with different binary versions.

Requirements

  • A working Linux (works best with recent CentOS or Ubuntu)
  • PHP (5.0 to 7.2)
  • A dedicated user (typically mysql)
  • The following packages are required:

CentOS

centos.pngredhat.png

  • php-cli
  • php-mysqli (provided by RPM "php-mysql")
  • php-posix (provided by RPM "php-process")
  • redhat-lsb-core

yum install php-cli php-mysqli php-posix redhat-lsb-core

Ubuntu

ubuntu.png

  • php5-cli
  • php5-mysql

apt-get install php5-cli php5-mysql

or

apt-get install php-cli php-mysql

SLES

suse.png

  • php5-posix
  • php5-pcntl
  • php5-mysql

zypper install php5-posix php5-pcntl php5-mysql

or

zypper install php7-posix php7-pcntl php7-mysql

Preparation

In the file /etc/php5/cli/php.ini or /etc/php/7.0/cli/php.ini (Ubuntu) or /etc/php.ini (CentOS), change the setting variables_order to EGPCS.

Then you have to set up the user and the group:

groupadd mysql
useradd -g mysql -d /home/mysql -m -s /bin/bash mysql

MyEnv will be run as the user mysql, just like any regular mysqld process.

You might want to check, if the home directory of the user mysql was created at the right place. If not, you can use the following commands to create it:

mkdir /home/mysql
chown -R mysql:mysql /home/mysql

Next ist the directory where the MyEnv configuration will be located. DO NOT FORGET to give the mysql user read and write permission for this directory.

mkdir /etc/myenv/
chown -R mysql:mysql /etc/myenv/
chmod 700 /etc/myenv

Switch the user ...

su - mysql

... and create some more folders in his home directory:

mkdir ~/product
mkdir ~/database
mkdir ~/download

  • product is the location of the unpacked binaries. This is the location where MyEnv is looking for them by default.
  • download is intended to be used as landing zone for downloads, such as fresh binary tarballs.
  • data usually contains the datadir of the instances (more precisely instancedir).

Download

Now download MyEnv:

cd ~/download
VERSION="1.3.1"
wget https://support.fromdual.com/admin/download/myenv-${VERSION}.tar.gz

Once the archive has finished downloading, you can move on to the installation.

Installation

To install MyEnv you have to unarchive it. It is recommended to do that in the product directory.

cd ~/product
tar xf ../download/myenv-${VERSION}.tar.gz
ln -s myenv-${VERSION} myenv

Downloading and installing database binary tarball

Before you start configuring MyEnv and a MyEnv controlled database instance it is recommended to first install the binary tar ball of your favourite flavour of MySQL:

For MariaDB:

cd ~/download
wget https://downloads.mariadb.org/f/mariadb-10.2.12/bintar-linux-glibc_214-x86_64/mariadb-10.2.12-linux-glibc_214-x86_64.tar.gz
cd ~/product
tar xf ~/download/mariadb-10.2.12-linux-glibc_214-x86_64.tar.gz
ln -s mariadb-10.2.12-linux-glibc_214-x86_64 mariadb-10.2.12

For MySQL:

cd ~/download
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
cd ~/product
tar xf ~/download/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
ln -s mysql-5.7.21-linux-glibc2.12-x86_64 mysql-5.7.21

Configuration

If you want to configure MyEnv you have to run the following command:

~/product/myenv/bin/installMyEnv.php

After you have issued this command, follow the steps through the setup. If you already have binaries available, you get the possibility to create a new database instance.

Upgrade

This paragraph is for all those who want to upgrade to a newer version.

su - mysql
cd ~/download
wget https://support.fromdual.com/admin/download/myenv-latest.tar.gz
cd ~/product
tar xf ../download/myenv-x.y.tar.gz
unlink myenv
ln -s myenv-x.y myenv

You are basically going to to re-install MyEnv, but with a newer version.

How myenv works

It is always recommended to work as user mysql.

When you login you will see the current status:

Up       : mysqld523 (5.2.3)

Down     : mysqld5115 (5.1.16) mysqld5037 (5.0.37) mysqld4027 (4.0.27)
           mysqld4122 (4.1.22)

mysqld523 (3323)  : cacti mysql test
mysqld5116 (3325)  : cluster_test mysql test
mysqld5037 (3307)  : mysql test
mysqld4027 (3320)  : mysql test
mysqld4122 (3319)  : mysql test FoodMart

mysql@master:~ [mysqld523, 3323]>

Functionality

Following you can find the most important commands for you:

<instance> : Switches to the environment for this instance. For example:
             shell> mysqld5116
u or up    : Lists, which releases are available, which instances are up and
             down and which instance contains which database. For example:
             shell> u
start      : Starts the actual or a specific instance. For example:
             shell> start
             or
             shell> start mysqld5116
stop       : Stops the actual instance or a specific instance. For example:
             shell> stop
             or
             shell> stop mysqld5116
restart    : restarts the actual or a specific instance. For example:
             shell> restart
             or
             shell> restart mysqld5116
V          : print the current MyEnv version
cdh, cdb   : cd to the basedir of this instance.
cdd        : cd to the datadir of this instance.
cdc        : cd to the cluster-directory of this instance.
cde        : cd to the myenv-directory.
cd a b     : cd to a directory with the name where a is substituted by b.
             For example:
             shell> pwd /var/lib/mysql1
             shell> cd 1 2
             shell> pwd /var/lib/mysql2
ll         : ls -l
la         : ls -la

Debugging

To enable debugging, please issue the following command on the command line:

export MYENV_DEBUG=1

To disable the debug mode, use the following command:

unset MYENV_DEBUG

In case you found a bug, please report it here: FromDual bug tracker