Hi,
The easiest way is to use the binary installer, since the mysql modules are already come with it.
If you decide to install it from source or packet-manager you will have to compile them "yourself"
Sorry for my bad text format :(
From Source:
// lets define the hostname
$ sudo sh -c 'echo "node1.domain.com" > /etc/hostname'
$ sudo hostname -F /etc/hostname
$ sudo sh -c 'ifconfig | grep Bcast | cut -d ":" -f 2 | sed s/Bcast/node1.domain.com/g >> /etc/hosts'
// lets install some dependencies
$ sudo apt-get update && sudo apt-get -y dist-upgrade && sudo reboot now
$ sudo apt-get install erlang subversion gcc make libexpat1-dev mysql-client-core-5.5 zlib1g-dev libssl-dev
$ wget http://www.process-one.net/downloads/ejabberd/2.1.13/ejabberd-2.1.13.tgz
$ wget https://raw.github.com/peterromfeldhk/ejabberd/master/ejabberd.init
$ sudo mv ejabberd.init /etc/init.d/ejabberd
$ sudo chmod +x !$
// create db, im using aws rds
// you may want to restrict the grants more, i am new to ejabberd and dont know what the mods all need
$ mysql -uroot -h yourhost.db.com -p
> create database ejabberd;
> CREATE USER 'ejabberd'@'10.0.0.0/255.0.0.0' IDENTIFIED BY 'pwgen32';
> GRANT SELECT,INSERT,UPDATE,CREATE,INDEX,ALTER ON ejabberd.* TO 'ejabberd'@'10.0.0.0/255.0.0.0';
$ wget https://gist.github.com/jrbl/5783688/raw/d01641a1da0fee91c459909371241e0ec25155d8/ejabberd_setup.sql
$ mysql -uroot -h yourserver.db.com -ppwgen32 ejabberd < ejabberd_setup.sql
// create system-user for ejabberd
$ sudo groupadd -r ejabberd
$ sudo useradd -g ejabberd -r ejabberd
$ tar -xf ejabberd-2.1.13.tgz
$ cd ejabberd-2.1.13/src/
// configure with mysql, you can type --help for additional infos
# ./configure --enable-user=ejabberd --enable-odbc
# make
# make install
// we want ejabberd to start at boot
$ sudo vim /etc/passwd
:%s/home\/ejabberd/var\/lib\/ejabberd/g
$ sudo chgrp -R ejabberd
/var/lib/ejabberd
$ sudo chgrp -R ejabberd /lib/ejabberd
$ sudo chown ejabberd:ejabberd
/var/lib/ejabberd/.erlang.cookie
$ sudo chmod 400 !$
$ sudo chmod 755 /sbin/ejabberdctl
$ sudo update-rc.d ejabberd defaults
// basic ejabberd configuration with mysql
// you can also use sed or just change it manually, i like vim
$ sudo vim /etc/ejabberd/ejabberd.cfg
:%s/{hosts\,\ \[\"localhost\"\]}\./{hosts\,\ \[\"domain.com\"\]}\.
:%s/mod_last/mod_last_odbc/g|%s/mod_offline/mod_offline_odbc/g
:%s/mod_privacy/mod_privacy_odbc/g|%s/mod_private/mod_private_odbc/g
:%s/mod_pubsub/mod_pubsub_odbc/g|%s/mod_roster/mod_roster_odbc/g|%s/mod_vcard/mod_vcard_odbc/g
:%s/%%{auth_method, odbc}./{auth_method, odbc}./g
:%s/{auth_method, internal}./%%{auth_method, internal}./g
:%s/%%{odbc_server,\ {mysql,\ \"server\",\ \"database\",\ \"username\",\ \"password\"}}./{odbc_server,\ {mysql,\ \"yourserver.db.com\",\ \"ejabberd\",\ \"ejabberd\",\ \"pwgen32\"}}.
$ sudo sh -c "i=`ifconfig | grep Bcast | cut -d ":" -f 2 | sed s/Bcast//g | sed 's/\./\,/g'`; sed -i 's/INET_DIST_INTERFACE={127\.0\.0\.1}/INET_DIST_INTERFACE={$i}/g' /etc/ejabberd/ejabberdctl.cfg ; sed -i 's/\ \ }/}/g' /etc/ejabberd/ejabberdctl.cfg
$ sudo sh -c "echo 'ERLANG_NODE=ejabberd@node1.domain.com' >> /etc/ejabberd/ejabberdctl.cfg"
// lets get the erlang-mysql drivers
$ svn co https://svn.process-one.net/ejabberd-modules ejabberd-modules
$ cd ejabberd-modules/mysql/trunk
$ ./build.sh
$ sudo mv ebin/mysql* /lib/ejabberd/ebin/
// now we want no plain password
// download rebar for erlsha2
$ git clone git://github.com/rebar/rebar.git
$ cd rebar/
$ ./bootstrap
$ sudo mv rebar /usr/bin/
$ sudo cp rebar.config /usr/bin/
$ sudo chmod +x /usr/bin/rebar
$ rebar -V
// erlsha2
$ svn co https://github.com/vinoski/erlsha2 erlsha2
$ cd erlsha2/trunk/
$ rebar get-deps compile
$ cp ebin/*.beam /lib/ejabberd/ebin/
$ cp ebin/*.app /lib/ejabberd/ebin/
// get mysql-password-hashing
$ svn co https://github.com/peterromfeldhk/ejabberd passhash
$ cd passhash/mysql-password-hashing/
$ ./build.sh
$ sudo cp ebin/*.beam /lib/ejabberd/ebin/
$ sudo sed -i "s/%%{auth_password_format, scram}./{auth_password_format, scram}./g" /etc/ejabberd/ejabberd.cfg
// now you can clean up, then reboot and test if everything works
// if you have problems, you should change debug to 5 in ejabberd.cfg and check your logs :)
For clustering you can take a look here:
easy-ejabberd-clustering-guide-mnesia-mysql
he also provides a link at bottom for master-master cluster
Hope it helps someone, enjoy ;)