1 Yesterday I was upgrading my
2 http://www.igniterealtime.org/projects/openfire/[OpenFire] server and thought
3 it might be fun to learn something new and switch to a different server
4 software. After doing some research, I decided upon
5 http://www.ejabberd.im/[ejabberd] since that one seems to be a popular solution
6 (not to mention that specs of course).
7
8 I keep my jabber data in a MySql database and I don't really want to migrate
9 away from that. That being said, I had a really difficult time finding any
10 complete documentation on how to configure an ejabberd server to work with a
11 MySql database. Here's how I did it.
12
13 Firstly, you of course need to grab said bin
14 http://www.process-one.net/en/ejabberd/archive/[here]. Once you have extracted
15 and installed, you'll need to edit your config file (conf/ejabberd.cfg). You'll
16 see a section in the middle (or so) that
17 looks like
18
19 ----
20 %%% ==============
21 %%% AUTHENTICATION
22
23
24 %%
25 %% auth_method: Method used to authenticate the users.
26 %% The default method is the internal.
27 %% If you want to use a different method,
28 %% comment this line and enable the correct ones.
29 %%
30 {auth_method, internal}.
31
32
33 %%
34 %% Authentication using external script
35 %% Make sure the script is executable by ejabberd.
36 %%
37 %%{auth_method, external}.
38 %%{extauth_program, "/path/to/authentication/script"}.
39
40
41 %%
42 %% Authentication using ODBC
43 %% Remember to setup a database in the next section.
44 %%
45 %%{auth_method, odbc}.
46 ----
47
48 Comment out the internal auth method line
49
50 ----
51 %%\{auth_method, internal}.
52 ----
53
54 Now, skip down to the line and uncomment the odbc auth
55 method.
56
57 ----
58 {auth_method, odbc}.
59 ----
60
61 Lastly in the config file, we need to configure our database connection
62 string. Head on down to the following location, uncomment the first
63 odbc_server line and fill in your database connection information.
64
65 ----
66 %%
67 %% MySQL server:
68 %%
69 {odbc_server, {mysql, "MySqlServer", "MySqlDatabase", "MySqlUsername", "MySqlPassword"}}.
70 ----
71
72 It's at this point that you might be thinking to yourself, "...but I don't have
73 a database or tables configured". This is the part where I initially got stuck.
74 All of the documentation I found pointed towards a sql file that could be found
75 in the source code. Other sources indicated that ejabberd needs to be compiled
76 with mysql support for this all to work. Thankfully, this is not the case (as
77 per my experience at least). I can't say this about the deb or the rpm
78 installs, but the gzipped binary at least has this.
79
80 If you go into the install location and navigate on down to
81
82 ----
83 <ejabberd-home>/lib/ejabberd-2.1.8/priv/odbc/mysql.sql
84 ----
85
86 and run the mysql file in there on the database you have created, you will find
87 yourself with a completely empty database structure (but a structure none the
88 less).
89
90 Finally, we have to go back and make a few more simple changes to our conf
91 file. The config file references several modules that store their data to the
92 internal database, unless otherwise specified. We are going to otherwise
93 specify here.
94
95 Crack open that config file again located at conf/ejabberd.cfg Navigate down to
96 the section that looks like the following (I won't put the whole thing in here
97 since it's a big section)
98
99 ----
100 %%% =======
101 %%% MODULES
102
103
104 %%
105 %% Modules enabled in all ejabberd virtual hosts.
106 %%
107 ----
108
109 Here you'll find a lot of lines starting with **mod_**. These are all the
110 modules your ejabberd instance will load on startup. There are several in here
111 that we need to add *_odbc* to the end of to make them talk to our MySql
112 database instead of the internal database. Find the following listed modules
113 and add _odbc to them (I've already done that in my list)
114
115 ----
116 {mod_last_odbc, []},
117 {mod_offline_odbc, []},
118 {mod_privacy_odbc, []},
119 {mod_private_odbc, []},
120 {mod_pubsub_odbc, [ % requires mod_caps ...
121 {mod_roster_odbc, []},
122 {mod_vcard_odbc, []},
123 ----
124
125 And finally, we're done. On a side note, you might want to uncomment the module
126 mod_65[] to enable file transfers. You never know when you'll need to
127 http://xkcd.com/949/[transfer a big file].
128
129
130 Category:MySQL
131 Category:XMPP
132 Category:Linux
133
134
135 // vim: set syntax=asciidoc:
|