Started out by following the instructions here for installing ejabberd on my Mac.
Configure and make:
## Enable flags ensure modules are included to support Riak and Redis
./configure --enable-riak --enable-redis --prefix=$HOME/my-ejabberd
./rebar get-deps
./rebar compile
make && make install
I installed Adium and Spark to test out 2 users sending/receiving messages. You can find a long list of clients here.
Riak KV provides a distributed database architecture, focusing on high-availability. You can read more about why/when to choose Riak here.
I initially followed these steps on Basho's website to get 1 Riak vnode running, however it became difficult to get multiple vnodes running in a cluster.
So, I abandoned that approach and found the riak-dev-cluster repo. I was able to get 5 Riak vnodes up and running in a cluster in under 10 minutes.
Once you have Riak running, you need to add some lines into ejabberd.yml (which can be found in my-ejabberd/etc/ejabberd/
)
Add the following lines to configure the Riak connection:
## Riak
riak_server: "localhost"
riak_port: 11087
For more details, see the Ejabberd docs on Riak configuration.
Then, you have to set the db_type
for individual ejabberd modules to use Riak. I have listed the modules below that are compatible with Riak, out of the box:
modules:
mod_announce: # recommends mod_adhoc
db_type: riak
access: announce
mod_caps:
db_type: riak
mod_last:
db_type: riak
mod_muc:
## host: "conference.@HOST@"
db_type: riak
access: muc
access_create: muc_create
access_persistent: muc_create
access_admin: muc_admin
mod_offline:
db_type: riak
access_max_user_messages: max_user_offline_messages
mod_privacy:
db_type: riak
mod_private:
db_type: riak
mod_roster:
db_type: riak
mod_vcard:
db_type: riak
search: false
Here is a link to the full ejabberd.yml.
Once you start up ejabberd, you should connect your chat clients and write some messages back and forth. Then, you should see buckets created in Riak KV, and values stored in each.
Ejabberd by default uses Mnesia for storing session management data. We prefer to use something a little more "heavy duty" like Redis for storing transient data.
Using Homebrew:
$ brew install redis
Start the Redis server. Then, add some lines into ejabberd.yml (which can be found in my-ejabberd/etc/ejabberd/
)
Add the following lines to configure the Redis connection:
## Redis
## These are all the default values
redis_server: "localhost"
redis_port: 6379
redis_db: 0
Then set the default session management storage to Redis:
## Set session storage type
sm_db_type: redis
For more details, see the Ejabberd docs on Redis configuration.
Start ejabberd with the new configuration.