You are here

MyEnv Installation Guide

This article will cover the installation of the MyEnv, a tool of FromDual.

Why MyEnv?

MyEnv is a bundle of scripts to run multiple MySQL, Percona Server or MariaDB database instances on the same server with ease. You can even run multiple database instances with different binary versions.


Requirements

  • A working Linux
  • PHP
  • A dedicated user

CentOS

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

Ubuntu

  • php5-cli
  • php5-mysql

SLES

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

Text within one of those boxes is command line input or output.

Preparation

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

groupadd mysql
useradd -g mysql -d /home/mysql 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 722 /etc/myenv

Switch the user ...

su - mysql

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

mkdir ~/product
mkdir ~/data
mkdir ~/download

  • In product you want to place the unpacked binaries, because that's where myenv goes looking for them by default.
  • download is intended to be used as landing zone for downloads, such as fresh binaries.
  • data usually contains the datadir of the instances.

Download

Now download MyEnv:

cd ~/download
wget https://support.fromdual.com/admin/download/myenv-latest.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-latest.tar.gz
ln -s myenv-x.y/ myenv

If you want to create the link is up to you, but it makes writing easier.

In the file /etc/php5/cli/php.ini, change the setting variables_order to EGPCS.

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