Saturday, May 4, 2013

Building from Source MySQL :: MariaDB :: Percona

It is possible to run more than one MySQL server on the same server. At times people might like to install another version of a database on the same hardware for testing purposes, as well as evaluations. 
Installing the databases from source and custom installations for each is easier than it might sound to some.  I would suggest to review MySQL Sandbox  first though, because it allows for evaluations and testing to be done very quickly and easily. However, installing from source worked out better for me when I did some comparisons.  Below is the process I used. I will be looking to build out future blog posts with these databases once I tune then configurations. 



This is the default information from mysql.com. I already had MySQL installed so I did not execute the following but I wanted this here for reference.  You can compare these steps to the MySQL, MariaDB and Percona source installations below too see how I updated the default steps in order to get all three versions of the database running on the same box. (No production value here was done just to test the process.)

# Preconfiguration setup
shell> groupadd mysql
shell> useradd -r -g mysql mysql

# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .
shell> make
shell> make install
# End of source-build specific instructions

# Postinstallation setup
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data

# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &

# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server



If you prefer to use the mysql.server script for start and stop make sure to review and edit accordingly.
# Preconfiguration setup
shell> groupadd oracle_mysql
shell> useradd -r -g 
oracle_mysql oracle_mysql

# Beginning of source-build specific instructions
shell> tar zxvf MariaDB
-VERSION.tar.gz
shell> cd MySQL-VERSION
shell> cmake .
shell> make
shell> make install DESTDIR="
/usr/local/
oracle_mysql-tmp"
# End of source-build specific instructions

I do not like the results
-- Installing: /usr/local/oracle_mysql-tmp/usr/local/mysql/
If DESTDIR is should install into that location not start with user under that location. This is a MySQL original issue as it does this with all versions of MySQL.

# Fix the odd/bug setup
shell> cd /usr/local/
oracle_mysql-tmp
shell> mv usr/local/mysql/ ../oracle_mysql ; 
shell> cd ../; # rm -Rf oracle_mysql-tmp

# Postinstallation setup
shell> cd /usr/local/oracle_mysql
shell> chown -R 
oracle_mysql .
shell> chgrp -R oracle_mysql .

# Next command is optional
shell> cp support-files/my-small.cnf /etc/
oracle_mysql.cnf
shell> vi /etc/oracle_mysql.cnf

       port            = 3309

       socket          = /tmp/oracle_mysql.sock

shell> scripts/mysql_install_db --defaults-file=/etc/oracle_mysql.cnf --basedir=/usr/local/oracle_mysql --skip-name-resolve --datadir=/var/lib/oracle_mysql --user=oracle_mysql
shell> chown -R oracle_mysql /var/lib/oracle_mysql/*

shell> 
# bin/mysqld_safe --defaults-file=/etc/oracle_mysql.cnf --user=oracle_mysql  --datadir=/var/lib/oracle_mysql/ --port=3309 & 


shell> bin/mysql --port=3309 --socket=/tmp/oracle_mysql.sock 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.31 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.








# Preconfiguration setup
shell> groupadd mariadb
shell> useradd -r -g 
mariadb mariadb

# Beginning of source-build specific instructions
shell> tar zxvf MariaDB
-VERSION.tar.gz
shell> cd MariaDB-VERSION
shell> cmake .
shell> make
shell> make install DESTDIR="
/usr/local/mariadb-tmp"
# End of source-build specific instructions

I do not like the results
-- Installing: /usr/local/mariadb-tmp/usr/local/mysql/
If DESTDIR is should install into that location not start with user under that location. This is a MySQL original issue as it does this with all versions of MySQL.

# Fix the odd/bug setup
shell> cd /usr/local/
mariadb-tmp
shell> mv usr/local/mysql/ ../mariadb ; 
shell> cd ../; # rm -Rf mariadb-tmp

# Postinstallation setup
shell> cd /usr/local/mariadb
shell> chown -R 
mariadb .
shell> chgrp -R mariadb .


# Next command is optional
shell> cp support-files/my-small.cnf /etc/
mariadb.cnf

shell> vi /etc/mariadb.cnf

       port            = 3308

       socket          = /tmp/mariadb.sock

shell> scripts/mysql_install_db --defaults-file=/etc/mariadb.cnf --basedir=/usr/local/mariadb --skip-name-resolve --datadir=/var/lib/mariadb --user=mariadb
shell> chown -R mariadb /var/lib/mariadb/*

shell> 
# bin/mysqld_safe --defaults-file=/etc/mariadb.cnf --user=mariadb  --datadir=/var/lib/mariadb/ --port=3308 & 


shell> bin/mysql --port=3308 --socket=/tmp/mariadb.sock 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.30-MariaDB Source distribution

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.






# Preconfiguration setup
shell> groupadd percona
shell> useradd -r -g 
percona percona

# Beginning of source-build specific instructions
shell> tar zxvf Percona-Server
-VERSION.tar.gz
shell> cd Percona-Server-VERSION
shell> cmake .
shell> make
shell> make install DESTDIR="
/usr/local/percona-tmp"
# End of source-build specific instructions

I do not like the results

-- Installing: /usr/local/percona-tmp/usr/local/mysql/

If DESTDIR is should install into that location not start with user under that location. This is a MySQL original issue as it does this with all versions of MySQL.

# Fix the odd/bug setup
shell> cd /usr/local/percona-tmp

shell> mv usr/local/mysql/ ../percona ; 

shell> cd ../; # rm -Rf percona-tmp



# Next command is optional
shell> cp support-files/my-small.cnf /etc/
percona.cnf

shell> vi /etc/percona.cnf

       port            = 3307

       socket          = /tmp/percona.sock




# Postinstallation setup
shell> cd /usr/local/percona
shell> chown -R 
percona .
shell> chgrp -R percona .

shell> scripts/mysql_install_db --defaults-file=/etc/percona.cnf --basedir=/usr/local/percona --skip-name-resolve --datadir=/var/lib/percona --user=percona 
shell> chown -R percona /var/lib/percona/*
shell> # bin/mysqld_safe --defaults-file=/etc/percona.cnf --user=percona  --datadir=/var/lib/percona/ --port=3307 



shell> bin/mysql --port=3307 --socket=/tmp/percona.sock 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.30 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.




Now I have access to all 3 flavors or MySQL. 
For easy client access I added this to my .bashrc file:

  • alias percona='/usr/local/percona/bin/mysql --port=3307 --socket=/tmp/percona.sock'
  • alias oracle_mysql='/usr/local/oracle_mysql/bin/mysql --port=3309 --socket=/tmp/oracle_mysql.sock'
  • alias maria='/usr/local/mariadb/bin/mysql --port=3308 --socket=/tmp/mariadb.sock'