Line 1: |
Line 1: |
| ==Install mariadb 'alongside' mysql== | | ==Install mariadb 'alongside' mysql== |
| + | MariaDB is a drop in place replacement for MySQL, but you can also install it alongside MySQL. |
| + | |
| + | Installing another SQL database server 'alongside' the built-in SME MySQL server allows a SME admin to use web apps that are incompatible with the Centos/SME version of MySQL without making potentially destabilizing changes to core server components. |
| + | |
| + | MariaDB or MySQL can both be installed in an alongside or side-by-side configuration, but MariaDB maintains binary executables compatible with CentOS 5 & 6 and MySQL does not (at least, I could not find any). |
| + | |
| ===Installation=== | | ===Installation=== |
− | These installation notes are based on the notes from From: https://mariadb.com/kb/en/installing-mariadb-alongside-mysql/ | + | These installation notes are taken from https://mariadb.com/kb/en/installing-mariadb-alongside-mysql/ |
| + | |
| + | IMPORTANT: Do not use yum for an 'alongside' ('side-by-side') installation of mariadb. |
| | | |
− | Yum cannot be used for a 'side-by-side' installation (where mysql is left in place and mariadb is run as a separate service).
| |
| ====Create service account==== | | ====Create service account==== |
| Create a user named '''mariadb''' in server-manager. This user account will be used by mariadb when running, and does not need to have a password set. | | Create a user named '''mariadb''' in server-manager. This user account will be used by mariadb when running, and does not need to have a password set. |
| + | |
| + | SME will create a group of the same name automatically. |
| | | |
| ====Download MariaDB and extract into /opt==== | | ====Download MariaDB and extract into /opt==== |
| | | |
− | <nowiki>mkdir -p addons | + | <nowiki>mkdir -p ~/addons |
− | cd addons | + | cd ~/addons |
| RELEASE=5.5.34 | | RELEASE=5.5.34 |
| wget https://downloads.mariadb.org/interstitial/mariadb-$RELEASE/kvm-bintar-hardy-x86/mariadb-$RELEASE-linux-i686.tar.gz/from/http://mirror.jmu.edu/pub/mariadb | | wget https://downloads.mariadb.org/interstitial/mariadb-$RELEASE/kvm-bintar-hardy-x86/mariadb-$RELEASE-linux-i686.tar.gz/from/http://mirror.jmu.edu/pub/mariadb |
Line 23: |
Line 32: |
| mkdir mariadb-data | | mkdir mariadb-data |
| # | | # |
| + | mkdir -p /var/run/mariadb</nowiki> |
| + | |
| + | ====Setup my.cnf and init.d==== |
| + | '''Important''': On a SME server, 'pid-file' must be specified in /opt/mariadb-data/my.cnf to override the SME default value in /etc/my.cnf |
| + | |
| + | '''/opt/mariadb-data/my.cnf''' |
| + | <nowiki>'cp' -f /opt/mariadb/support-files/my-medium.cnf /opt/mariadb-data/my.cnf |
| + | sed -i -e '/^port.*3306$/ s/= 3306/= 3307/' /opt/mariadb-data/my.cnf |
| + | sed -i -e '/^socket.*= \/tmp\/mysql.sock/ s~= /tmp/mysql.sock~= /opt/mariadb-data/mariadb.sock~' /opt/mariadb-data/my.cnf |
| + | # |
| + | BASEDIR='basedir\t\t= /opt/mariadb' |
| + | DATADIR='datadir\t\t= /opt/mariadb-data' |
| + | USER='user\t\t= mariadb' |
| + | PIDFILE='pid-file\t= /var/run/mariadb/mariadb.pid' |
| + | sed -i -e "/^\[mysqld\]$/ s~\[mysqld\]~\[mysqld\]\n$DATADIR\n$BASEDIR\n$USER\n$PIDFILE~" /opt/mariadb-data/my.cnf</nowiki> |
| + | Note: The last 'sed' command will add lines for basedir, datadir, user, and pid into my.cnf every time it is run, even if these lines already exist. |
| + | |
| + | '''/etc/rc.d/init.d/mariadb''' |
| + | <nowiki>'cp' -f /opt/mariadb/support-files/mysql.server /etc/rc.d/init.d/mariadb |
| + | sed -i "s~^# Provides: mysql$~# Provides: mariadb~" /etc/rc.d/init.d/mariadb |
| + | sed -i "s~^basedir=$~basedir=/opt/mariadb~" /etc/rc.d/init.d/mariadb |
| + | sed -i "s~^datadir=$~datadir=/opt/mariadb-data~" /etc/rc.d/init.d/mariadb |
| + | sed -i "s~lockdir/mysql~lockdir/mariadb~" /etc/rc.d/init.d/mariadb |
| + | sed -i "s~bindir/mysqld_safe\ --datadir~bindir/mysqld_safe\ --defaults-file=/opt/mariadb-data/my.cnf\ --datadir~" /etc/rc.d/init.d/mariadb</nowiki> |
| + | |
| + | ====file and folder ownership==== |
| + | <nowiki>RELEASE=5.5.34 |
| + | chown -R mariadb:mariadb mariadb-data mariadb mariadb-$RELEASE-linux-i686 |
| + | chown mariadb:mariadb /var/run/mariadb</nowiki> |
| + | |
| + | ====Initialize Environment==== |
| + | |
| + | <nowiki>cd /opt/mariadb |
| + | scripts/mysql_install_db --defaults-file=/opt/mariadb-data/my.cnf</nowiki> |
| + | |
| + | ====Configure to start at boot==== |
| + | <nowiki>cd /etc/init.d |
| + | chkconfig --add mariadb |
| + | chkconfig --levels 3 mariadb on |
| + | # SME Server uses runlevel 7... |
| + | cp /etc/rc3.d/S64mariadb /etc/rc7.d</nowiki> |
| | | |
| | | |
− | ====Raw notes on mariadb installation==== | + | ====Raw notes==== |
| <nowiki> | | <nowiki> |
| ##################################################################################### | | ##################################################################################### |